mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\BudgetBundle\Repository;
|
|
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use DateTime;
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
/**
|
|
* ResourceRepository.
|
|
*
|
|
* This class was generated by the Doctrine ORM. Add your own custom
|
|
* repository methods below.
|
|
*/
|
|
class ResourceRepository extends EntityRepository
|
|
{
|
|
public function findByEntityAndDate($entity, DateTime $date, $sort = null)
|
|
{
|
|
$qb = $this->createQueryBuilder('c');
|
|
|
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
|
|
|
$qb->where("c.{$entityStr} = :{$entityStr}")
|
|
// TODO: in controller, the budget and charges asked are also for future and actual
|
|
//->andWhere('c.startDate < :date')
|
|
// TODO: there is a misconception here, the end date must be lower or null. startDate are never null
|
|
//->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
|
;
|
|
|
|
if (null !== $sort) {
|
|
$qb->orderBy($sort);
|
|
}
|
|
|
|
$qb->setParameters([
|
|
$entityStr => $entity,
|
|
//'date' => $date,
|
|
]);
|
|
|
|
return $qb->getQuery()->getResult();
|
|
}
|
|
}
|