mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
rdv: delete a rdv
This commit is contained in:
parent
7e02b284ca
commit
9c7c890943
@ -267,54 +267,42 @@ class CalendarController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
[$user, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
$view = 'ChillCalendarBundle:Calendar:confirm_deleteAccompanyingCourse.html.twig';
|
$view = 'ChillCalendarBundle:Calendar:confirm_deleteAccompanyingCourse.html.twig';
|
||||||
} elseif ($person instanceof Person) {
|
}
|
||||||
$view = 'ChillCalendarBundle:Calendar:confirm_deletePerson.html.twig';
|
// elseif ($person instanceof Person) {
|
||||||
}
|
// $view = 'ChillCalendarBundle:Calendar:confirm_deletePerson.html.twig';
|
||||||
|
// }
|
||||||
|
|
||||||
/* @var $activity Calendar */
|
/* @var $entity Calendar */
|
||||||
$activity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id);
|
$entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id);
|
||||||
|
|
||||||
if (!$activity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Calendar entity.');
|
throw $this->createNotFoundException('Unable to find Calendar entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
$form = $this->createDeleteForm($id, $user, $accompanyingPeriod);
|
||||||
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
|
||||||
|
|
||||||
$form = $this->createDeleteForm($id, $person, $accompanyingPeriod);
|
|
||||||
|
|
||||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
|
||||||
$this->logger->notice("An activity has been removed", array(
|
$this->logger->notice("A calendar event has been removed", array(
|
||||||
'by_user' => $this->getUser()->getUsername(),
|
'by_user' => $this->getUser()->getUsername(),
|
||||||
'activity_id' => $activity->getId(),
|
'calendar_id' => $entity->getId()
|
||||||
'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
|
|
||||||
'comment' => $activity->getComment()->getComment(),
|
|
||||||
'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
|
|
||||||
'reasons_ids' => $activity->getReasons()
|
|
||||||
->map(function ($ar) { return $ar->getId(); })
|
|
||||||
->toArray(),
|
|
||||||
'type_id' => $activity->getType()->getId(),
|
|
||||||
'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
|
|
||||||
'date' => $activity->getDate()->format('Y-m-d'),
|
|
||||||
'attendee' => $activity->getAttendee()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$em->remove($activity);
|
$em->remove($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')
|
$this->addFlash('success', $this->get('translator')
|
||||||
->trans("The activity has been successfully removed."));
|
->trans("The calendar has been successfully removed."));
|
||||||
|
|
||||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
|
||||||
return $this->redirectToRoute('chill_activity_activity_list', $params);
|
return $this->redirectToRoute('chill_calendar_calendar', $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,9 +311,8 @@ class CalendarController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($view, array(
|
return $this->render($view, array(
|
||||||
'activity' => $activity,
|
'calendar' => $entity,
|
||||||
'delete_form' => $form->createView(),
|
'delete_form' => $form->createView(),
|
||||||
'person' => $person,
|
|
||||||
'accompanyingCourse' => $accompanyingPeriod,
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -339,7 +326,7 @@ class CalendarController extends AbstractController
|
|||||||
$params['id'] = $id;
|
$params['id'] = $id;
|
||||||
|
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('chill_activity_activity_delete', $params))
|
->setAction($this->generateUrl('chill_calendar_calendar_delete', $params))
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
->getForm()
|
->getForm()
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar' %}
|
||||||
|
|
||||||
|
{% block title 'Remove calendar item'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'Remove calendar item'|trans,
|
||||||
|
'confirm_question' : 'Are you sure you want to remove the calendar item?'|trans,
|
||||||
|
'cancel_route' : 'chill_calendar_calendar',
|
||||||
|
'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : calendar.id },
|
||||||
|
'form' : delete_form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,17 @@
|
|||||||
|
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
{% set person = activity.person %}
|
||||||
|
|
||||||
|
{% block title 'Remove activity'|trans %}
|
||||||
|
|
||||||
|
{% block personcontent %}
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'Remove activity'|trans,
|
||||||
|
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname } ),
|
||||||
|
'cancel_route' : 'chill_activity_activity_list',
|
||||||
|
'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id },
|
||||||
|
'form' : delete_form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
@ -32,12 +32,9 @@
|
|||||||
{% if calendar.endDate %}
|
{% if calendar.endDate %}
|
||||||
<h3>{{ calendar.endDate|format_date('long') }}</h3>
|
<h3>{{ calendar.endDate|format_date('long') }}</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>{{ calendar.endDate.diff(calendar.startDate)|date("%i'%s''") }}</h3>
|
<h3>{{ calendar.endDate.diff(calendar.startDate)|date("%Y%m%d%h") }}</h3>
|
||||||
|
|
||||||
|
|
||||||
{% if context == 'user' and calendar.accompanyingPeriod is not empty %}
|
{% if context == 'user' and calendar.accompanyingPeriod is not empty %}
|
||||||
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user