2020-04-24 18:08:09 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-04-24 18:08:09 +02:00
|
|
|
namespace Engelsystem\Controllers;
|
|
|
|
|
2022-12-23 18:26:16 +01:00
|
|
|
use Carbon\CarbonImmutable;
|
2021-04-10 17:02:34 +02:00
|
|
|
use Engelsystem\Config\Config;
|
2022-06-07 22:59:49 +02:00
|
|
|
use Engelsystem\Helpers\BarChart;
|
2020-04-24 18:08:09 +02:00
|
|
|
use Engelsystem\Http\Response;
|
2022-06-06 13:00:37 +02:00
|
|
|
use Engelsystem\Models\User\PersonalData;
|
2020-04-24 18:08:09 +02:00
|
|
|
use Engelsystem\Models\User\State;
|
|
|
|
use Engelsystem\Models\User\User;
|
|
|
|
|
|
|
|
class DesignController extends BaseController
|
|
|
|
{
|
2022-12-15 19:57:02 +01:00
|
|
|
public function __construct(protected Response $response, protected Config $config)
|
2020-04-24 18:08:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the design overview page
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function index(): Response
|
2020-04-24 18:08:09 +02:00
|
|
|
{
|
|
|
|
$demoUser = (new User())->forceFill([
|
2021-04-10 17:02:34 +02:00
|
|
|
'id' => 42,
|
2020-04-24 18:08:09 +02:00
|
|
|
'name' => 'test',
|
|
|
|
]);
|
|
|
|
$demoUser->__set('state', (new State())->forceFill([
|
|
|
|
'user_id' => 42,
|
|
|
|
'arrived' => true,
|
|
|
|
]));
|
|
|
|
$demoUser2 = (new User())->forceFill([
|
2021-04-10 17:02:34 +02:00
|
|
|
'id' => 1337,
|
2020-04-24 18:08:09 +02:00
|
|
|
'name' => 'test2',
|
|
|
|
]);
|
|
|
|
$demoUser2->__set('state', (new State())->forceFill([
|
|
|
|
'user_id' => 1337,
|
|
|
|
'arrived' => false,
|
|
|
|
]));
|
2022-06-06 13:00:37 +02:00
|
|
|
$demoUser2->__set('personalData', (new PersonalData())->forceFill([
|
|
|
|
'pronoun' => 'it/its',
|
|
|
|
]));
|
2020-04-24 18:08:09 +02:00
|
|
|
|
2022-12-23 18:26:16 +01:00
|
|
|
$selectOptions = [];
|
|
|
|
|
|
|
|
for ($i = 1; $i <= 50; $i++) {
|
|
|
|
$selectOptions['option_' . $i] = 'Option ' . $i;
|
|
|
|
}
|
|
|
|
|
|
|
|
$dateSelectOptions = [];
|
|
|
|
$date = CarbonImmutable::now();
|
|
|
|
|
|
|
|
for ($i = 1; $i <= 600; $i++) {
|
|
|
|
$formattedDate = $date->format("Y-m-d");
|
|
|
|
$dateSelectOptions[$formattedDate] = $formattedDate;
|
|
|
|
$date = $date->addDay();
|
|
|
|
}
|
|
|
|
|
2021-04-29 21:58:20 +02:00
|
|
|
$themes = $this->config->get('themes');
|
2022-12-21 14:18:21 +01:00
|
|
|
$date = new \DateTimeImmutable();
|
2021-04-10 17:02:34 +02:00
|
|
|
$data = [
|
2022-12-23 18:26:16 +01:00
|
|
|
'demo_user' => $demoUser,
|
|
|
|
'demo_user_2' => $demoUser2,
|
|
|
|
'themes' => $themes,
|
|
|
|
'bar_chart' => BarChart::render(...BarChart::generateChartDemoData(23)),
|
2022-10-18 21:16:05 +02:00
|
|
|
|
2022-12-23 18:26:16 +01:00
|
|
|
'timestamp30m' => $date->add(new \DateInterval('PT30M')),
|
|
|
|
'timestamp59m' => $date->add(new \DateInterval('PT59M')),
|
|
|
|
'timestamp1h' => $date->add(new \DateInterval('PT1H')),
|
|
|
|
'timestamp1h30m' => $date->add(new \DateInterval('PT1H30M')),
|
|
|
|
'timestamp1h31m' => $date->add(new \DateInterval('PT1H31M')),
|
|
|
|
'timestamp2h' => $date->add(new \DateInterval('PT2H')),
|
|
|
|
'timestamp2d' => $date->add(new \DateInterval('P2D')),
|
|
|
|
'timestamp3m' => $date->add(new \DateInterval('P3M')),
|
|
|
|
'timestamp22y' => $date->add(new \DateInterval('P22Y')),
|
|
|
|
'timestamp30s' => $date->add(new \DateInterval('PT30S')),
|
2022-12-21 14:18:21 +01:00
|
|
|
|
2022-12-23 18:26:16 +01:00
|
|
|
'timestamp30mago' => $date->sub(new \DateInterval('PT30M')),
|
|
|
|
'timestamp45mago' => $date->sub(new \DateInterval('PT45M')),
|
|
|
|
'selectOptions' => $selectOptions,
|
|
|
|
'dateSelectOptions' => $dateSelectOptions,
|
2021-04-10 17:02:34 +02:00
|
|
|
];
|
|
|
|
|
2020-04-24 18:08:09 +02:00
|
|
|
return $this->response->withView(
|
|
|
|
'pages/design',
|
2021-04-10 17:02:34 +02:00
|
|
|
$data
|
2020-04-24 18:08:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|