-
- {% if acp.requestorPerson == person %}
-
+ {% if acp.step == 'DRAFT' %}
+
+ {{ 'course.draft'|trans }}
+
+ {% endif %}
+ {% if acp.requestorPerson == person %}
+
+
{{ 'Requestor'|trans({'gender': person.gender}) }}
-
- {% endif %}
+
+
+ {% endif %}
+
+
{% if app != null %}
{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}
{% endif %}
@@ -94,6 +107,11 @@
{% endif %}
+
+ {{ 'File number'|trans }} {{ acp.id }}
+
+
+
@@ -101,17 +119,76 @@
{{ issue|chill_entity_render_box }}
{% endfor %}
-
+ {% if acp.currentParticipations|length > 1 %}
+
+
+
+ {{ 'Participants'|trans }}
+
+
+
+ {% set participating = false %}
+ {% for part in acp.currentParticipations %}
+ {% if part.person.id != person.id %}
+ {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
+ targetEntity: { name: 'person', id: part.person.id },
+ action: 'show',
+ displayBadge: true,
+ buttonText: part.person|chill_entity_render_string
+ } %}
+ {% else %}
+ {% set participating = true %}
+ {% endif %}
+ {% endfor %}
+ {% if participating %}
+ {{ 'person.and_himself'|trans({'gender': person.gender}) }}
+ {% endif %}
+
+
+ {% endif %}
+ {% if (acp.requestorPerson is not null and acp.requestorPerson.id != person.id) or acp.requestorThirdParty is not null %}
+
+
+
+ {% if acp.requestorPerson is not null %}
+ {{ 'Requestor'|trans({'gender': acp.requestorPerson.gender}) }}
+ {% else %}
+ {{ 'Requestor'|trans({'gender': 'other'})}}
+ {% endif %}
+
+
+
+ {% if acp.requestorThirdParty is not null %}
+ {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
+ targetEntity: { name: 'thirdparty', id: acp.requestorThirdParty.id },
+ action: 'show',
+ displayBadge: true,
+ buttonText: acp.requestorThirdParty|chill_entity_render_string
+ } %}
+ {% else %}
+ {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
+ targetEntity: { name: 'person', id: acp.requestorPerson.id },
+ action: 'show',
+ displayBadge: true,
+ buttonText: acp.requestorPerson|chill_entity_render_string
+ } %}
+ {% endif %}
+
+
+ {% endif %}
{% endfor %}
diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
index d83749147..f4a6c19bf 100644
--- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
@@ -5,11 +5,15 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Search;
use Chill\MainBundle\Search\AbstractSearch;
+use Chill\MainBundle\Search\Utils\ExtractDateFromPattern;
+use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
+use Chill\PersonBundle\Form\Type\GenderType;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Search\SearchInterface;
use Chill\MainBundle\Search\ParsingException;
use Chill\MainBundle\Pagination\PaginatorFactory;
+use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -19,23 +23,29 @@ use Symfony\Component\Templating\EngineInterface;
class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterface
{
- protected EngineInterface $templating;
- protected PaginatorFactory $paginatorFactory;
- protected PersonACLAwareRepositoryInterface $personACLAwareRepository;
+ private EngineInterface $templating;
+ private PaginatorFactory $paginatorFactory;
+ private PersonACLAwareRepositoryInterface $personACLAwareRepository;
+ private ExtractDateFromPattern $extractDateFromPattern;
+ private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern;
public const NAME = "person_regular";
private const POSSIBLE_KEYS = [
'_default', 'firstname', 'lastname', 'birthdate', 'birthdate-before',
- 'birthdate-after', 'gender', 'nationality'
+ 'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city'
];
public function __construct(
EngineInterface $templating,
+ ExtractDateFromPattern $extractDateFromPattern,
+ ExtractPhonenumberFromPattern $extractPhonenumberFromPattern,
PaginatorFactory $paginatorFactory,
PersonACLAwareRepositoryInterface $personACLAwareRepository
) {
$this->templating = $templating;
+ $this->extractDateFromPattern = $extractDateFromPattern;
+ $this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern;
$this->paginatorFactory = $paginatorFactory;
$this->personACLAwareRepository = $personACLAwareRepository;
}
@@ -69,6 +79,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
*/
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array(), $format = 'html')
{
+ $terms = $this->findAdditionnalInDefault($terms);
$total = $this->count($terms);
$paginator = $this->paginatorFactory->create($total);
@@ -99,6 +110,26 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
}
}
+ private function findAdditionnalInDefault(array $terms): array
+ {
+ // chaining some extractor
+ $datesResults = $this->extractDateFromPattern->extractDates($terms['_default']);
+ $phoneResults = $this->extractPhonenumberFromPattern->extractPhonenumber($datesResults->getFilteredSubject());
+ $terms['_default'] = $phoneResults->getFilteredSubject();
+
+ if ($datesResults->hasResult() && (!\array_key_exists('birthdate', $terms)
+ || NULL !== $terms['birthdate'])) {
+ $terms['birthdate'] = $datesResults->getFound()[0]->format('Y-m-d');
+ }
+
+ if ($phoneResults->hasResult() && (!\array_key_exists('phonenumber', $terms)
+ || NULL !== $terms['phonenumber'])) {
+ $terms['phonenumber'] = $phoneResults->getFound()[0];
+ }
+
+ return $terms;
+ }
+
/**
* @return Person[]
*/
@@ -113,6 +144,8 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'birthdate-after' => $birthdateAfter,
'gender' => $gender,
'nationality' => $countryCode,
+ 'phonenumber' => $phonenumber,
+ 'city' => $city,
] = $terms + \array_fill_keys(self::POSSIBLE_KEYS, null);
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
@@ -139,6 +172,8 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
$birthdateAfter,
$gender,
$countryCode,
+ $phonenumber,
+ $city
);
}
@@ -153,7 +188,8 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'birthdate-after' => $birthdateAfter,
'gender' => $gender,
'nationality' => $countryCode,
-
+ 'phonenumber' => $phonenumber,
+ 'city' => $city,
] = $terms + \array_fill_keys(self::POSSIBLE_KEYS, null);
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
@@ -177,6 +213,8 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
$birthdateAfter,
$gender,
$countryCode,
+ $phonenumber,
+ $city
);
}
@@ -207,13 +245,19 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'label' => 'Birthdate before',
'required' => false
])
- ->add('gender', ChoiceType::class, [
- 'choices' => [
- 'Man' => Person::MALE_GENDER,
- 'Woman' => Person::FEMALE_GENDER
- ],
+ ->add('phonenumber', TelType::class, [
+ 'required' => false,
+ 'label' => 'Part of the phonenumber'
+ ])
+ ->add('gender', GenderType::class, [
'label' => 'Gender',
- 'required' => false
+ 'required' => false,
+ 'expanded' => false,
+ 'placeholder' => 'All genders'
+ ])
+ ->add('city', TextType::class, [
+ 'required' => false,
+ 'label' => 'City or postal code'
])
;
}
@@ -224,7 +268,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
$string .= empty($data['_default']) ? '' : $data['_default'].' ';
- foreach(['firstname', 'lastname', 'gender'] as $key) {
+ foreach(['firstname', 'lastname', 'gender', 'phonenumber', 'city'] as $key) {
$string .= empty($data[$key]) ? '' : $key.':'.
// add quote if contains spaces
(strpos($data[$key], ' ') !== false ? '"'.$data[$key].'"': $data[$key])
@@ -246,7 +290,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
{
$data = [];
- foreach(['firstname', 'lastname', 'gender', '_default'] as $key) {
+ foreach(['firstname', 'lastname', 'gender', '_default', 'phonenumber', 'city'] as $key) {
$data[$key] = $terms[$key] ?? null;
}
@@ -275,6 +319,4 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
{
return self::NAME;
}
-
-
}
diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearchByPhone.php b/src/Bundle/ChillPersonBundle/Search/PersonSearchByPhone.php
deleted file mode 100644
index 08152144b..000000000
--- a/src/Bundle/ChillPersonBundle/Search/PersonSearchByPhone.php
+++ /dev/null
@@ -1,133 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see