Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\TimeManagement\Data;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use DateTimeInterface;
|
||||
use Xentral\Modules\TimeManagement\Exception\InvalidDateFormatException;
|
||||
|
||||
final class CalendarData
|
||||
{
|
||||
/** @var int $month */
|
||||
private $month = 0;
|
||||
|
||||
/** @var DateTimeInterface $date */
|
||||
private $date;
|
||||
|
||||
/** @var int $addressId */
|
||||
private $addressId = 0;
|
||||
|
||||
/** @var string $employeeName */
|
||||
private $employeeName = '';
|
||||
|
||||
/** @var string $type */
|
||||
private $type = '';
|
||||
|
||||
/** @var bool $isHalf */
|
||||
private $isHalf = false;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return CalendarData
|
||||
*
|
||||
* @throws InvalidDateFormatException
|
||||
*/
|
||||
public static function fromDbState(array $data): CalendarData
|
||||
{
|
||||
$calendarData = new CalendarData();
|
||||
$calendarData->month = (int)$data['month'];
|
||||
try {
|
||||
$calendarData->date = new DateTimeImmutable($data['date']);
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidDateFormatException('Could not convert date: ' . $data['date']);
|
||||
}
|
||||
|
||||
$calendarData->addressId = (int)$data['address_id'];
|
||||
$calendarData->employeeName = (string)$data['name'];
|
||||
$calendarData->type = (string)$data['type'];
|
||||
$calendarData->isHalf = (bool)$data['is_half'];
|
||||
|
||||
return $calendarData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMonth(): int
|
||||
{
|
||||
return $this->month;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface
|
||||
*/
|
||||
public function getDate(): DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAddressId(): int
|
||||
{
|
||||
return $this->addressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmployeeName(): string
|
||||
{
|
||||
return $this->employeeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHalf(): bool
|
||||
{
|
||||
return $this->isHalf;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\TimeManagement\Data;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
final class DayInfoData implements JsonSerializable
|
||||
{
|
||||
|
||||
/** @var string $type */
|
||||
private $type = '';
|
||||
|
||||
/** @var int $workMinutes */
|
||||
private $workMinutes = 0;
|
||||
|
||||
/** @var int $vacationMinutes */
|
||||
private $vacationMinutes = 0;
|
||||
|
||||
/** @var string $internalComment */
|
||||
private $internalComment = '';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return DayInfoData
|
||||
*/
|
||||
public static function fromDbState($data): DayInfoData
|
||||
{
|
||||
$dayInfoData = new DayInfoData();
|
||||
|
||||
if (isset($data['type'])) {
|
||||
$dayInfoData->type = (string)$data['type'];
|
||||
}
|
||||
if (isset($data['workminutes'])) {
|
||||
$dayInfoData->workMinutes = (int)$data['workminutes'];
|
||||
}
|
||||
if (isset($data['vacationminutes'])) {
|
||||
$dayInfoData->vacationMinutes = (int)$data['vacationminutes'];
|
||||
}
|
||||
if (isset($data['internal_comment'])) {
|
||||
$dayInfoData->internalComment = (string)$data['internal_comment'];
|
||||
}
|
||||
|
||||
return $dayInfoData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWorkMinutes(): int
|
||||
{
|
||||
return $this->workMinutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVacationMinutes(): int
|
||||
{
|
||||
return $this->vacationMinutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInternalComment(): string
|
||||
{
|
||||
return $this->internalComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'workminutes' => $this->workMinutes,
|
||||
'vacationminutes' => $this->vacationMinutes,
|
||||
'internal_comment' => $this->internalComment,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\TimeManagement\Data;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Exception;
|
||||
use Xentral\Modules\TimeManagement\Exception\InvalidDateFormatException;
|
||||
|
||||
final class HolidayData
|
||||
{
|
||||
/** @var string $name */
|
||||
private $name = 'Unknown';
|
||||
|
||||
/** @var DateTimeInterface $date */
|
||||
private $date;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @throws InvalidDateFormatException
|
||||
*
|
||||
* @return HolidayData
|
||||
*
|
||||
*/
|
||||
public static function fromDbState(array $data): HolidayData
|
||||
{
|
||||
$holidayData = new HolidayData();
|
||||
|
||||
$holidayData->name = $data['name'];
|
||||
try {
|
||||
$holidayData->date = new DateTimeImmutable($data['date']);
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidDateFormatException('Could not convert date: ' . $data['date']);
|
||||
}
|
||||
|
||||
return $holidayData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface
|
||||
*/
|
||||
public function getDate(): DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\TimeManagement\Data;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use Xentral\Modules\TimeManagement\Exception\InvalidDateFormatException;
|
||||
|
||||
final class RequestInfoData implements JsonSerializable
|
||||
{
|
||||
/** @var int $employeeId */
|
||||
private $employeeId = 0;
|
||||
|
||||
/** @var string $employeeNumber */
|
||||
private $employeeNumber = '';
|
||||
|
||||
/** @var string $employeeName */
|
||||
private $employeeName = '';
|
||||
|
||||
/** @var DateTimeInterface $minDate */
|
||||
private $minDate;
|
||||
|
||||
/** @var DateTimeInterface $maxDate */
|
||||
private $maxDate;
|
||||
|
||||
/** @var int $amount */
|
||||
private $amount = 0;
|
||||
|
||||
/** @var string $comment */
|
||||
private $comment = '';
|
||||
|
||||
/** @var string $type */
|
||||
private $type = '';
|
||||
|
||||
/** @var string $internalComment */
|
||||
private $internalComment = '';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getEmployeeId(): int
|
||||
{
|
||||
return $this->employeeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmployeeNumber(): string
|
||||
{
|
||||
return $this->employeeNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmployeeName(): string
|
||||
{
|
||||
return $this->employeeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface
|
||||
*/
|
||||
public function getMinDate(): DateTimeInterface
|
||||
{
|
||||
return $this->minDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface
|
||||
*/
|
||||
public function getMaxDate(): DateTimeInterface
|
||||
{
|
||||
return $this->maxDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInternalComment(): string
|
||||
{
|
||||
return $this->internalComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @throws InvalidDateFormatException
|
||||
*
|
||||
* @return RequestInfoData
|
||||
*/
|
||||
public static function fromDbState(array $data): RequestInfoData
|
||||
{
|
||||
$requestInfoData = new RequestInfoData();
|
||||
|
||||
$requestInfoData->employeeId = (int)$data['employee_id'];
|
||||
$requestInfoData->employeeNumber = (string)$data['employee_number'];
|
||||
$requestInfoData->employeeName = (string)$data['employee_name'];
|
||||
|
||||
try {
|
||||
$requestInfoData->minDate = new DateTimeImmutable($data['min_date']);
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidDateFormatException('Could not convert date: ' . $data['date']);
|
||||
}
|
||||
|
||||
try {
|
||||
$requestInfoData->maxDate = new DateTimeImmutable($data['max_date']);
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidDateFormatException('Could not convert date: ' . $data['date']);
|
||||
}
|
||||
|
||||
$requestInfoData->amount = (int)$data['amount'];
|
||||
$requestInfoData->comment = (string)$data['comment'];
|
||||
$requestInfoData->type = (string)$data['type'];
|
||||
$requestInfoData->internalComment = (string)$data['internal_comment'];
|
||||
|
||||
return $requestInfoData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'employee_id' => $this->employeeId,
|
||||
'employee_number' => $this->employeeNumber,
|
||||
'employee_name' => $this->employeeName,
|
||||
'min_date' => empty($this->minDate) ? '0000-00-00' : $this->minDate->format('Y-m-d'),
|
||||
'max_date' => empty($this->maxDate) ? '0000-00-00' : $this->maxDate->format('Y-m-d'),
|
||||
'amount' => $this->amount,
|
||||
'comment' => $this->comment,
|
||||
'type' => $this->type,
|
||||
'internal_comment' => $this->internalComment,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\TimeManagement\Data;
|
||||
|
||||
final class WorkDayData
|
||||
{
|
||||
|
||||
/** @var bool $isMondayWorkDay */
|
||||
private $isMondayWorkDay = false;
|
||||
|
||||
/** @var bool $isTuesdayWorkDay */
|
||||
private $isTuesdayWorkDay = false;
|
||||
|
||||
/** @var bool $isWednesdayWorkDay */
|
||||
private $isWednesdayWorkDay = false;
|
||||
|
||||
/** @var bool $isThursdayWorkDay */
|
||||
private $isThursdayWorkDay = false;
|
||||
|
||||
/** @var bool $isFridayWorkDay */
|
||||
private $isFridayWorkDay = false;
|
||||
|
||||
/** @var bool $isSaturdayWorkDay */
|
||||
private $isSaturdayWorkDay = false;
|
||||
|
||||
/** @var bool $isSundayWorkDay */
|
||||
private $isSundayWorkDay = false;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function fromDbState(array $data): WorkDayData
|
||||
{
|
||||
$workDayData = new WorkDayData();
|
||||
|
||||
$workDayData->isMondayWorkDay = !empty($data['is_monday_workday']);
|
||||
$workDayData->isTuesdayWorkDay = !empty($data['is_tuesday_workday']);
|
||||
$workDayData->isWednesdayWorkDay = !empty($data['is_wednesday_workday']);
|
||||
$workDayData->isThursdayWorkDay = !empty($data['is_thursday_workday']);
|
||||
$workDayData->isFridayWorkDay = !empty($data['is_friday_workday']);
|
||||
$workDayData->isSaturdayWorkDay = !empty($data['is_saturday_workday']);
|
||||
$workDayData->isSundayWorkDay = !empty($data['is_sunday_workday']);
|
||||
|
||||
return $workDayData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isMondayWorkDay(): bool
|
||||
{
|
||||
return $this->isMondayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTuesdayWorkDay(): bool
|
||||
{
|
||||
return $this->isTuesdayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWednesdayWorkDay(): bool
|
||||
{
|
||||
return $this->isWednesdayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isThursdayWorkDay(): bool
|
||||
{
|
||||
return $this->isThursdayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isFridayWorkDay(): bool
|
||||
{
|
||||
return $this->isFridayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSaturdayWorkDay(): bool
|
||||
{
|
||||
return $this->isSaturdayWorkDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSundayWorkDay(): bool
|
||||
{
|
||||
return $this->isSundayWorkDay;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user