120 lines
4.0 KiB
PHP
120 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace HermannTelser\Watten\Domain\Repository;
|
|
|
|
use TYPO3\CMS\Extbase\Persistence\Repository;
|
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use stdClass;
|
|
|
|
class ErgebnisseRepository extends Repository
|
|
{
|
|
public static function loadStatistik()
|
|
{
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_tournaments')->createQueryBuilder();
|
|
$res = $queryBuilder
|
|
->select('uid')
|
|
->from('tx_watten_tournaments')
|
|
->where(
|
|
$queryBuilder->expr()->eq('active', (int) 1)
|
|
)
|
|
->execute();
|
|
foreach ($res as $key => $value) {
|
|
return (int) $value['uid'];
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public static function getActiveTournament()
|
|
{
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_tournaments')->createQueryBuilder();
|
|
$res = $queryBuilder
|
|
->select('uid')
|
|
->from('tx_watten_tournaments')
|
|
->where(
|
|
$queryBuilder->expr()->eq('active', (int) 1)
|
|
)
|
|
->execute();
|
|
foreach ($res as $key => $value) {
|
|
return (int) $value['uid'];
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public function getLastEventId()
|
|
{
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_domain_model_events')->createQueryBuilder();
|
|
$res = $queryBuilder
|
|
->select('uid')
|
|
->from('tx_watten_domain_model_events')
|
|
->where(
|
|
$queryBuilder->expr()->eq('isactive', (int) 1)
|
|
)
|
|
->execute();
|
|
foreach ($res as $key => $value) {
|
|
return (int) $value['uid'];
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public function findTournaments($mitGesammt)
|
|
{
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_tournaments')->createQueryBuilder();
|
|
$res = $queryBuilder
|
|
->select('uid', 'tournament', 'active')
|
|
->from('tx_watten_tournaments')
|
|
->execute();
|
|
|
|
$tournaments = [];
|
|
foreach ($res as $key => $value) {
|
|
$tmp = new stdClass();
|
|
$tmp->id = (int) $value['uid'];
|
|
$tmp->name = $value['tournament'];
|
|
$tmp->active = $value['active'];
|
|
$tournaments[] = $tmp;
|
|
}
|
|
if ($mitGesammt == true) {
|
|
$tmp = new stdClass();
|
|
$tmp->id = -1;
|
|
$tmp->name = "Gesamt";
|
|
$tournaments[] = $tmp;
|
|
}
|
|
return $tournaments;
|
|
}
|
|
|
|
public function findByEventId(int $event_id)
|
|
{
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_domain_model_athleten')->createQueryBuilder();
|
|
$res = $queryBuilder
|
|
->select('uid', 'name')
|
|
->from('tx_watten_domain_model_athleten')
|
|
->execute();
|
|
$athleten = [];
|
|
foreach ($res as $key => $value) {
|
|
$athleten[$value['uid']] = $value['name'];
|
|
}
|
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_watten_domain_model_ergebnisse')->createQueryBuilder();
|
|
$ergebnisse = $queryBuilder
|
|
->select('uid', 'datum', 's1', 's2', 'v1', 'v2', 'bumid')
|
|
->from('tx_watten_domain_model_ergebnisse')
|
|
->where(
|
|
$queryBuilder->expr()->eq('event_id', (int) $event_id)
|
|
)
|
|
->execute();
|
|
|
|
$return = [];
|
|
foreach ($ergebnisse as $key => $value) {
|
|
$tmp = [];
|
|
$tmp['uid'] = $value['uid'];
|
|
$tmp['s1'] = $athleten[$value['s1']];
|
|
$tmp['s2'] = $athleten[$value['s2']];
|
|
$tmp['v1'] = $athleten[$value['v1']];
|
|
$tmp['v2'] = $athleten[$value['v2']];
|
|
$tmp['bumid'] = $value['bumid'];
|
|
$return[] = $tmp;
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
} |