Files
PHP-App-Timekeeping/api/src/Repositories/WorkingHoursYearlyViewRepository.php
T

41 lines
1.1 KiB
PHP

<?php
namespace TorstenHettstedt\TimekeepingApi\Repositories;
use DateTime;
use DateTimeInterface;
use Exception;
use PDO;
use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursYearlyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const string SQL_SELECT = <<<SQL
select
"Jahr" as "period",
"Gesamtarbeitszeit" as "totalHours",
"Arbeitstage" as "workingDays",
"Home-Office-Tage" as "homeOfficeDays",
"Überstunden" as "overtime"
from "Arbeitszeiten - Jahr"
SQL;
protected const string SQL_WHERE = ' where "Jahr" = ?';
public function __construct(PDO $database)
{
parent::__construct($database);
$this->periodDesignation = PeriodDesignationEnum::YEARLY;
}
/**
* @param string $period
*
* @return DateTimeInterface
* @throws Exception
*/
protected function buildDateFromPeriod(string $period): DateTimeInterface
{
return new DateTime($period . '-01-01');
}
}