mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Merge branch 'issue560_ACCent_parcours_household' into 'master'
Create parcours from within household context See merge request Chill-Projet/chill-bundles!390
This commit is contained in:
commit
386e88387d
@ -56,6 +56,7 @@ and this project adheres to
|
||||
* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509)
|
||||
* [thirdparty] Thirdparty view page, english text translated (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/534)
|
||||
* [social_action] Translation changed in evaluation section (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/512)
|
||||
* [household] Within parcours listing page of household add create button (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/560)
|
||||
|
||||
## Test releases
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\AccompanyingCourseType;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
@ -279,6 +280,40 @@ class AccompanyingCourseController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/parcours/new", name="chill_household_accompanying_course_new")
|
||||
*/
|
||||
public function newHouseholdParcoursAction(Request $request): Response
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
if ($request->query->has('household_id')) {
|
||||
$householdId = $request->query->get('household_id');
|
||||
|
||||
$household = $em->getRepository(Household::class)->find($householdId);
|
||||
$members = $household->getCurrentMembers();
|
||||
|
||||
if (null !== $members) {
|
||||
foreach ($members as $m) {
|
||||
$period->addPerson($m->getPerson());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$userLocation = $this->getUser()->getCurrentLocation();
|
||||
$period->setAdministrativeLocation($userLocation);
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
|
||||
|
||||
$em->persist($period);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_course_edit', [
|
||||
'accompanying_period_id' => $period->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
|
@ -46,13 +46,13 @@
|
||||
{{ 'Household summary'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{#
|
||||
{# TODO: add ACL to check if user is allowed to edit household? #}
|
||||
<li>
|
||||
<a href="{{ path ('chill_person_household_accompanying_course_new', {'household_id' : [ household.id ] } ) }}" class="btn btn-create">
|
||||
{{ 'Create an accompanying period'|trans }}
|
||||
<a class="btn btn-create"
|
||||
href="{{ path ('chill_household_accompanying_course_new', {'household_id' : household.id } ) }}" role="button">
|
||||
{{ 'Create an accompanying period'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
#}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user