refs #724. New field . RemotePc
parent
feb239f3de
commit
ca23d41241
|
@ -12,6 +12,9 @@ resources:
|
|||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\TraceProvider
|
||||
|
||||
order:
|
||||
createdAt: DESC
|
||||
|
||||
properties:
|
||||
App\Entity\Trace:
|
||||
id:
|
||||
|
|
|
@ -127,6 +127,18 @@ services:
|
|||
arguments: [ { 'synchronized': ~ } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.remote_calendar.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
$properties: { 'id': ~, 'name': ~ }
|
||||
$orderParameterName: 'order'
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.remote_calendar.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.user.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241002062742 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE organizational_unit ADD remote_pc TINYINT(1) NOT NULL, ADD reserved TINYINT(1) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE organizational_unit DROP remote_pc, DROP reserved');
|
||||
}
|
||||
}
|
|
@ -84,20 +84,33 @@ class RemoteCalendar extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function isRemoteAvailable(): bool
|
||||
public function isAvailable(): bool
|
||||
{
|
||||
$now = new \DateTime();
|
||||
|
||||
foreach ($this->getRules() as $rule) {
|
||||
$dayOfWeek = (int) $now->format('w');
|
||||
$adjustedDayOfWeek = ($dayOfWeek + 6) % 7;
|
||||
if (!in_array($adjustedDayOfWeek, $rule->getBusyWeekdays())) {
|
||||
return false;
|
||||
if ($rule->isRemoteAvailable()) {
|
||||
$fromDate = $rule->getAvailableFromDate();
|
||||
$toDate = $rule->getAvailableToDate();
|
||||
|
||||
if ($fromDate && $toDate && $fromDate <= $now && $now <= $toDate) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$dayOfWeek = (int) $now->format('w');
|
||||
$adjustedDayOfWeek = ($dayOfWeek + 6) % 7;
|
||||
|
||||
if (!in_array($adjustedDayOfWeek, $rule->getBusyWeekdays())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$currentTime = $now->format('H:i');
|
||||
if (!($currentTime >= $rule->getBusyFromHour() && $currentTime <= $rule->getBusyToHour())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$currentTime = $now->format('H:i');
|
||||
|
||||
return ($currentTime >= $rule->getBusyFromHour() && $currentTime <= $rule->getBusyToHour());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue