File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Repository/LecturerAgreementRepository.php
<?php
namespace App\Repository;
use App\Entity\LecturerAgreement;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
*
* @method LecturerAgreement|null find($id, $lockMode = null, $lockVersion = null)
* @method LecturerAgreement|null findOneBy(array $criteria, array $orderBy = null)
// * @method LecturerAgreement[] findAll()
* @method LecturerAgreement[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class LecturerAgreementRepository extends EntityRepository
{
public function findAll(): array
{
return $this->getEntityManager()
->createQuery("
SELECT la, l, d, au
FROM App:LecturerAgreement la
JOIN la.lecturerPosition lp
JOIN la.lecturer l
JOIN l.department d
JOIN d.academicUnit au
WHERE lp.isForPlan = 1
ORDER BY l.name ASC
")
->getResult()
;
}
public function findAllFilter(): array
{
return $this->getEntityManager()
->createQuery("
SELECT la, l, d, au
FROM App:LecturerAgreement la
JOIN la.lecturerPosition lp
JOIN la.lecturer l
JOIN l.department d
JOIN d.academicUnit au
WHERE lp.isForPlan = 1
AND la.contractTo > DATE_ADD(la.contractFrom, 1, 'YEAR')
ORDER BY l.name ASC
")
->getResult()
;
}
public function findAllIndexedById(): array
{
$items = $this->findBy([]);
$indexed = [];
foreach ($items as $item) {
$indexed[$item->getId()] = $item;
}
return $indexed;
}
public function findAllForReport(): array
{
return $this->getEntityManager()
->createQuery("
SELECT la, l, d, au
FROM App:LecturerAgreement la
JOIN la.lecturerPosition lp
JOIN la.lecturer l
JOIN l.department d
JOIN d.academicUnit au
ORDER BY l.name ASC
")
->getResult()
;
}
public function deleteAll()
{
return $this->getEntityManager()
->createQuery(
"DELETE App:LecturerAgreement l"
)
->execute();
}
}