feat : ajout des suspensions et des jours de présence
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled

This commit is contained in:
2026-03-12 16:46:06 +01:00
parent e6819bc68a
commit 38f09914cb
25 changed files with 2969 additions and 21 deletions

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\ContractSuspension;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ContractSuspension>
*/
class ContractSuspensionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ContractSuspension::class);
}
}

View File

@@ -138,6 +138,48 @@ final class WorkHourRepository extends ServiceEntityRepository implements WorkHo
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @return array<string, float> YYYY-MM => presence day count (0.5 for half-days)
*/
public function countPresenceDaysByMonth(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): array
{
$sql = <<<'SQL'
SELECT TO_CHAR(work_date, 'YYYY-MM') AS month,
SUM(
CASE
WHEN (morning_from IS NOT NULL OR is_present_morning = true)
AND (afternoon_from IS NOT NULL OR is_present_afternoon = true)
THEN 1.0
WHEN (morning_from IS NOT NULL OR is_present_morning = true)
OR (afternoon_from IS NOT NULL OR is_present_afternoon = true)
THEN 0.5
ELSE 0
END
) AS cnt
FROM work_hours
WHERE employee_id = :employee
AND work_date >= :from
AND work_date <= :to
AND (morning_from IS NOT NULL OR is_present_morning = true
OR afternoon_from IS NOT NULL OR is_present_afternoon = true)
GROUP BY month
SQL;
$conn = $this->getEntityManager()->getConnection();
$rows = $conn->fetchAllAssociative($sql, [
'employee' => $employee->getId(),
'from' => $from->format('Y-m-d'),
'to' => $to->format('Y-m-d'),
]);
$result = [];
foreach ($rows as $row) {
$result[(string) $row['month']] = (float) $row['cnt'];
}
return $result;
}
public function hasPendingSiteValidationForSiteAndDate(int $siteId, DateTimeInterface $date): bool
{
$workDate = DateTimeImmutable::createFromInterface($date);