mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge remote-tracking branch 'origin/master' into user_absences
This commit is contained in:
@@ -11,11 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
@@ -192,14 +194,20 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
|
||||
private function preparePersonIds()
|
||||
{
|
||||
$centers = LoadCenters::$centers;
|
||||
|
||||
// @TODO: Remove this and make this service stateless
|
||||
$this->personIds = $this->em
|
||||
->createQuery(
|
||||
'SELECT p.id FROM ' . Person::class . ' p ' .
|
||||
'JOIN p.center c ' .
|
||||
'WHERE c.name = :center '
|
||||
'WHERE EXISTS( ' .
|
||||
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch ' .
|
||||
'JOIN pch.center c ' .
|
||||
'WHERE pch.person = p.id ' .
|
||||
'AND c.name IN (:authorized_centers)' .
|
||||
')'
|
||||
)
|
||||
->setParameter('center', 'Center A')
|
||||
->setParameter('authorized_centers', $centers)
|
||||
->getScalarResult();
|
||||
|
||||
shuffle($this->personIds);
|
||||
|
@@ -680,6 +680,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$this->proxyAccompanyingPeriodOpenState = false;
|
||||
}
|
||||
|
||||
public function countResources(): int
|
||||
{
|
||||
return $this->resources->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* This public function is the same but return only true or false.
|
||||
*/
|
||||
@@ -764,6 +769,18 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function countAccompanyingPeriodInvolved(
|
||||
bool $asParticipantOpen = true,
|
||||
bool $asRequestor = true
|
||||
): int {
|
||||
// TODO should be optimized to avoid loading accompanying period ?
|
||||
return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor)
|
||||
->filter(function (AccompanyingPeriod $p) {
|
||||
return $p->getStep() !== AccompanyingPeriod::STEP_DRAFT;
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AccompanyingPeriodParticipations Collection.
|
||||
*
|
||||
|
@@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class JobAggregator implements AggregatorInterface
|
||||
final class UserJobAggregator implements AggregatorInterface
|
||||
{
|
||||
private UserJobRepository $jobRepository;
|
||||
|
||||
@@ -40,11 +40,11 @@ final class JobAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpjob', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acp.job', 'acpjob');
|
||||
if (!in_array('acpuser', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acp.user', 'acpuser');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acp.job) AS job_aggregator');
|
||||
$qb->addSelect('IDENTITY(acpuser.userJob) AS job_aggregator');
|
||||
$qb->addGroupBy('job_aggregator');
|
||||
}
|
||||
|
@@ -72,6 +72,7 @@ class HasTemporaryLocationFilter implements FilterInterface
|
||||
{
|
||||
$builder
|
||||
->add('having_temporarily', ChoiceType::class, [
|
||||
'label' => 'export.filter.course.having_temporarily.label',
|
||||
'choices' => [
|
||||
'export.filter.course.having_temporarily.Having a temporarily location' => true,
|
||||
'export.filter.course.having_temporarily.Having a person\'s location' => false,
|
||||
|
@@ -126,12 +126,4 @@ class UserJobFilter implements FilterInterface
|
||||
{
|
||||
return 'Filter by user job';
|
||||
}
|
||||
|
||||
private function getUserJob(): UserJob
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->security->getUser();
|
||||
|
||||
return $user->getUserJob();
|
||||
}
|
||||
}
|
||||
|
@@ -11,13 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
@@ -61,13 +60,8 @@ class ReferrerFilter implements FilterInterface
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('accepted_agents', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choice_label' => function (User $u) {
|
||||
return $this->userRender->renderString($u, []);
|
||||
},
|
||||
$builder->add('accepted_agents', PickUserDynamicType::class, [
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,14 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Add menu entrie to person menu.
|
||||
@@ -35,18 +38,28 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
private ResidentialAddressRepository $residentialAddressRepo;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
ParameterBagInterface $parameterBag,
|
||||
Security $security,
|
||||
TranslatorInterface $translator
|
||||
TranslatorInterface $translator,
|
||||
ResidentialAddressRepository $residentialAddressRepo
|
||||
) {
|
||||
$this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period');
|
||||
$this->security = $security;
|
||||
$this->translator = $translator;
|
||||
$this->residentialAddressRepo = $residentialAddressRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menuId
|
||||
* @param MenuItem $menu
|
||||
* @param array{person: Person} $parameters
|
||||
* @return void
|
||||
*/
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
$menu->addChild($this->translator->trans('Person details'), [
|
||||
@@ -67,6 +80,8 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 60,
|
||||
'counter' => 0 < ($nbResidentials = $this->residentialAddressRepo->countByPerson($parameters['person'])) ?
|
||||
$nbResidentials : null,
|
||||
]);
|
||||
|
||||
$menu->addChild($this->translator->trans('person_resources_menu'), [
|
||||
@@ -77,6 +92,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 70,
|
||||
'counter' => 0 < ($nbResources = $parameters['person']->countResources()) ? $nbResources : null,
|
||||
]);
|
||||
|
||||
$menu->addChild($this->translator->trans('household.person history'), [
|
||||
@@ -111,6 +127,8 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 100,
|
||||
'counter' => 0 < ($nbAccompanyingPeriod = $parameters['person']->countAccompanyingPeriodInvolved())
|
||||
? $nbAccompanyingPeriod : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -187,8 +187,12 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
);
|
||||
|
||||
foreach ($scopes as $key => $scope) {
|
||||
$orx->add($qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'));
|
||||
$orx->add($qb->expr()->orX(
|
||||
$qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'),
|
||||
$qb->expr()->eq('ap.user', ':user')
|
||||
));
|
||||
$qb->setParameter('scope_' . $key, $scope);
|
||||
$qb->setParameter('user', $this->security->getUser());
|
||||
}
|
||||
$qb->andWhere($orx);
|
||||
|
||||
|
@@ -32,6 +32,16 @@ class ResidentialAddressRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, ResidentialAddress::class);
|
||||
}
|
||||
|
||||
public function countByPerson(Person $person): int
|
||||
{
|
||||
return $this->createQueryBuilder('ra')
|
||||
->select('COUNT(ra)')
|
||||
->where('ra.person = :person')
|
||||
->setParameter('person', $person)
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder
|
||||
{
|
||||
$date = null === $at ? new DateTimeImmutable('today') : $at;
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
<script>
|
||||
import VueMultiselect from 'vue-multiselect';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
@@ -58,23 +58,17 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getOptions() {
|
||||
const url = `/api/1.0/main/location.json`;
|
||||
makeFetch('GET', url)
|
||||
fetchResults(`/api/1.0/main/location.json`)
|
||||
.then(response => {
|
||||
let options = response.results;
|
||||
let uniqueLocationTypeId = [...new Set(options.map(o => o.locationType.id))];
|
||||
let uniqueLocationTypeId = [...new Set(response.map(o => o.locationType.id))];
|
||||
let results = [];
|
||||
for (let id of uniqueLocationTypeId) {
|
||||
results.push({
|
||||
locationCategories: options.filter(o => o.locationType.id === id)[0].locationType.title.fr,
|
||||
locations: options.filter(o => o.locationType.id === id)
|
||||
locationCategories: response.filter(o => o.locationType.id === id)[0].locationType.title.fr,
|
||||
locations: response.filter(o => o.locationType.id === id)
|
||||
})
|
||||
}
|
||||
this.options = results;
|
||||
return response;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toast.open({message: error.txt})
|
||||
})
|
||||
},
|
||||
updateAdminLocation(value) {
|
||||
|
@@ -111,14 +111,13 @@
|
||||
</add-async-upload>
|
||||
</li>
|
||||
<li>
|
||||
<add-async-upload-downloader
|
||||
:buttonTitle="$t('download')"
|
||||
:storedObject="d.storedObject"
|
||||
>
|
||||
</add-async-upload-downloader>
|
||||
</li>
|
||||
<li v-if="canEditDocument(d)">
|
||||
<a :href="buildEditLink(d.storedObject)" class="btn btn-wopilink"></a>
|
||||
<document-action-buttons-group
|
||||
:stored-object="d.storedObject"
|
||||
:filename="d.title"
|
||||
:can-edit="true"
|
||||
:execute-before-leave="submitBeforeLeaveToEditor"
|
||||
@on-stored-object-status-change="onStatusDocumentChanged"
|
||||
></document-action-buttons-group>
|
||||
</li>
|
||||
<li v-if="d.workflows.length === 0">
|
||||
<a class="btn btn-delete" @click="removeDocument(d)">
|
||||
@@ -174,6 +173,7 @@ import AddAsyncUpload from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUpload
|
||||
import AddAsyncUploadDownloader from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUploadDownloader.vue';
|
||||
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
|
||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||
import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue";
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
@@ -212,6 +212,7 @@ export default {
|
||||
AddAsyncUpload,
|
||||
AddAsyncUploadDownloader,
|
||||
ListWorkflowModal,
|
||||
DocumentActionButtonsGroup,
|
||||
},
|
||||
i18n,
|
||||
data() {
|
||||
@@ -223,78 +224,6 @@ export default {
|
||||
maxPostSize: 15000000,
|
||||
required: false,
|
||||
},
|
||||
mime: [
|
||||
// TODO temporary hardcoded. to be replaced by twig extension or a collabora server query
|
||||
'application/clarisworks',
|
||||
'application/coreldraw',
|
||||
'application/macwriteii',
|
||||
'application/msword',
|
||||
'application/vnd.lotus-1-2-3',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'application/vnd.ms-excel.template.macroEnabled.12',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'application/vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'application/vnd.ms-visio.drawing',
|
||||
'application/vnd.ms-word.document.macroEnabled.12',
|
||||
'application/vnd.ms-word.template.macroEnabled.12',
|
||||
'application/vnd.ms-works',
|
||||
'application/vnd.oasis.opendocument.chart',
|
||||
'application/vnd.oasis.opendocument.formula',
|
||||
'application/vnd.oasis.opendocument.graphics',
|
||||
'application/vnd.oasis.opendocument.graphics-flat-xml',
|
||||
'application/vnd.oasis.opendocument.graphics-template',
|
||||
'application/vnd.oasis.opendocument.presentation',
|
||||
'application/vnd.oasis.opendocument.presentation-flat-xml',
|
||||
'application/vnd.oasis.opendocument.presentation-template',
|
||||
'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'application/vnd.oasis.opendocument.spreadsheet-flat-xml',
|
||||
'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||
'application/vnd.oasis.opendocument.text',
|
||||
'application/vnd.oasis.opendocument.text-flat-xml',
|
||||
'application/vnd.oasis.opendocument.text-master',
|
||||
'application/vnd.oasis.opendocument.text-master-template',
|
||||
'application/vnd.oasis.opendocument.text-template',
|
||||
'application/vnd.oasis.opendocument.text-web',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'application/vnd.sun.xml.calc',
|
||||
'application/vnd.sun.xml.calc.template',
|
||||
'application/vnd.sun.xml.chart',
|
||||
'application/vnd.sun.xml.draw',
|
||||
'application/vnd.sun.xml.draw.template',
|
||||
'application/vnd.sun.xml.impress',
|
||||
'application/vnd.sun.xml.impress.template',
|
||||
'application/vnd.sun.xml.math',
|
||||
'application/vnd.sun.xml.writer',
|
||||
'application/vnd.sun.xml.writer.global',
|
||||
'application/vnd.sun.xml.writer.template',
|
||||
'application/vnd.visio',
|
||||
'application/vnd.visio2013',
|
||||
'application/vnd.wordperfect',
|
||||
'application/x-abiword',
|
||||
'application/x-aportisdoc',
|
||||
'application/x-dbase',
|
||||
'application/x-dif-document',
|
||||
'application/x-fictionbook+xml',
|
||||
'application/x-gnumeric',
|
||||
'application/x-hwp',
|
||||
'application/x-iwork-keynote-sffkey',
|
||||
'application/x-iwork-numbers-sffnumbers',
|
||||
'application/x-iwork-pages-sffpages',
|
||||
'application/x-mspublisher',
|
||||
'application/x-mswrite',
|
||||
'application/x-pagemaker',
|
||||
'application/x-sony-bbeb',
|
||||
'application/x-t602',
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -343,10 +272,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
ISOToDatetime,
|
||||
canEditDocument(document) {
|
||||
return 'storedObject' in document ?
|
||||
this.mime.includes(document.storedObject.type) : false;
|
||||
},
|
||||
listAllStatus() {
|
||||
console.log('load all status');
|
||||
let url = `/api/`;
|
||||
@@ -359,10 +284,25 @@ export default {
|
||||
})
|
||||
;
|
||||
},
|
||||
buildEditLink(storedObject) {
|
||||
return `/chill/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent(
|
||||
buildEditLink(document) {
|
||||
return `/chill/wopi/edit/${document.storedObject.uuid}?returnPath=` + encodeURIComponent(
|
||||
window.location.pathname + window.location.search + window.location.hash);
|
||||
},
|
||||
submitBeforeLeaveToEditor() {
|
||||
console.log('submit beore edit 2');
|
||||
// empty callback
|
||||
const callback = () => null;
|
||||
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
submitBeforeEdit(storedObject) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
|
||||
let document = evaluation.documents.find(d => d.storedObject.id === storedObject.id);
|
||||
//console.log('=> document', document);
|
||||
window.location.assign(this.buildEditLink(document));
|
||||
};
|
||||
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
submitBeforeGenerate({template}) {
|
||||
const callback = (data) => {
|
||||
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
|
||||
@@ -399,6 +339,10 @@ export default {
|
||||
this.$store.commit('removeDocument', {key: this.evaluation.key, document: document});
|
||||
}
|
||||
},
|
||||
onStatusDocumentChanged(newStatus) {
|
||||
console.log('onStatusDocumentChanged', newStatus);
|
||||
this.$store.commit('statusDocumentChanged', {key: this.evaluation.key, newStatus: newStatus});
|
||||
},
|
||||
goToGenerateWorkflowEvaluationDocument({event, link, workflowName, payload}) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
|
||||
|
@@ -360,7 +360,22 @@ const store = createStore({
|
||||
state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
|
||||
.documents.find(d => d.id === payload.id).title = payload.title;
|
||||
}
|
||||
}
|
||||
},
|
||||
statusDocumentChanged(state, {newStatus, key}) {
|
||||
const e = state.evaluationsPicked.find(e => e.key === key);
|
||||
if (typeof e === 'undefined') {
|
||||
console.error('evaluation not found for given key', {key});
|
||||
}
|
||||
|
||||
const doc = e.documents.find(d => d.storedObject?.id === newStatus.id);
|
||||
if (typeof doc === 'undefined') {
|
||||
console.error('document not found', {newStatus});
|
||||
}
|
||||
|
||||
doc.storedObject.status = newStatus.status;
|
||||
doc.storedObject.type = newStatus.type;
|
||||
doc.storedObject.filename = newStatus.filename;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
updateThirdParty({ commit }, payload) {
|
||||
|
@@ -142,7 +142,7 @@
|
||||
{{ mm.mimeIcon(d.storedObject.type) }}
|
||||
</div>
|
||||
<div class="col col-lg-4 text-end">
|
||||
{{ m.download_button_small(d.storedObject, d.title) }}
|
||||
{{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
@@ -6,20 +6,20 @@
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||
{{ encore_entry_link_tags('mod_entity_workflow_pick') }}
|
||||
{{ encore_entry_link_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||
{{ encore_entry_script_tags('mod_entity_workflow_pick') }}
|
||||
{{ encore_entry_script_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="accompanying-course-work">
|
||||
<h1>{{ block('title') }}</h1>
|
||||
|
||||
|
||||
<div class="flex-table mt-4">
|
||||
{% include '@ChillPerson/AccompanyingCourseWork/_item.html.twig' with {
|
||||
'w': work,
|
||||
@@ -29,7 +29,7 @@
|
||||
} %}
|
||||
<div class="p-3 mt-3">{{ macro.metadata(work) }}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a href="{{ path('chill_person_accompanying_period_work_list', { 'id': accompanyingCourse.id }) }}"
|
||||
@@ -51,7 +51,7 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
@@ -63,6 +63,41 @@
|
||||
{%- endif -%}
|
||||
</fieldset>
|
||||
|
||||
{%- if form.email is defined or form.phonenumber is defined or form.mobilenumber is defined or form.contactInfo is defined-%}
|
||||
<fieldset>
|
||||
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
|
||||
{%- if form.email is defined -%}
|
||||
<div id="personEmail">
|
||||
{{ form_row(form.email, {'label': 'Email'}) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- if form.acceptEmail is defined -%}
|
||||
<div id="personAcceptEmail">
|
||||
{{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if form.phonenumber is defined -%}
|
||||
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
|
||||
{%- endif -%}
|
||||
{%- if form.mobilenumber is defined -%}
|
||||
<div id="personPhoneNumber">
|
||||
{{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }}
|
||||
</div>
|
||||
<div id="personAcceptSMS">
|
||||
{{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- if form.otherPhoneNumbers is defined -%}
|
||||
{{ form_widget(form.otherPhoneNumbers) }}
|
||||
{{ form_errors(form.otherPhoneNumbers) }}
|
||||
{%- endif -%}
|
||||
{%- if form.contactInfo is defined -%}
|
||||
{{ form_row(form.contactInfo, {'label': 'Notes on contact information'}) }}
|
||||
{%- endif -%}
|
||||
</fieldset>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if form.nationality is defined or form.spokenLanguages is defined -%}
|
||||
<fieldset>
|
||||
<legend><h2>{{ 'Administrative information'|trans }}</h2></legend>
|
||||
@@ -93,41 +128,6 @@
|
||||
</fieldset>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if form.email is defined or form.phonenumber is defined or form.mobilenumber is defined or form.contactInfo is defined-%}
|
||||
<fieldset>
|
||||
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
|
||||
{%- if form.email is defined -%}
|
||||
<div id="personEmail">
|
||||
{{ form_row(form.email, {'label': 'Email'}) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- if form.acceptEmail is defined -%}
|
||||
<div id="personAcceptEmail">
|
||||
{{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if form.phonenumber is defined -%}
|
||||
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
|
||||
{%- endif -%}
|
||||
{%- if form.mobilenumber is defined -%}
|
||||
<div id="personPhoneNumber">
|
||||
{{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }}
|
||||
</div>
|
||||
<div id="personAcceptSMS">
|
||||
{{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- if form.otherPhoneNumbers is defined -%}
|
||||
{{ form_widget(form.otherPhoneNumbers) }}
|
||||
{{ form_errors(form.otherPhoneNumbers) }}
|
||||
{%- endif -%}
|
||||
{%- if form.contactInfo is defined -%}
|
||||
{{ form_row(form.contactInfo, {'label': 'Notes on contact information'}) }}
|
||||
{%- endif -%}
|
||||
</fieldset>
|
||||
{%- endif -%}
|
||||
|
||||
{{ form_rest(form) }}
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
|
@@ -120,20 +120,13 @@
|
||||
</div>
|
||||
|
||||
{% if display_action is defined and display_action == true %}
|
||||
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork) %}
|
||||
<ul class="record_actions">
|
||||
<li>{{ m.download_button(doc.storedObject, doc.title) }}</li>
|
||||
{% if chill_document_is_editable(doc.storedObject) %}
|
||||
<li>
|
||||
{{ doc.storedObject|chill_document_edit_button }}
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>{{ doc.storedObject|chill_document_button_group(doc.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork)) }}</li>
|
||||
<li>
|
||||
<a class="btn btn-show" href="{{ path('chill_person_accompanying_period_work_edit', {'id': evaluation.accompanyingPeriodWork.id}) }}">
|
||||
{{ 'Show'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@@ -17,9 +17,13 @@
|
||||
|
||||
<div class="list-group vertical-menu {{ 'menu-' ~ menus.name }}">
|
||||
{% for menu in menus %}
|
||||
<a class="list-group-item list-group-item-action"
|
||||
|
||||
<a class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
|
||||
href="{{ menu.uri }}">
|
||||
{{ menu.label|upper }}
|
||||
{% if menu.extras.counter is defined and menu.extras.counter is not null %}
|
||||
<span class="badge rounded-pill bg-secondary notification-counter">{{ menu.extras.counter }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@@ -62,7 +62,7 @@ class SimilarPersonMatcher
|
||||
|
||||
public function matchPerson(
|
||||
Person $person,
|
||||
float $precision = 0.15,
|
||||
float $precision = 0.30,
|
||||
string $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY,
|
||||
bool $addYearComparison = false
|
||||
) {
|
||||
@@ -72,41 +72,50 @@ class SimilarPersonMatcher
|
||||
);
|
||||
$query = $this->em->createQuery();
|
||||
|
||||
$dql = 'SELECT p from ChillPersonBundle:Person p '
|
||||
. ' WHERE ('
|
||||
. ' SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) >= :precision '
|
||||
. ' ) '
|
||||
. ' AND p.center IN (:centers)';
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
|
||||
$qb->select('p')
|
||||
->from(Person::class, 'p')
|
||||
->where('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) >= :precision')
|
||||
->andWhere($qb->expr()->in('p.center', ':centers'));
|
||||
|
||||
if (null !== $person->getBirthdate()) {
|
||||
$qb->andWhere($qb->expr()->orX(
|
||||
$qb->expr()->eq('p.birthdate', ':personBirthdate'),
|
||||
$qb->expr()->isNull('p.birthdate')
|
||||
));
|
||||
|
||||
$qb->setParameter('personBirthdate', $person->getBirthdate());
|
||||
}
|
||||
|
||||
if ($person->getId() !== null) {
|
||||
$dql .= ' AND p.id != :personId ';
|
||||
$notDuplicatePersons = $this->personNotDuplicateRepository->findNotDuplicatePerson($person);
|
||||
|
||||
$qb->andWhere($qb->expr()->neq('p.id', ':personId'));
|
||||
$query->setParameter('personId', $person->getId());
|
||||
|
||||
$notDuplicatePersons = $this->personNotDuplicateRepository->findNotDuplicatePerson($person);
|
||||
|
||||
if (count($notDuplicatePersons)) {
|
||||
$dql .= ' AND p.id not in (:notDuplicatePersons)';
|
||||
$qb->andWhere($qb->expr()->notIn('p.id', ':notDuplicatePersons'));
|
||||
$query->setParameter('notDuplicatePersons', $notDuplicatePersons);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($orderBy) {
|
||||
case self::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL:
|
||||
$dql .= ' ORDER BY p.fullnameCanonical ASC ';
|
||||
$qb->orderBy('p.fullnameCanonical', 'ASC');
|
||||
|
||||
break;
|
||||
|
||||
case self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY:
|
||||
default:
|
||||
$dql .= ' ORDER BY SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) DESC ';
|
||||
$qb->orderBy('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName)))', 'DESC');
|
||||
}
|
||||
|
||||
$query = $query
|
||||
->setDQL($dql)
|
||||
$qb
|
||||
->setParameter('fullName', $this->personRender->renderString($person, []))
|
||||
->setParameter('centers', $centers)
|
||||
->setParameter('precision', $precision);
|
||||
|
||||
return $query->getResult();
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
use Chill\BudgetBundle\Service\Summary\SummaryBudgetInterface;
|
||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
@@ -87,6 +88,7 @@ class PersonDocGenNormalizer implements
|
||||
$dateContext['docgen:expects'] = DateTimeInterface::class;
|
||||
$addressContext = array_merge($context, ['docgen:expects' => Address::class]);
|
||||
$phonenumberContext = array_merge($context, ['docgen:expects' => PhoneNumber::class]);
|
||||
$centerContext = array_merge($context, ['docgen:expects' => Center::class]);
|
||||
$personResourceContext = array_merge($context, [
|
||||
'docgen:expects' => Person\PersonResource::class,
|
||||
// we simplify the list of attributes for the embedded persons
|
||||
@@ -139,6 +141,7 @@ class PersonDocGenNormalizer implements
|
||||
'numberOfChildren' => (string) $person->getNumberOfChildren(),
|
||||
'address' => $this->normalizer->normalize($person->getCurrentPersonAddress(), $format, $addressContext),
|
||||
'resources' => $this->normalizer->normalize($person->getResources(), $format, $personResourceContext),
|
||||
'center' => $this->normalizer->normalize($person->getCenter(), $format, $centerContext),
|
||||
];
|
||||
|
||||
if ($context['docgen:person:with-household'] ?? false) {
|
||||
@@ -240,6 +243,7 @@ class PersonDocGenNormalizer implements
|
||||
|
||||
$attributes = [
|
||||
'id', 'firstName', 'lastName', 'age', 'altNames', 'text',
|
||||
'center' => Center::class,
|
||||
'civility' => Civility::class,
|
||||
'birthdate' => DateTimeInterface::class,
|
||||
'deathdate' => DateTimeInterface::class,
|
||||
|
@@ -24,6 +24,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -51,6 +52,8 @@ class AccompanyingPeriodContext implements
|
||||
|
||||
private PersonRenderInterface $personRender;
|
||||
|
||||
private PersonRepository $personRepository;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
@@ -61,6 +64,7 @@ class AccompanyingPeriodContext implements
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
EntityManagerInterface $em,
|
||||
PersonRenderInterface $personRender,
|
||||
PersonRepository $personRepository,
|
||||
TranslatorInterface $translator,
|
||||
BaseContextData $baseContextData
|
||||
) {
|
||||
@@ -69,6 +73,7 @@ class AccompanyingPeriodContext implements
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->em = $em;
|
||||
$this->personRender = $personRender;
|
||||
$this->personRepository = $personRepository;
|
||||
$this->translator = $translator;
|
||||
$this->baseContextData = $baseContextData;
|
||||
}
|
||||
@@ -256,6 +261,31 @@ class AccompanyingPeriodContext implements
|
||||
return $options['mainPerson'] || $options['person1'] || $options['person2'];
|
||||
}
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
$normalized = [];
|
||||
foreach (['mainPerson', 'person1', 'person2'] as $k) {
|
||||
$normalized[$k] = null !== ($data[$k] ?? null) ? $data[$k]->getId() : null;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
$denormalized = [];
|
||||
|
||||
foreach (['mainPerson', 'person1', 'person2'] as $k) {
|
||||
if (null !== ($id = ($data[$k] ?? null))) {
|
||||
$denormalized[$k] = $this->personRepository->find($id);
|
||||
} else {
|
||||
$denormalized[$k] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $denormalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $entity
|
||||
*/
|
||||
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
@@ -18,7 +19,13 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class AccompanyingPeriodWorkContext
|
||||
/**
|
||||
* Generate a context for an @link{AccompanyingPeriodWork}.
|
||||
*
|
||||
* Although there isn't any document associated to AccompanyingPeriodWork, this context
|
||||
* is use by @link{AccompanyingPeriodWorkEvaluationContext}.
|
||||
*/
|
||||
class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicFormInterface
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
@@ -109,8 +116,18 @@ class AccompanyingPeriodWorkContext
|
||||
return $this->periodContext->hasPublicForm($template, $entity);
|
||||
}
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return $this->periodContext->contextGenerationDataNormalize($template, $entity, $data);
|
||||
}
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return $this->periodContext->contextGenerationDataDenormalize($template, $entity, $data);
|
||||
}
|
||||
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||
{
|
||||
// TODO: Implement storeGenerated() method.
|
||||
// currently, no document associated with a AccompanyingPeriodWork
|
||||
}
|
||||
}
|
||||
|
@@ -174,6 +174,18 @@ class AccompanyingPeriodWorkEvaluationContext implements
|
||||
->hasPublicForm($template, $entity->getAccompanyingPeriodWork());
|
||||
}
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return $this->accompanyingPeriodWorkContext
|
||||
->contextGenerationDataNormalize($template, $entity, $data);
|
||||
}
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return $this->accompanyingPeriodWorkContext
|
||||
->contextGenerationDataDenormalize($template, $entity, $data);
|
||||
}
|
||||
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||
{
|
||||
$doc = new AccompanyingPeriodWorkEvaluationDocument();
|
||||
|
@@ -21,11 +21,13 @@ use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@@ -55,6 +57,8 @@ final class PersonContext implements PersonContextInterface
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
private ScopeRepositoryInterface $scopeRepository;
|
||||
|
||||
private Security $security;
|
||||
|
||||
private bool $showScopes;
|
||||
@@ -71,6 +75,7 @@ final class PersonContext implements PersonContextInterface
|
||||
EntityManagerInterface $em,
|
||||
NormalizerInterface $normalizer,
|
||||
ParameterBagInterface $parameterBag,
|
||||
ScopeRepositoryInterface $scopeRepository,
|
||||
Security $security,
|
||||
TranslatorInterface $translator,
|
||||
TranslatableStringHelperInterface $translatableStringHelper
|
||||
@@ -81,6 +86,7 @@ final class PersonContext implements PersonContextInterface
|
||||
$this->documentCategoryRepository = $documentCategoryRepository;
|
||||
$this->em = $em;
|
||||
$this->normalizer = $normalizer;
|
||||
$this->scopeRepository = $scopeRepository;
|
||||
$this->security = $security;
|
||||
$this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes'];
|
||||
$this->translator = $translator;
|
||||
@@ -211,6 +217,38 @@ final class PersonContext implements PersonContextInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $entity
|
||||
*/
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
$scope = $data['scope'] ?? null;
|
||||
|
||||
return [
|
||||
'title' => $data['title'] ?? '',
|
||||
'scope_id' => $scope instanceof Scope ? $scope->getId() : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $entity
|
||||
*/
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
if (!isset($data['scope'])) {
|
||||
$scope = null;
|
||||
} else {
|
||||
if (null === $scope = $this->scopeRepository->find($data['scope'])) {
|
||||
throw new \UnexpectedValueException('scope not found');
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => $data['title'] ?? '',
|
||||
'scope' => $scope,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $entity
|
||||
*/
|
||||
|
@@ -48,6 +48,10 @@ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterfa
|
||||
*/
|
||||
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
|
||||
/**
|
||||
* @param Person $entity
|
||||
*/
|
||||
|
@@ -17,6 +17,7 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
@@ -30,12 +31,16 @@ class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInt
|
||||
|
||||
private PersonContextInterface $personContext;
|
||||
|
||||
private ThirdPartyRepository $thirdPartyRepository;
|
||||
|
||||
public function __construct(
|
||||
PersonContextInterface $personContext,
|
||||
NormalizerInterface $normalizer
|
||||
NormalizerInterface $normalizer,
|
||||
ThirdPartyRepository $thirdPartyRepository
|
||||
) {
|
||||
$this->personContext = $personContext;
|
||||
$this->normalizer = $normalizer;
|
||||
$this->thirdPartyRepository = $thirdPartyRepository;
|
||||
}
|
||||
|
||||
public function adminFormReverseTransform(array $data): array
|
||||
@@ -123,6 +128,26 @@ class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInt
|
||||
return true;
|
||||
}
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return array_merge(
|
||||
[
|
||||
'thirdParty' => null === $data['thirdParty'] ? null : $data['thirdParty']->getId(),
|
||||
],
|
||||
$this->personContext->contextGenerationDataNormalize($template, $entity, $data),
|
||||
);
|
||||
}
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
{
|
||||
return array_merge(
|
||||
[
|
||||
'thirdParty' => null === $data['thirdParty'] ? null : $this->thirdPartyRepository->find($data['thirdParty']),
|
||||
],
|
||||
$this->personContext->contextGenerationDataDenormalize($template, $entity, $data),
|
||||
);
|
||||
}
|
||||
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||
{
|
||||
$this->personContext->storeGenerated($template, $storedObject, $entity, $contextGenerationData);
|
||||
|
@@ -13,16 +13,16 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregato
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserJobAggregator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JobAggregatorTest extends AbstractAggregatorTest
|
||||
final class UserJobAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
private JobAggregator $aggregator;
|
||||
private UserJobAggregator $aggregator;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
@@ -40,6 +40,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
|
||||
private const BLANK = [
|
||||
'id' => '',
|
||||
'center' => '',
|
||||
'firstName' => '',
|
||||
'lastName' => '',
|
||||
'altNames' => '',
|
||||
@@ -64,6 +65,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
'numberOfChildren' => '',
|
||||
'age' => '@ignored',
|
||||
'resources' => [],
|
||||
'center' => '@ignored',
|
||||
];
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
@@ -0,0 +1,62 @@
|
||||
<?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 Validator\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlapValidator;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class ParticipationOverlapValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
$personRender = $this->prophesize(PersonRenderInterface::class);
|
||||
$personRender->renderString(Argument::is(Person::class), [])->willReturn('person');
|
||||
$thirdPartyRender = $this->prophesize(ThirdPartyRender::class);
|
||||
$thirdPartyRender->renderString(Argument::is(ThirdParty::class), [])->willReturn('thirdparty');
|
||||
|
||||
return new ParticipationOverlapValidator($personRender->reveal(), $thirdPartyRender->reveal());
|
||||
}
|
||||
|
||||
public function testOneParticipation()
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
$person = new Person();
|
||||
|
||||
$collection = new ArrayCollection([
|
||||
new AccompanyingPeriodParticipation($period, $person)
|
||||
]);
|
||||
|
||||
$this->validator->validate($collection, $this->getConstraint());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConstraint()
|
||||
{
|
||||
return new ParticipationOverlap();
|
||||
}
|
||||
}
|
@@ -136,7 +136,7 @@ services:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_scope_aggregator }
|
||||
|
||||
chill.person.export.aggregator_referrer_job:
|
||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator
|
||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserJobAggregator
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_referrer_job_aggregator }
|
||||
|
||||
|
@@ -1068,6 +1068,7 @@ export:
|
||||
by_referrer:
|
||||
Computation date for referrer: Date à laquelle le référent était actif
|
||||
having_temporarily:
|
||||
label: Qualité de la localisation
|
||||
Having a temporarily location: Ayant une localisation temporaire
|
||||
Having a person's location: Ayant une localisation auprès d'un usager
|
||||
Calculation date: Date de la localisation
|
||||
|
Reference in New Issue
Block a user