configurable print export (#2657)
This commit is contained in:
@@ -93,6 +93,7 @@ require('./js/KimaiWebLoader.js');
|
||||
global.KimaiPaginatedBoxWidget = require('./js/widgets/KimaiPaginatedBoxWidget').default;
|
||||
global.KimaiReloadPageWidget = require('./js/widgets/KimaiReloadPageWidget').default;
|
||||
global.KimaiCookies = require('./js/widgets/KimaiCookies').default;
|
||||
global.KimaiStorage = require('./js/widgets/KimaiStorage').default;
|
||||
|
||||
// ------ Autocomplete for tags only ------
|
||||
require('jquery-ui/ui/widgets/autocomplete');
|
||||
|
||||
30
assets/js/widgets/KimaiStorage.js
Normal file
30
assets/js/widgets/KimaiStorage.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* [KIMAI] KimaiStorage: simple wrapper to handle localStorage access
|
||||
*/
|
||||
|
||||
export default class KimaiStorage {
|
||||
|
||||
static set(name, values) {
|
||||
window.localStorage.setItem(name, JSON.stringify(values));
|
||||
}
|
||||
|
||||
static get(name) {
|
||||
let value = window.localStorage.getItem(name);
|
||||
if (value === undefined || value === null) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
static remove(name) {
|
||||
window.localStorage.removeItem(name);
|
||||
}
|
||||
|
||||
}
|
||||
2
public/build/app.07c264a7.js
Normal file
2
public/build/app.07c264a7.js
Normal file
File diff suppressed because one or more lines are too long
@@ -135,6 +135,10 @@
|
||||
* [KIMAI] KimaiSelectDataAPI: <select> boxes with dynamic data from API
|
||||
*/
|
||||
|
||||
/*!
|
||||
* [KIMAI] KimaiStorage: simple wrapper to handle localStorage access
|
||||
*/
|
||||
|
||||
/*!
|
||||
* [KIMAI] KimaiThemeInitializer: initialize theme functionality
|
||||
*/
|
||||
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@
|
||||
"app": {
|
||||
"js": [
|
||||
"build/runtime.b8e7bb04.js",
|
||||
"build/app.1cecb23c.js"
|
||||
"build/app.07c264a7.js"
|
||||
],
|
||||
"css": [
|
||||
"build/app.079fbef2.css"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"build/app.css": "build/app.079fbef2.css",
|
||||
"build/app.js": "build/app.1cecb23c.js",
|
||||
"build/app.js": "build/app.07c264a7.js",
|
||||
"build/invoice.css": "build/invoice.ff32661a.css",
|
||||
"build/invoice.js": "build/invoice.19f36eca.js",
|
||||
"build/invoice-pdf.css": "build/invoice-pdf.9a7468ef.css",
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Export\ExportItemInterface;
|
||||
use App\Export\ServiceExport;
|
||||
use App\Export\TooManyItemsExportException;
|
||||
use App\Form\Toolbar\ExportToolbarForm;
|
||||
use App\Repository\Query\ExportQuery;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
@@ -45,6 +46,7 @@ class ExportController extends AbstractController
|
||||
$query = $this->getDefaultQuery();
|
||||
|
||||
$showPreview = false;
|
||||
$tooManyResults = false;
|
||||
$maxItemsPreview = 500;
|
||||
$entries = [];
|
||||
|
||||
@@ -56,25 +58,33 @@ class ExportController extends AbstractController
|
||||
$byCustomer = [];
|
||||
|
||||
if ($form->isValid() && ($query->hasBookmark() || $request->query->has('performSearch'))) {
|
||||
$showPreview = true;
|
||||
$entries = $this->getEntries($query);
|
||||
foreach ($entries as $entry) {
|
||||
$cid = $entry->getProject()->getCustomer()->getId();
|
||||
if (!isset($byCustomer[$cid])) {
|
||||
$byCustomer[$cid] = [
|
||||
'customer' => $entry->getProject()->getCustomer(),
|
||||
'rate' => 0,
|
||||
'internalRate' => 0,
|
||||
'duration' => 0,
|
||||
];
|
||||
try {
|
||||
$showPreview = true;
|
||||
$entries = $this->getEntries($query);
|
||||
foreach ($entries as $entry) {
|
||||
$cid = $entry->getProject()->getCustomer()->getId();
|
||||
if (!isset($byCustomer[$cid])) {
|
||||
$byCustomer[$cid] = [
|
||||
'customer' => $entry->getProject()->getCustomer(),
|
||||
'rate' => 0,
|
||||
'internalRate' => 0,
|
||||
'duration' => 0,
|
||||
];
|
||||
}
|
||||
$byCustomer[$cid]['rate'] += $entry->getRate();
|
||||
$byCustomer[$cid]['internalRate'] += $entry->getInternalRate();
|
||||
$byCustomer[$cid]['duration'] += $entry->getDuration();
|
||||
}
|
||||
$byCustomer[$cid]['rate'] += $entry->getRate();
|
||||
$byCustomer[$cid]['internalRate'] += $entry->getInternalRate();
|
||||
$byCustomer[$cid]['duration'] += $entry->getDuration();
|
||||
} catch (TooManyItemsExportException $ex) {
|
||||
$tooManyResults = true;
|
||||
$showPreview = false;
|
||||
$entries = [];
|
||||
$this->logException($ex);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('export/index.html.twig', [
|
||||
'too_many' => $tooManyResults,
|
||||
'by_customer' => $byCustomer,
|
||||
'query' => $query,
|
||||
'entries' => $entries,
|
||||
@@ -136,7 +146,7 @@ class ExportController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param ExportQuery $query
|
||||
* @return Timesheet[]
|
||||
* @return ExportItemInterface[]
|
||||
*/
|
||||
protected function getEntries(ExportQuery $query): array
|
||||
{
|
||||
|
||||
28
src/Event/ExportItemsQueryEvent.php
Normal file
28
src/Event/ExportItemsQueryEvent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Repository\Query\ExportQuery;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
class ExportItemsQueryEvent extends Event
|
||||
{
|
||||
private $query;
|
||||
|
||||
public function __construct(ExportQuery $query)
|
||||
{
|
||||
$this->query = $query;
|
||||
}
|
||||
|
||||
public function getExportQuery(): ExportQuery
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
namespace App\Export;
|
||||
|
||||
use App\Event\ExportItemsQueryEvent;
|
||||
use App\Repository\Query\ExportQuery;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
final class ServiceExport
|
||||
{
|
||||
@@ -20,17 +22,24 @@ final class ServiceExport
|
||||
/**
|
||||
* @var TimesheetExportInterface[]
|
||||
*/
|
||||
private $exporter = [];
|
||||
private $timesheetExporter = [];
|
||||
/**
|
||||
* @var ExportRepositoryInterface[]
|
||||
*/
|
||||
private $repositories = [];
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
public function addRenderer(ExportRendererInterface $renderer): ServiceExport
|
||||
public function __construct(EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function addRenderer(ExportRendererInterface $renderer): void
|
||||
{
|
||||
$this->renderer[] = $renderer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,11 +61,9 @@ final class ServiceExport
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addTimesheetExporter(TimesheetExportInterface $exporter): ServiceExport
|
||||
public function addTimesheetExporter(TimesheetExportInterface $exporter): void
|
||||
{
|
||||
$this->exporter[] = $exporter;
|
||||
|
||||
return $this;
|
||||
$this->timesheetExporter[] = $exporter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,12 +71,12 @@ final class ServiceExport
|
||||
*/
|
||||
public function getTimesheetExporter(): array
|
||||
{
|
||||
return $this->exporter;
|
||||
return $this->timesheetExporter;
|
||||
}
|
||||
|
||||
public function getTimesheetExporterById(string $id): ?TimesheetExportInterface
|
||||
{
|
||||
foreach ($this->exporter as $exporter) {
|
||||
foreach ($this->timesheetExporter as $exporter) {
|
||||
if ($exporter->getId() === $id) {
|
||||
return $exporter;
|
||||
}
|
||||
@@ -78,19 +85,31 @@ final class ServiceExport
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addExportRepository(ExportRepositoryInterface $repository): ServiceExport
|
||||
public function addExportRepository(ExportRepositoryInterface $repository): void
|
||||
{
|
||||
$this->repositories[] = $repository;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExportQuery $query
|
||||
* @return ExportItemInterface[]
|
||||
* @throws TooManyItemsExportException
|
||||
*/
|
||||
public function getExportItems(ExportQuery $query)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$event = new ExportItemsQueryEvent($query);
|
||||
$this->eventDispatcher->dispatch($event);
|
||||
$max = $event->getExportQuery()->getMaxResults();
|
||||
|
||||
foreach ($this->repositories as $repository) {
|
||||
$items = array_merge($items, $repository->getExportItemsForQuery($query));
|
||||
$items = array_merge($items, $repository->getExportItemsForQuery($event->getExportQuery()));
|
||||
if ($max !== null && \count($items) > $max) {
|
||||
throw new TooManyItemsExportException(
|
||||
sprintf('Limit reached! Expected max. %s items but got %s', $max, \count($items))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
17
src/Export/TooManyItemsExportException.php
Normal file
17
src/Export/TooManyItemsExportException.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Export;
|
||||
|
||||
/**
|
||||
* THIS IS MORE A QUICKFIX THAN ANYTHING ELSE!
|
||||
*/
|
||||
final class TooManyItemsExportException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -58,6 +58,10 @@ class TimesheetQuery extends ActivityQuery implements BillableInterface
|
||||
* @var User[]
|
||||
*/
|
||||
private $users = [];
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $maxResults;
|
||||
|
||||
public function __construct(bool $resetTimes = true)
|
||||
{
|
||||
@@ -69,6 +73,16 @@ class TimesheetQuery extends ActivityQuery implements BillableInterface
|
||||
]);
|
||||
}
|
||||
|
||||
public function getMaxResults(): ?int
|
||||
{
|
||||
return $this->maxResults;
|
||||
}
|
||||
|
||||
public function setMaxResults(?int $maxResults): void
|
||||
{
|
||||
$this->maxResults = $maxResults;
|
||||
}
|
||||
|
||||
public function addUser(User $user): self
|
||||
{
|
||||
$this->users[$user->getId()] = $user;
|
||||
|
||||
@@ -962,6 +962,10 @@ class TimesheetRepository extends EntityRepository
|
||||
$qb->leftJoin('t.activity', 'a');
|
||||
}
|
||||
|
||||
if ($query->getMaxResults() !== null) {
|
||||
$qb->setMaxResults($query->getMaxResults());
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@
|
||||
{% block box_after %}{{ form_end(form) }}{% endblock %}
|
||||
{% endembed %}
|
||||
|
||||
{% if preview_show %}
|
||||
{% if too_many is same as (true) %}
|
||||
{{ widgets.callout('danger', 'error.too_many_entries') }}
|
||||
{% elseif preview_show %}
|
||||
{% if entries is empty %}
|
||||
{{ widgets.nothing_found() }}
|
||||
{% else %}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
{% block document_title %}{{ 'export.title'|trans }}{% endblock %}
|
||||
|
||||
{% set storageItemName = 'kimai_html_export' %}
|
||||
{% set showRateBudget = false %}
|
||||
{% set showTimeBudget = false %}
|
||||
{% for budget in budgets %}
|
||||
@@ -19,6 +20,8 @@
|
||||
{% set columnTitles = {} %}
|
||||
{% set columns = {
|
||||
'date': true,
|
||||
'begin': false,
|
||||
'end': false,
|
||||
'username': false,
|
||||
'customer': true,
|
||||
'project': true,
|
||||
@@ -62,27 +65,175 @@
|
||||
let initialized = false;
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
let config = KimaiCookies.get('kimai_html_export');
|
||||
if (config !== undefined && config !== null) {
|
||||
console.log(config);
|
||||
for (const key in config) {
|
||||
let elName = key;
|
||||
let checked = config[key];
|
||||
let el = document.getElementById(elName);
|
||||
if (el === undefined || el === null) {
|
||||
el = document.getElementById('records-column-' + elName);
|
||||
if (el === undefined || el === null) {
|
||||
continue;
|
||||
}
|
||||
var loader = new KimaiWebLoader({
|
||||
formatDuration: '{{ get_format_duration() }}',
|
||||
locale: '{{ app.request.locale }}',
|
||||
}, {});
|
||||
var DATES = loader.getKimai().getPlugin('date');
|
||||
|
||||
document.getElementById('duration-decimal').addEventListener('click', function(event) {
|
||||
var spans = document.getElementsByClassName('duration-format');
|
||||
for (var span of spans) {
|
||||
var duration = span.dataset['duration'];
|
||||
if (duration === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (checked !== el.checked) {
|
||||
el.click();
|
||||
if (!event.target.checked) {
|
||||
span.innerHTML = DATES.formatSeconds(duration);
|
||||
} else {
|
||||
span.innerHTML = (new Intl.NumberFormat('{{ app.request.locale }}', {maximumFractionDigits: 2}).format(duration / 3600));
|
||||
}
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
|
||||
document.getElementById('summary-by-activities').addEventListener('click', function(event) {
|
||||
document.getElementById('summary-project').style.display = event.target.checked ? 'none' : 'table';
|
||||
document.getElementById('summary-activity').style.display = event.target.checked ? 'table' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('date-format').addEventListener('change', function(event) {
|
||||
changedDateFormat(event.target.value, 'dateformat');
|
||||
});
|
||||
document.getElementById('begin-format').addEventListener('change', function(event) {
|
||||
changedDateFormat(event.target.value, 'beginformat');
|
||||
});
|
||||
document.getElementById('end-format').addEventListener('change', function(event) {
|
||||
changedDateFormat(event.target.value, 'endformat');
|
||||
});
|
||||
document.getElementById('summary-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
{% if showTimeBudget %}
|
||||
document.getElementById('summary-timeBudget').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('export-timeBudget');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
{% endif %}
|
||||
{% if showRateBudget %}
|
||||
document.getElementById('summary-budget').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('export-budget');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
{% endif %}
|
||||
document.getElementById('summary-duration').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-duration');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-rate').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-rate');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-rate-internal').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-rate-internal');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('records-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-records').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
|
||||
var columnCheckboxes = document.getElementsByClassName('column-visibility-changer');
|
||||
|
||||
for (var checkbox of columnCheckboxes) {
|
||||
checkbox.addEventListener('click', function(event) {
|
||||
changeVisibility(event.target.name, event.target.checked);
|
||||
});
|
||||
}
|
||||
|
||||
var editableTitles = document.querySelectorAll('[contenteditable=true]');
|
||||
|
||||
for (var editable of editableTitles) {
|
||||
editable.addEventListener('input', function(event) {
|
||||
if (event.target.innerText === '') {
|
||||
return;
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
}
|
||||
|
||||
// needs to be executed as last action in the flow, after the listener were registered
|
||||
let config = localStorage.getItem('{{ storageItemName }}');
|
||||
if (config !== null) {
|
||||
try {
|
||||
config = JSON.parse(config);
|
||||
for (const elName in config) {
|
||||
if (!config.hasOwnProperty(elName)) {
|
||||
continue;
|
||||
}
|
||||
let elValue = config[elName];
|
||||
let el = document.getElementById(elName);
|
||||
if (el === undefined || el === null) {
|
||||
el = document.getElementById('records-column-' + elName);
|
||||
if (el === undefined || el === null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (el.type === 'checkbox') {
|
||||
if (elValue !== el.checked) {
|
||||
el.click();
|
||||
}
|
||||
} else if (el.type === 'select-one') {
|
||||
if (el.value !== elValue) {
|
||||
el.value = elValue;
|
||||
el.dispatchEvent(new Event('change'));
|
||||
}
|
||||
} else if (el.isContentEditable) {
|
||||
el.innerText = elValue;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore error in restoring
|
||||
console.log('Failed to restore settings, clearing all up: ', e);
|
||||
localStorage.removeItem('{{ storageItemName }}');
|
||||
}
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
});
|
||||
|
||||
function changeVisibility(column, visible)
|
||||
{
|
||||
var cells = document.getElementsByClassName('column-' + column);
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = visible ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
}
|
||||
|
||||
function changedDateFormat(formatType, className)
|
||||
{
|
||||
var elements = document.getElementsByClassName(className);
|
||||
for (var elem of elements) {
|
||||
var formattedDate = elem.dataset[formatType];
|
||||
if (formattedDate === undefined) {
|
||||
continue;
|
||||
}
|
||||
elem.innerHTML = formattedDate;
|
||||
}
|
||||
saveVisibility();
|
||||
}
|
||||
|
||||
function saveVisibility()
|
||||
{
|
||||
if (!initialized) {
|
||||
@@ -92,81 +243,42 @@
|
||||
const form = document.getElementsByTagName('form')[0];
|
||||
let settings = {};
|
||||
for (let checkbox of form.querySelectorAll('input[type=checkbox]')) {
|
||||
settings[checkbox.getAttribute('name')] = checkbox.checked;
|
||||
settings[checkbox.getAttribute('id')] = checkbox.checked;
|
||||
}
|
||||
KimaiCookies.set('kimai_html_export', settings, {expires: 365, SameSite: 'Strict'});
|
||||
for (let selectbox of form.querySelectorAll('select')) {
|
||||
settings[selectbox.getAttribute('id')] = selectbox.value;
|
||||
}
|
||||
for (let editable of document.querySelectorAll('[contenteditable=true]')) {
|
||||
settings[editable.getAttribute('id')] = editable.innerText;
|
||||
}
|
||||
localStorage.setItem('{{ storageItemName }}', JSON.stringify(settings));
|
||||
}
|
||||
document.getElementById('summary-by-activities').addEventListener('click', function(event) {
|
||||
document.getElementById('summary-project').style.display = event.target.checked ? 'none' : 'table';
|
||||
document.getElementById('summary-activity').style.display = event.target.checked ? 'table' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
{% if showTimeBudget %}
|
||||
document.getElementById('summary-timeBudget').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('export-timeBudget');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
|
||||
function resetExport()
|
||||
{
|
||||
var editableTitles = document.querySelectorAll('[contenteditable=true]');
|
||||
|
||||
for (var editable of editableTitles) {
|
||||
editable.innerText = editable.dataset['original'];
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
{% endif %}
|
||||
{% if showRateBudget %}
|
||||
document.getElementById('summary-budget').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('export-budget');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
{% endif %}
|
||||
document.getElementById('summary-duration').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-duration');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-rate').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-rate');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-rate-internal').addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('summary-rate-internal');
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('summary-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
document.getElementById('records-show').addEventListener('click', function(event) {
|
||||
document.getElementById('export-records').style.display = event.target.checked ? 'block' : 'none';
|
||||
saveVisibility();
|
||||
});
|
||||
var columnCheckboxes = document.getElementsByClassName('column-visibility-changer');
|
||||
for (var checkbox of columnCheckboxes) {
|
||||
checkbox.addEventListener('click', function(event) {
|
||||
var cells = document.getElementsByClassName('column-'+event.target.name);
|
||||
for (var columnCell of cells) {
|
||||
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
|
||||
}
|
||||
saveVisibility();
|
||||
});
|
||||
|
||||
localStorage.removeItem('{{ storageItemName }}');
|
||||
const form = document.getElementsByTagName('form')[0];
|
||||
form.reset();
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
<style>
|
||||
@media print{
|
||||
h2 { font-size: 22px; }
|
||||
h3 { font-size: 18px; }
|
||||
p, td { font-size: 11px; }
|
||||
th, td.totals { font-size: 12px; }
|
||||
table.table-bordered.dataTable { border-collapse: collapse!important; }
|
||||
}
|
||||
.items td.totals {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
@@ -174,102 +286,143 @@
|
||||
.items td.duration,
|
||||
.items th.duration,
|
||||
.items th.cost,
|
||||
.items td.cost {
|
||||
text-align: center;
|
||||
.items td.cost,
|
||||
.items th.column-rate,
|
||||
.items th.column-rate_internal,
|
||||
.items th.column-duration
|
||||
{
|
||||
text-align: right;
|
||||
}
|
||||
.toolbar {
|
||||
border-bottom: 1px solid #ccc;
|
||||
background-color: #eee;
|
||||
padding: 5px 0 0 5px;
|
||||
.table>thead:first-child>tr:first-child>th {
|
||||
padding-right: 5px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block export %}
|
||||
<div class="row no-print toolbar">
|
||||
<div class="col-xs-12">
|
||||
<form class="form-inline">
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-show">
|
||||
<input type="checkbox" id="summary-show" name="summary-show" checked="checked">
|
||||
{{ 'export.summary'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-11">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-by-activities">
|
||||
<input type="checkbox" id="summary-by-activities" name="summary-by-activities">
|
||||
{{ 'label.activity'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% if showTimeBudget %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-timeBudget">
|
||||
<input type="checkbox" id="summary-timeBudget" name="summary-timeBudget" checked>
|
||||
{{ 'label.timeBudget'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if showRateBudget %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-budget">
|
||||
<input type="checkbox" id="summary-budget" name="summary-budget" checked>
|
||||
{{ 'label.budget'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-duration">
|
||||
<input type="checkbox" id="summary-duration" name="summary-duration" checked>
|
||||
{{ 'label.duration'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-rate-internal">
|
||||
<input type="checkbox" id="summary-rate-internal" name="summary-rate-internal" checked>
|
||||
{{ 'label.rate_internal'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-rate">
|
||||
<input type="checkbox" id="summary-rate" name="summary-rate" checked>
|
||||
{{ 'label.rate'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="records-show">
|
||||
<input type="checkbox" id="records-show" name="records-show" checked="checked">
|
||||
{{ 'export.full_list'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-11">
|
||||
{% for columnId, visibility in columns %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="records-column-{{ columnId }}">
|
||||
<input type="checkbox" class="column-visibility-changer" id="records-column-{{ columnId }}" name="{{ columnId }}" {% if visibility %}checked="checked"{% endif %}>
|
||||
{{ columnTitles[columnId]|default('label.'~columnId)|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="form-inline no-print">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{ 'settings'|trans({}, 'actions') }}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<label class="control-label" for="duration-decimal">
|
||||
<input type="checkbox" id="duration-decimal" name="duration-decimal"{% if decimal%} checked="checked"{% endif %}>
|
||||
{{ 'label.timesheet.export_decimal'|trans }}
|
||||
</label>
|
||||
|
|
||||
<label class="control-label" for="date-format">
|
||||
{{ 'label.date'|trans }}:
|
||||
{% set demo_date = create_date('2020-01-01 20:00:00') %}
|
||||
<select id="date-format" name="date-format">
|
||||
<option value="time">{{ demo_date|date_time }}</option>
|
||||
<option value="short">{{ demo_date|date_short }}</option>
|
||||
<option value="full">{{ demo_date|date_full }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
|
||||
<label class="control-label" for="begin-format">
|
||||
{{ 'label.begin'|trans }}:
|
||||
{% set demo_date = create_date('2020-01-01 13:00:00') %}
|
||||
<select id="begin-format" name="begin-format">
|
||||
<option value="plain">{{ demo_date|date_format('H:i') }}</option>
|
||||
<option value="time">{{ demo_date|date_time }}</option>
|
||||
<option value="short">{{ demo_date|date_short }}</option>
|
||||
<option value="full">{{ demo_date|date_full }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
|
||||
<label class="control-label" for="end-format">
|
||||
{{ 'label.end'|trans }}:
|
||||
{% set demo_date = create_date('2020-01-01 18:00:00') %}
|
||||
<select id="end-format" name="end-format">
|
||||
<option value="plain">{{ demo_date|date_format('H:i') }}</option>
|
||||
<option value="time">{{ demo_date|date_time }}</option>
|
||||
<option value="short">{{ demo_date|date_short }}</option>
|
||||
<option value="full">{{ demo_date|date_full }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<button type="reset" class="btn btn-primary pull-right" onclick="resetExport()">{{ 'action.reset'|trans }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<label class="control-label" for="summary-show">
|
||||
<input type="checkbox" id="summary-show" name="summary-show" checked="checked">
|
||||
{{ 'export.summary'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-by-activities">
|
||||
<input type="checkbox" id="summary-by-activities" name="summary-by-activities">
|
||||
{{ 'label.activity'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% if showTimeBudget %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-timeBudget">
|
||||
<input type="checkbox" id="summary-timeBudget" name="summary-timeBudget" checked>
|
||||
{{ 'label.timeBudget'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if showRateBudget %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-budget">
|
||||
<input type="checkbox" id="summary-budget" name="summary-budget" checked>
|
||||
{{ 'label.budget'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-duration">
|
||||
<input type="checkbox" id="summary-duration" name="summary-duration" checked>
|
||||
{{ 'label.duration'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-rate-internal">
|
||||
<input type="checkbox" id="summary-rate-internal" name="summary-rate-internal" checked>
|
||||
{{ 'label.rate_internal'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="summary-rate">
|
||||
<input type="checkbox" id="summary-rate" name="summary-rate" checked>
|
||||
{{ 'label.rate'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="records-show">
|
||||
<input type="checkbox" id="records-show" name="records-show" checked="checked">
|
||||
{{ 'export.full_list'|trans }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% for columnId, visibility in columns %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="records-column-{{ columnId }}">
|
||||
<input type="checkbox" class="column-visibility-changer" id="records-column-{{ columnId }}" name="{{ columnId }}" {% if visibility %}checked="checked"{% endif %}>
|
||||
{{ columnTitles[columnId]|default('label.'~columnId)|trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h2>{{ 'export.document_title'|trans }}</h2>
|
||||
<h2 id="doc-title" contenteditable="true" data-original="{{ 'export.document_title'|trans }}">{{ 'export.document_title'|trans }}</h2>
|
||||
<p>
|
||||
{{ 'export.period'|trans }}:
|
||||
{{ query.begin|date_short }} - {{ query.end|date_short }}
|
||||
@@ -279,7 +432,7 @@
|
||||
|
||||
<div class="row" id="export-summary">
|
||||
<div class="col-xs-12">
|
||||
<h3>{{ 'export.summary'|trans }}</h3>
|
||||
<h3 id="doc-summary" contenteditable="true" data-original="{{ 'export.summary'|trans }}">{{ 'export.summary'|trans }}</h3>
|
||||
<table class="items table table-condensed table-bordered dataTable" id="summary-project">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -316,7 +469,9 @@
|
||||
{% if showRateBudget %}
|
||||
<td class="export-budget"></td>
|
||||
{% endif %}
|
||||
<td class="totals duration summary-duration">{{ customerDuration|duration(decimal) }}</td>
|
||||
<td class="totals duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ customerDuration }}">{{ customerDuration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="totals cost summary-rate-internal">{{ customerInternalRate|money(customerCurrency) }}</td>
|
||||
<td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
@@ -332,7 +487,7 @@
|
||||
{% if showTimeBudget %}
|
||||
<td class="center export-timeBudget">
|
||||
{% if budgets[id] is defined and budgets[id].time_left > 0 %}
|
||||
{{ budgets[id].time_left|duration(decimal) }}
|
||||
<span class="duration-format" data-duration="{{ budgets[id].time_left }}">{{ budgets[id].time_left|duration(decimal) }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
@@ -343,7 +498,9 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="duration summary-duration">{{ summary.duration|duration(decimal) }}</td>
|
||||
<td class="duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ summary.duration }}">{{ summary.duration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="cost summary-rate-internal">{{ summary.rate_internal|money(summary.currency) }}</td>
|
||||
<td class="cost summary-rate">{{ summary.rate|money(summary.currency) }}</td>
|
||||
</tr>
|
||||
@@ -360,7 +517,9 @@
|
||||
{% if showRateBudget %}
|
||||
<td class="export-budget"></td>
|
||||
{% endif %}
|
||||
<td class="totals duration summary-duration">{{ customerDuration|duration(decimal) }}</td>
|
||||
<td class="totals duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ customerDuration }}">{{ customerDuration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="totals cost summary-rate-internal">{{ customerInternalRate|money(customerCurrency) }}</td>
|
||||
<td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
@@ -399,7 +558,9 @@
|
||||
{% if customer is not same as(summary.customer) %}
|
||||
<tr class="summary">
|
||||
<td colspan="3"></td>
|
||||
<td class="totals duration summary-duration">{{ customerDuration|duration(decimal) }}</td>
|
||||
<td class="totals duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ customerDuration }}">{{ customerDuration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="totals cost summary-rate-internal">{{ customerInternalRate|money(customerCurrency) }}</td>
|
||||
<td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
@@ -414,7 +575,9 @@
|
||||
<td>{{ summary.customer }}</td>
|
||||
<td>{{ summary.project }}</td>
|
||||
<td>{{ activitySummary.activity }}</td>
|
||||
<td class="duration summary-duration">{{ activitySummary.duration|duration(decimal) }}</td>
|
||||
<td class="duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ activitySummary.duration }}">{{ activitySummary.duration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="cost summary-rate-internal">{{ activitySummary.rate_internal|money(activitySummary.currency) }}</td>
|
||||
<td class="cost summary-rate">{{ activitySummary.rate|money(activitySummary.currency) }}</td>
|
||||
</tr>
|
||||
@@ -426,7 +589,9 @@
|
||||
{% if customer is not same as(null) %}
|
||||
<tr class="summary">
|
||||
<td colspan="3"></td>
|
||||
<td class="totals duration summary-duration">{{ customerDuration|duration(decimal) }}</td>
|
||||
<td class="totals duration summary-duration">
|
||||
<span class="duration-format" data-duration="{{ customerDuration }}">{{ customerDuration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="totals cost summary-rate-internal">{{ customerInternalRate|money(customerCurrency) }}</td>
|
||||
<td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
@@ -438,8 +603,8 @@
|
||||
|
||||
<div class="row" id="export-records">
|
||||
<div class="col-xs-12">
|
||||
<h3>{{ 'export.full_list'|trans }}</h3>
|
||||
<table class="table table-condensed table-bordered dataTable">
|
||||
<h3 id="doc-records" contenteditable="true" data-original="{{ 'export.full_list'|trans }}">{{ 'export.full_list'|trans }}</h3>
|
||||
<table class="items table table-condensed table-bordered dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for columnId, visibility in columns %}
|
||||
@@ -470,11 +635,19 @@
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td class="column-date text-nowrap" {% if not columns.date %}style="display: none"{% endif %}>
|
||||
<span class="dateformat" data-short="{{ entry.begin|date_short }}" data-full="{{ entry.begin|date_full }}" data-time="{{ entry.begin|date_time }}">
|
||||
{{ entry.begin|date_time }}
|
||||
{% if entry.end %}
|
||||
<br>
|
||||
{{ entry.end|date_time }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</td>
|
||||
<td class="column-begin text-nowrap" {% if not columns.begin %}style="display: none"{% endif %}>
|
||||
<span class="beginformat" data-short="{{ entry.begin|date_short }}" data-full="{{ entry.begin|date_full }}" data-time="{{ entry.begin|date_time }}" data-plain="{{ entry.begin|date_format('H:i') }}">
|
||||
{{ entry.begin|date_format('H:i') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="column-end text-nowrap" {% if not columns.end %}style="display: none"{% endif %}>
|
||||
<span class="endformat" data-short="{{ entry.end|date_short }}" data-full="{{ entry.end|date_full }}" data-time="{{ entry.end|date_time }}" data-plain="{{ entry.end|date_format('H:i') }}">
|
||||
{{ entry.end|date_format('H:i') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="column-username" {% if not columns.username %}style="display: none"{% endif %}>
|
||||
{{ widgets.username(entry.user) }}
|
||||
@@ -542,17 +715,17 @@
|
||||
<td class="column-fixedRate text-nowrap" {% if not columns.fixedRate %}style="display: none"{% endif %}>
|
||||
{{ entry.fixedRate|money(entry.project.customer.currency) }}
|
||||
</td>
|
||||
<td class="column-duration text-nowrap" {% if not columns.duration %}style="display: none"{% endif %}>
|
||||
{{ entry.duration|duration(decimal) }}
|
||||
<td class="duration column-duration text-nowrap" {% if not columns.duration %}style="display: none"{% endif %}>
|
||||
<span class="duration-format" data-duration="{{ entry.duration }}">{{ entry.duration|duration(decimal) }}</span>
|
||||
</td>
|
||||
<td class="column-rate_internal text-nowrap" {% if not columns.rate_internal %}style="display: none"{% endif %}>
|
||||
<td class="cost column-rate_internal text-nowrap" {% if not columns.rate_internal %}style="display: none"{% endif %}>
|
||||
{% if entry.internalRate is defined %}
|
||||
{{ entry.internalRate|money(entry.project.customer.currency) }}
|
||||
{% else %}
|
||||
{{ entry.rate|money(entry.project.customer.currency) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="column-rate text-nowrap" {% if not columns.rate %}style="display: none"{% endif %}>
|
||||
<td class="cost column-rate text-nowrap" {% if not columns.rate %}style="display: none"{% endif %}>
|
||||
{{ entry.rate|money(entry.project.customer.currency) }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -565,7 +738,7 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<th class="text-nowrap column-duration">
|
||||
{{- timeWorked|duration(decimal) -}}
|
||||
<span class="duration-format" data-duration="{{ timeWorked }}">{{- timeWorked|duration(decimal) -}}</span>
|
||||
</th>
|
||||
<th class="text-nowrap column-rate_internal">
|
||||
{%- if currency is not null and currency is not same as(false) %}
|
||||
|
||||
@@ -233,13 +233,14 @@ class ExportControllerTest extends ControllerBaseTest
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$content = $response->getContent();
|
||||
$node = $client->getCrawler()->filter('body');
|
||||
$this->assertEquals(1, $node->count());
|
||||
|
||||
// poor mans assertions ;-)
|
||||
$this->assertStringContainsString('export_print', $node->getIterator()[0]->getAttribute('class'));
|
||||
$this->assertStringContainsString('<h2>', $response->getContent());
|
||||
$this->assertStringContainsString('<h3>Summary</h3>', $response->getContent());
|
||||
$this->assertStringContainsString('<h2 id="doc-title" contenteditable="true"', $content);
|
||||
$this->assertStringContainsString('<h3 id="doc-summary" contenteditable="true" data-original="Summary">Summary</h3>', $content);
|
||||
|
||||
$node = $client->getCrawler()->filter('section.export div#export-records table.dataTable tbody tr');
|
||||
// 20 rows + the summary footer
|
||||
|
||||
@@ -52,8 +52,8 @@ class HtmlRendererTest extends AbstractRendererTest
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
$this->assertStringContainsString('<h2>', $content);
|
||||
$this->assertStringContainsString('<h3>Summary</h3>', $content);
|
||||
$this->assertStringContainsString('<h2 id="doc-title" contenteditable="true"', $content);
|
||||
$this->assertStringContainsString('<h3 id="doc-summary" contenteditable="true" data-original="Summary">Summary</h3>', $content);
|
||||
$this->assertEquals(1, substr_count($content, 'id="export-summary"'));
|
||||
$this->assertEquals(1, substr_count($content, 'id="export-records"'));
|
||||
$this->assertEquals(1, substr_count($content, 'id="summary-project"'));
|
||||
@@ -61,7 +61,7 @@ class HtmlRendererTest extends AbstractRendererTest
|
||||
|
||||
$this->assertStringContainsString('<td>Customer Name</td>', $content);
|
||||
$this->assertStringContainsString('<td>project name</td>', $content);
|
||||
$this->assertStringContainsString('<td class="duration summary-duration">01:50 h</td>', $content);
|
||||
$this->assertStringContainsString('<span class="duration-format" data-duration="6600">01:50 h</span>', $content);
|
||||
$this->assertStringContainsString('<td class="cost summary-rate">€2,437.12</td>', $content);
|
||||
|
||||
// 5 times in the "full list" and once in the "summary with activities"
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
|
||||
namespace App\Tests\Export;
|
||||
|
||||
use App\Export\ExportRepositoryInterface;
|
||||
use App\Export\Renderer\HtmlRenderer;
|
||||
use App\Export\ServiceExport;
|
||||
use App\Export\Timesheet\HtmlRenderer as HtmlExporter;
|
||||
use App\Project\ProjectStatisticService;
|
||||
use App\Repository\Query\ExportQuery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
@@ -22,9 +25,16 @@ use Twig\Environment;
|
||||
*/
|
||||
class ServiceExportTest extends TestCase
|
||||
{
|
||||
private function createSut(): ServiceExport
|
||||
{
|
||||
$sut = new ServiceExport($this->createMock(EventDispatcherInterface::class));
|
||||
|
||||
return $sut;
|
||||
}
|
||||
|
||||
public function testEmptyObject()
|
||||
{
|
||||
$sut = new ServiceExport();
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEmpty($sut->getRenderer());
|
||||
self::assertNull($sut->getRendererById('default'));
|
||||
@@ -35,7 +45,7 @@ class ServiceExportTest extends TestCase
|
||||
|
||||
public function testAddRenderer()
|
||||
{
|
||||
$sut = new ServiceExport();
|
||||
$sut = $this->createSut();
|
||||
|
||||
$renderer = new HtmlRenderer($this->createMock(Environment::class), new EventDispatcher(), $this->createMock(ProjectStatisticService::class));
|
||||
$sut->addRenderer($renderer);
|
||||
@@ -46,7 +56,7 @@ class ServiceExportTest extends TestCase
|
||||
|
||||
public function testAddTimesheetExporter()
|
||||
{
|
||||
$sut = new ServiceExport();
|
||||
$sut = $this->createSut();
|
||||
|
||||
$exporter = new HtmlExporter($this->createMock(Environment::class), new EventDispatcher(), $this->createMock(ProjectStatisticService::class));
|
||||
$sut->addTimesheetExporter($exporter);
|
||||
@@ -54,4 +64,18 @@ class ServiceExportTest extends TestCase
|
||||
self::assertEquals(1, \count($sut->getTimesheetExporter()));
|
||||
self::assertSame($exporter, $sut->getTimesheetExporterById('print'));
|
||||
}
|
||||
|
||||
public function testAddExportRepository()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
$repository = $this->createMock(ExportRepositoryInterface::class);
|
||||
$repository->expects($this->once())->method('getExportItemsForQuery')->willReturn([]);
|
||||
$sut->addExportRepository($repository);
|
||||
|
||||
$query = new ExportQuery();
|
||||
$items = $sut->getExportItems($query);
|
||||
|
||||
self::assertEquals([], $items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class TimesheetQueryTest extends BaseQueryTest
|
||||
$this->assertExported($sut);
|
||||
$this->assertSearchTerm($sut);
|
||||
$this->assertModifiedAfter($sut);
|
||||
$this->assertMaxResults($sut);
|
||||
|
||||
self::assertNull($sut->getBillable());
|
||||
self::assertFalse($sut->isBillable());
|
||||
@@ -50,6 +51,13 @@ class TimesheetQueryTest extends BaseQueryTest
|
||||
$this->assertResetByFormError(new TimesheetQuery(), 'begin', 'DESC');
|
||||
}
|
||||
|
||||
protected function assertMaxResults(TimesheetQuery $sut)
|
||||
{
|
||||
self::assertNull($sut->getMaxResults());
|
||||
$sut->setMaxResults(999);
|
||||
self::assertEquals(999, $sut->getMaxResults());
|
||||
}
|
||||
|
||||
protected function assertUser(TimesheetQuery $sut)
|
||||
{
|
||||
self::assertNull($sut->getUser());
|
||||
|
||||
@@ -246,6 +246,10 @@
|
||||
<source>error.no_comments_found</source>
|
||||
<target>Es wurden noch keine Kommentare abgegeben.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="error.too_many_entries">
|
||||
<source>error.too_many_entries</source>
|
||||
<target>Anfrage konnte nicht verarbeitet werden, es wurden zu viele Ergebnisse gefunden.</target>
|
||||
</trans-unit>
|
||||
<!--
|
||||
General labels
|
||||
-->
|
||||
|
||||
@@ -246,6 +246,10 @@
|
||||
<source>error.no_comments_found</source>
|
||||
<target>There were no comments posted yet.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="error.too_many_entries">
|
||||
<source>error.too_many_entries</source>
|
||||
<target>Request could not be processed, too many results were found.</target>
|
||||
</trans-unit>
|
||||
<!--
|
||||
General labels
|
||||
-->
|
||||
|
||||
Reference in New Issue
Block a user