3 Commits
Author SHA1 Message Date
TorstenHettstedt 7b5ce23342 Überarbeiter das 'deploy'-Kommando 2025-06-16 15:48:03 +02:00
TorstenHettstedt a3b123f466 Korrigiere UI-Hinweise 2025-06-16 15:47:02 +02:00
TorstenHettstedt d52a9d77ab Korrigiere PHP-Hinweise 2025-06-16 15:36:27 +02:00
9 changed files with 50 additions and 47 deletions
+7 -16
View File
@@ -10,24 +10,14 @@ use JetBrains\PhpStorm\ArrayShape;
class WorkingHoursView implements ModelInterface
{
protected DateTimeInterface $period;
protected PeriodDesignationEnum $periodDesignation;
protected int $workingDays;
protected DateInterval $totalHours;
protected DateInterval $overtime;
public function __construct(
DateTimeInterface $period,
PeriodDesignationEnum $periodDesignation,
int $workingDays,
DateInterval $totalHours,
DateInterval $overtime
protected DateTimeInterface $period,
protected PeriodDesignationEnum $periodDesignation,
protected int $workingDays,
protected DateInterval $totalHours,
protected DateInterval $overtime
) {
$this->period = $period;
$this->periodDesignation = $periodDesignation;
$this->workingDays = $workingDays;
$this->totalHours = $totalHours;
$this->overtime = $overtime;
}
public function getPeriod(): DateTimeInterface
@@ -66,7 +56,8 @@ class WorkingHoursView implements ModelInterface
'totalHours' => "string",
'workingDays' => "int",
'overtime' => "string"
])] public function jsonSerialize(): array
])]
public function jsonSerialize(): array
{
$formatOvertime = (($this->getOvertime()->invert === 1) ? '-' : '') . '%H:%I:%S';
return [
@@ -12,7 +12,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursMonthlyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Monat" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -20,7 +20,7 @@ class WorkingHoursMonthlyViewRepository extends AbstractWorkingHoursViewReposito
"Überstunden" as "overtime"
from "Arbeitszeiten - Monat"
SQL;
protected const SQL_WHERE = ' where "Monat" = ?';
protected const string SQL_WHERE = ' where "Monat" = ?';
public function __construct(PDO $database)
{
@@ -20,6 +20,13 @@ use TorstenHettstedt\TimekeepingApi\Models\WorkingHours;
*/
class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWriterInterface
{
protected const string SQL_SELECT = <<<'SQL'
select
"Datum" as "workingDay",
"Arbeitszeit" as "workingTime"
from public."Arbeitszeiten"
SQL;
public function __construct(protected PDO $database)
{
@@ -88,7 +95,7 @@ class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWri
protected function buildFindFilteredStatement(?string $start, ?string $end): ?PDOStatement
{
$query = 'select "Datum" as "workingDay", "Arbeitszeit" as "workingTime" from public."Arbeitszeiten" ';
$query = static::SQL_SELECT . ' ';
$query .= $this->buildFilterString($start, $end);
$query .= 'order by "Datum"';
$stmt = $this->database->prepare($query);
@@ -113,9 +120,7 @@ class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWri
*/
public function findByKey(mixed $primary_key): WorkingHours
{
$stmt = $this->database->prepare(
'select "Datum" as "workingDay", "Arbeitszeit" as "workingTime" from public."Arbeitszeiten" where "Datum" = ?'
);
$stmt = $this->database->prepare(static::SQL_SELECT . ' where "Datum" = ?');
$stmt->bindParam(1, $primary_key);
$stmt->execute();
$row = $stmt->fetch();
@@ -11,7 +11,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursWeeklyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Woche" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -19,7 +19,7 @@ class WorkingHoursWeeklyViewRepository extends AbstractWorkingHoursViewRepositor
"Überstunden" as "overtime"
from "Arbeitszeiten - Woche"
SQL;
protected const SQL_WHERE = ' where "Woche" = ?';
protected const string SQL_WHERE = ' where "Woche" = ?';
public function __construct(PDO $database)
{
@@ -11,7 +11,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursYearlyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Jahr" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -19,7 +19,7 @@ class WorkingHoursYearlyViewRepository extends AbstractWorkingHoursViewRepositor
"Überstunden" as "overtime"
from "Arbeitszeiten - Jahr"
SQL;
protected const SQL_WHERE = ' where "Jahr" = ?';
protected const string SQL_WHERE = ' where "Jahr" = ?';
public function __construct(PDO $database)
{
+1 -1
View File
@@ -3,6 +3,6 @@ modules:
enabled:
- \Helper\Api
- REST:
url: http://localhost:8091/
url: http://api:80/
depends: PhpBrowser
part: Json
@@ -4,14 +4,12 @@ namespace TorstenHettstedt\TimekeepingApi\Tests\Unit\Controller;
use Codeception\Attribute\DataProvider;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Slim\Exception\HttpBadRequestException;
use Slim\Exception\HttpNotFoundException;
use Slim\Psr7\Request;
use Slim\Psr7\Response;
use TorstenHettstedt\TimekeepingApi\Controller\HttpConflictRequestException;
use TorstenHettstedt\TimekeepingApi\Controller\NotDatabasesException;
use TorstenHettstedt\TimekeepingApi\Controller\WorkingHoursController;
@@ -25,10 +23,6 @@ class WorkingHoursControllerTest extends AbstractControllerTest
public const string NEW_DATE = '2020-04-01';
public const string NEW_INTERVAL = '07:59:00';
protected ContainerInterface $container;
protected Request $request;
protected Response|MockObject $response;
/**
* @throws Exception
* @throws \PHPUnit\Framework\MockObject\Exception
+11 -4
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
create_css_files() {
cd ui/public || exit 2
lessc --source-map less/print.less print.css
lessc --source-map less/global.less global.css
cd ui || exit 2
lessc --source-map less/print.less static/print.css
lessc --source-map less/global.less static/global.css
cd ../..
}
@@ -27,6 +27,13 @@ build_ui() {
cd ..
}
codeception_install() {
pwd
cd api/ || exit 2
test -e ./tests/unit.suite.yml || ./vendor/bin/codecept build
cd ..
}
test_unit() {
pwd
cd api/ || exit 2
@@ -44,4 +51,4 @@ composer_run() {
docker compose up -d
}
create_css_files && install_ui_dependence && install_api_dependence && build_ui && test_unit && composer_run && test_api
create_css_files && install_ui_dependence && install_api_dependence && build_ui && codeception_install && test_unit && composer_run && test_api
+16 -10
View File
@@ -19,7 +19,7 @@ const getMonday = actualDayObject => {
}
/** @type {String[]} **/
const day_list = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sontag']
const weekday_list = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sontag']
/** @param {Date} actualDayObject **/
const getDateString = actualDayObject => {
@@ -49,17 +49,23 @@ export const actions = {
const form_data = await request.formData();
// @ts-ignore
let actualDayObject = getMonday(new Date(form_data.get('week')))
day_list.forEach(day => {
if (form_data.get(day) !== '00:00:00' && form_data.get(day) !== '00:00') {
const working_day = getDateString(actualDayObject)
const body_data = {
workingDay: working_day,
workingTime: form_data.get(day),
}
WorkingHoursRepository.addOrUpdate(env.API_URL, working_day, body_data);
}
/** @type {Object<String,String>} **/
let day_list = {}
weekday_list.forEach(day => {
day_list[day] = getDateString(actualDayObject)
actualDayObject.setDate(actualDayObject.getDate() + 1)
})
for (const pair of form_data.entries()) {
const working_day = day_list[pair[0]] ?? null
if (working_day === null) {
continue
}
const body_data = {
workingDay: working_day,
workingTime: pair[1],
}
await WorkingHoursRepository.addOrUpdate(env.API_URL, working_day, body_data);
}
},
'import-csv': async ({ request }) => {
const form_data = await request.formData();