Skip to content

Commit

Permalink
Merge branch 'next' into bugfix-zmskvr-129-too-many-appointments-with…
Browse files Browse the repository at this point in the history
…-email-at-location
  • Loading branch information
Thomas Fink authored and Thomas Fink committed Feb 21, 2025
2 parents cfd68e3 + da896f7 commit 6b8b1ca
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 20 deletions.
8 changes: 7 additions & 1 deletion zmsentities/src/Zmsentities/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,19 @@ public function getGroupedHashSet(array $fields, array $hashfields)
$field = array_shift($fields);
$fieldposition = $this->getPositionByName($field);

$requestscountPosition = $this->getPositionByName('requestscount');


foreach ($this->data as $element) {
// Check if $fieldposition exists in $element
if (isset($element[$fieldposition])) {
if (!isset($list[$element[$fieldposition]])) {
$list[$element[$fieldposition]] = clone $this;
$list[$element[$fieldposition]]->data = [];
}
if ($requestscountPosition !== false && isset($element[$requestscountPosition])) {
$element[$requestscountPosition] = (int) $element[$requestscountPosition];
}

$list[$element[$fieldposition]]->data[] = $element;
}
}
Expand Down
39 changes: 33 additions & 6 deletions zmsstatistic/src/Zmsstatistic/Download/RequestReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;

class RequestReport extends Base
{
Expand Down Expand Up @@ -87,19 +88,45 @@ public function writeHeader(ReportEntity $report, $sheet, $datePatternCol1, $dat
public function writeReportData(ReportEntity $report, $sheet, $datePatternCol1, $datePatternCol2)
{
$reportData = [];
$rowIndex = $sheet->getHighestRow() + 1;
$firstDataRow = $rowIndex;

foreach ($report->data as $name => $entry) {
if ('sum' != $name && 'average_processingtime' != $name) {
$reportData[$name][] = $name;
$reportData[$name][] = isset($report->data['average_processingtime'][$name]) || is_numeric($report->data['average_processingtime'][$name]) ? (string)$report->data['average_processingtime'][$name] : "0";
$reportData[$name][] = $report->data['sum'][$name];
if ($name !== 'sum' && $name !== 'average_processingtime') {
$rowData = [];
$rowData[] = $name;
$rowData[] = isset($report->data['average_processingtime'][$name])
&& is_numeric($report->data['average_processingtime'][$name])
? (string)$report->data['average_processingtime'][$name]
: "0";
$rowData[] = $report->data['sum'][$name];

$dateTime = clone $this->firstDayDate;
do {
$dateString = $dateTime->format($this->dateFormatter[$report->period]);
$reportData[$name][] = (isset($entry[$dateString])) ? $entry[$dateString]['requestscount'] : '0';
$rowData[] = isset($entry[$dateString]) ? (int)$entry[$dateString]['requestscount'] : '0';


$dateTime->modify('+1 ' . $report->period);
} while ($dateTime <= $this->lastDayDate);

$reportData[$name] = $rowData;
}
}
$sheet->fromArray($reportData, null, 'A' . ($sheet->getHighestRow() + 1));

$sheet->fromArray($reportData, null, 'A' . $rowIndex);
$lastColumn = $sheet->getHighestColumn();
$lastRow = $sheet->getHighestRow();
$sumRowIndex = $lastRow + 2;
$sumRow = ["Summe", "", ""];
$sumRow[2] = "=SUM(C{$firstDataRow}:C{$lastRow})";
$lastColumnIndex = Coordinate::columnIndexFromString($lastColumn);

for ($colIndex = 4; $colIndex <= $lastColumnIndex; $colIndex++) {
$colLetter = Coordinate::stringFromColumnIndex($colIndex);
$sumRow[] = "=SUM({$colLetter}{$firstDataRow}:{$colLetter}{$lastRow})";
}

$sheet->fromArray($sumRow, null, 'A' . $sumRowIndex);
}
}
67 changes: 54 additions & 13 deletions zmsstatistic/templates/page/reportRequestIndex.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,72 @@
</tr>
</thead>
<tbody>
{% for name, entry in exchangeRequest.data|filter(name => name != "sum") %}
{% if name != "average_processingtime" %}
<tr>
<th class="report-board--long-text">{{ name|trans }}</th>
{% if exchangeRequest.period == "day" %}
{% set totalSum = 0 %}

{% for name, entry in exchangeRequest.data %}

{% if name != "average_processingtime" and name != "sum" %}
<tr>
<th class="report-board--long-text">{{ name|trans }}</th>

{% if exchangeRequest.period == "day" %}
<td class="report-board--summary">
{{ exchangeRequest.data.average_processingtime[name]|default("-") }}
</td>
{% endif %}

<td class="report-board--summary">
{{ exchangeRequest.data.average_processingtime[name]|default("-") }}
{{ exchangeRequest.data.sum[name] }}
</td>

{% set totalSum = totalSum + (exchangeRequest.data.sum[name]|default(0)) %}

{% for date in dateRange %}
{% if exchangeRequest.period == "day" %}
{% set formattedDate = "#{year}-#{month}-#{date}"|date("Y-m-d") %}
{% elseif exchangeRequest.period == "month" %}
{% set formattedDate = startDate|date('Y') ~"-"~ "%02d"|format(date) %}
{% endif %}

<td>
<span class="{% if not entry[formattedDate].requestscount %}ausgegraut{% endif %}">
{{ entry[formattedDate].requestscount|default("-") }}
</span>
</td>
{% endfor %}
</tr>
{% endif %}
{% endfor %}

<tr>
<th class="report-board--long-text">Summe</th>

{% if exchangeRequest.period == "day" %}
<td class="report-board--summary">-</td>
{% endif %}

<td class="report-board--summary">
{{ exchangeRequest.data.sum[name] }}
{{ totalSum }}
</td>

{% for date in dateRange %}
{% if exchangeRequest.period == "day" %}
{% set date = "#{year}-#{month}-#{date}"|date("Y-m-d") %}
{% set formattedDate = "#{year}-#{month}-#{date}"|date("Y-m-d") %}
{% elseif exchangeRequest.period == "month" %}
{% set date = startDate|date('Y') ~"-"~ "%02d"|format(date) %}
{% set formattedDate = startDate|date('Y') ~"-"~ "%02d"|format(date) %}
{% endif %}
<td>
<span class="{% if not entry[date].requestscount %}ausgegraut{% endif %}">{{ entry[date].requestscount|default("-") }}</span><br>

{% set dateSum = 0 %}

{% for name, entry in exchangeRequest.data %}
{% set dateSum = dateSum + (entry[formattedDate].requestscount|default(0)) %}
{% endfor %}

<td class="report-board--summary">
{{ dateSum }}
</td>
{% endfor %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
Expand Down

0 comments on commit 6b8b1ca

Please sign in to comment.