mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
residential address at thirdparty filter : not done!
This commit is contained in:
parent
9a2af662c0
commit
a3cae28613
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||||
|
use DateTime;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('thirdparty_type', EntityType::class, [
|
||||||
|
'class' => ThirdPartyCategory::class,
|
||||||
|
'choice_label' => function (ThirdPartyCategory $tpc) {
|
||||||
|
return $this->translatableStringHelper->localize($tpc->getName());
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('date_calc', ChillDateType::class, [
|
||||||
|
'label' => 'Date during which residential address was valid',
|
||||||
|
'data' => new DateTime('now'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Query is not finished... not clear what 'catégorie' corresponds with. Cannot get values to appear in table thirdparty_category
|
||||||
|
$qb->resetDQLPart('from');
|
||||||
|
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra');
|
||||||
|
|
||||||
|
$qb->join('ra.person', 'person');
|
||||||
|
$qb->join('person.center', 'center');
|
||||||
|
$qb->join('ra.hostThirdparty', 'thirdparty');
|
||||||
|
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->isNotNull('ra.hostThirdparty'),
|
||||||
|
// $qb->expr()->in('thirdparty.categories')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($where instanceof Expr\Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return Declarations::PERSON_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return ['Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%';
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user