mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Feature: Allow to filter periods to reassign by postal code
This commit is contained in:
@@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\Type\PickPostalCodeType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
@@ -92,12 +94,14 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
$userFrom = $form['user']->getData();
|
||||
$postalCodes = $form['postal_code']->getData() instanceof PostalCode ? [$form['postal_code']->getData()] : [];
|
||||
|
||||
$total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom);
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$periods = $this->accompanyingPeriodACLAwareRepository
|
||||
->findByUserOpenedAccompanyingPeriod(
|
||||
->findByUserAndPostalCodesOpenedAccompanyingPeriod(
|
||||
$userFrom,
|
||||
$postalCodes,
|
||||
['openingDate' => 'ASC'],
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
@@ -148,7 +152,9 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
$data = [
|
||||
'user' => null,
|
||||
'postal_code' => null,
|
||||
];
|
||||
|
||||
$builder = $this->formFactory->createBuilder(FormType::class, $data, [
|
||||
'method' => 'get', 'csrf_protection' => false, ]);
|
||||
|
||||
@@ -158,12 +164,17 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
'label' => 'reassign.Current user',
|
||||
'required' => false,
|
||||
'help' => 'reassign.Choose a user and click on "Filter" to apply',
|
||||
])
|
||||
->add('postal_code', PickPostalCodeType::class, [
|
||||
'label' => 'reassign.Filter by postal code',
|
||||
'required' => false,
|
||||
'help' => 'reassign.Filter course which are located inside a postal code',
|
||||
]);
|
||||
|
||||
return $builder->getForm();
|
||||
}
|
||||
|
||||
private function buildReassignForm(array $periodIds, ?User $userFrom): FormInterface
|
||||
private function buildReassignForm(array $periodIds, ?User $userFrom = null): FormInterface
|
||||
{
|
||||
$defaultData = [
|
||||
'userFrom' => $userFrom,
|
||||
|
Reference in New Issue
Block a user