mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
controller action to create parcours from within household + link added in template
This commit is contained in:
parent
ff5aeaae17
commit
caaa25ef8e
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller;
|
|||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Form\AccompanyingCourseType;
|
use Chill\PersonBundle\Form\AccompanyingCourseType;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
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")
|
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
|
||||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||||
|
@ -46,13 +46,12 @@
|
|||||||
{{ 'Household summary'|trans }}
|
{{ 'Household summary'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{#
|
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path ('chill_person_household_accompanying_course_new', {'household_id' : [ household.id ] } ) }}" class="btn btn-create">
|
<a class="btn btn-create"
|
||||||
|
href="{{ path ('chill_household_accompanying_course_new', {'household_id' : household.id } ) }}" role="button">
|
||||||
{{ 'Create an accompanying period'|trans }}
|
{{ 'Create an accompanying period'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
#}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user