| @@ 129-157 (lines=29) @@ | ||
| 126 | ||
| 127 | $em = $this->getDoctrine()->getManager(); |
|
| 128 | ||
| 129 | if ($request->request->has('ids')) { |
|
| 130 | try { |
|
| 131 | $ids = $request->request->get('ids'); |
|
| 132 | ||
| 133 | $dates = $em->getRepository('AppBundle:Workday')->createQueryBuilder('w') |
|
| 134 | ->where('w.id IN (:ids)') |
|
| 135 | ->andWhere('w.agreement = :agreement') |
|
| 136 | ->setParameter('ids', $ids) |
|
| 137 | ->setParameter('agreement', $agreement) |
|
| 138 | ->getQuery() |
|
| 139 | ->getResult(); |
|
| 140 | ||
| 141 | /** @var Workday $date */ |
|
| 142 | foreach ($dates as $date) { |
|
| 143 | if ($date->getTrackedHours() === 0) { |
|
| 144 | $em->remove($date); |
|
| 145 | } |
|
| 146 | } |
|
| 147 | $em->flush(); |
|
| 148 | ||
| 149 | $agreement->setFromDate($this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getRealFromDate($agreement)); |
|
| 150 | $agreement->setToDate($this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getRealToDate($agreement)); |
|
| 151 | ||
| 152 | $em->flush(); |
|
| 153 | $this->addFlash('success', $this->get('translator')->trans('alert.deleted', [], 'calendar')); |
|
| 154 | } catch (\Exception $e) { |
|
| 155 | $this->addFlash('error', $this->get('translator')->trans('alert.not_deleted', [], 'calendar')); |
|
| 156 | } |
|
| 157 | } |
|
| 158 | return $this->redirectToRoute('agreement_calendar', ['id' => $agreement->getId()]); |
|
| 159 | } |
|
| 160 | ||
| @@ 197-225 (lines=29) @@ | ||
| 194 | ||
| 195 | $em = $this->getDoctrine()->getManager(); |
|
| 196 | ||
| 197 | if ($request->request->has('ids')) { |
|
| 198 | try { |
|
| 199 | $ids = $request->request->get('ids'); |
|
| 200 | ||
| 201 | $dates = $em->getRepository('AppBundle:Workday')->createQueryBuilder('w') |
|
| 202 | ->where('w.id IN (:ids)') |
|
| 203 | ->andWhere('w.agreement = :agreement') |
|
| 204 | ->setParameter('ids', $ids) |
|
| 205 | ->setParameter('agreement', $agreement) |
|
| 206 | ->getQuery() |
|
| 207 | ->getResult(); |
|
| 208 | ||
| 209 | /** @var Workday $date */ |
|
| 210 | foreach ($dates as $date) { |
|
| 211 | if ($date->getTrackedHours() === 0) { |
|
| 212 | $em->remove($date); |
|
| 213 | } |
|
| 214 | } |
|
| 215 | $em->flush(); |
|
| 216 | ||
| 217 | $agreement->setFromDate($this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getRealFromDate($agreement)); |
|
| 218 | $agreement->setToDate($this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getRealToDate($agreement)); |
|
| 219 | ||
| 220 | $em->flush(); |
|
| 221 | $this->addFlash('success', $this->get('translator')->trans('alert.deleted', [], 'calendar')); |
|
| 222 | } catch (\Exception $e) { |
|
| 223 | $this->addFlash('error', $this->get('translator')->trans('alert.not_deleted', [], 'calendar')); |
|
| 224 | } |
|
| 225 | } |
|
| 226 | return $this->redirectToRoute('admin_group_student_calendar', ['id' => $agreement->getId()]); |
|
| 227 | } |
|
| 228 | ||