<?php

namespace AppBundle\Entity\Person\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Description of BankAccountRepository
 *
 */
class PersonActivityRepository extends EntityRepository
{
    public function getArchivedPersonActivity($enDate, $organizationId)
    {
        $filter = $this->_em->getFilters()->enable('activity_year');
        $filter->setParameter('disabledFilter', 1);
        $qb = $this->createQueryBuilder('person_activity');

        $qb
            ->innerJoin('person_activity.access', 'access')
            ->innerJoin('access.organization', 'organization')
            ->andWhere('person_activity.endDate = :enDate')
            ->andWhere('organization.id = :id')
            ->setParameter('id', $organizationId)
            ->setParameter('enDate', $enDate)
        ;

        $filter->setParameter('disabledFilter', 0);
        return $qb->getQuery()->getResult();
    }
}

