Files
steiermark/public/typo3conf/ext/off/Classes/Zuteilungen/Zuteilungen.php
T
2026-10-06 19:40:28 +02:00

87 lines
2.3 KiB
PHP

<?php
namespace HermannTelser\Zuladungsliste\Zuteilungen;
use ForceUTF8\Encoding;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use HermannTelser\Zuladungsliste\Berechnung\_Berechnung;
/***
*
* This file is part of the "Zuladungsliste Steiermark" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
*
* Copyright notice
*
* (c) 2017 - 2022 Hermann Telser <hermann.telser@gmail.com>
*
* All rights reserved
* ************************************************************* */
class Zuteilungen
{
/**
* @return void
*/
public static function laden($return_array = false)
{
$liste = new _Berechnung();
$liste::berechnen();
$_p = ['n2','n3','n4','n5','n6','e2','e3','e4','e5','e6'];
$_arr = [];
foreach (_Berechnung::$_data['liste'] as $key => $value) {
$door = false;
foreach ($_p as $k => $v) {
if (isset($value[$v]) and $value[$v] == 1) {
$value[$v] = (int) $value[$v];
$door = true;
}
}
if ($door) {
unset($value['auswertung']);
$_arr[] = $value;
}
}
if ($return_array) {
return $_arr;
}
header('Content-Type: application/json');
echo json_encode($_arr);
exit();
}
/**
* @return void
*/
public static function filterNaechsten($_arr, $dienaechsten)
{
$f1 = "n".$dienaechsten;
$f2 = "e".$dienaechsten;
// echo "\nf1: " . $f1;
// echo "\nf2: " . $f2;
// echo "\n";
$next = [];
foreach ($_arr as $key => $value) {
if ((isset($value[$f1]) and $value[$f1]==1) || (isset($value[$f2]) and $value[$f2]==1)) {
$tmp = [];
$tmp['user_id'] = $value['user_id'];
$tmp['pos'] = $value['pos'];
$tmp['rang'] = $value['rang'];
$tmp["ersatz"] = $value[$f2] ? $value[$f2] : 0;
$tmp[$f1] = $value[$f1];
$tmp[$f2] = $value[$f2];
$next[] = $tmp;
}
}
return $next;
}
}