|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
ÁTICA - Aplicación web para la gestión documental de centros educativos |
|
4
|
|
|
|
|
5
|
|
|
Copyright (C) 2015-2016: Luis Ramón López López |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Affero General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Affero General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
along with this program. If not, see [http://www.gnu.org/licenses/]. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppBundle\Controller; |
|
22
|
|
|
|
|
23
|
|
|
use AppBundle\Entity\Agreement; |
|
24
|
|
|
use AppBundle\Entity\User; |
|
25
|
|
|
use AppBundle\Entity\Workday; |
|
26
|
|
|
use AppBundle\Form\Model\Attendance; |
|
27
|
|
|
use Doctrine\ORM\EntityManager; |
|
28
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
29
|
|
|
use Symfony\Component\Form\Form; |
|
30
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
31
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
32
|
|
|
|
|
33
|
|
|
class MyStudentController extends BaseController |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @Route("/estudiantes", name="my_student_index", methods={"GET"}) |
|
37
|
|
|
*/ |
|
38
|
|
|
public function myStudentIndexAction() |
|
39
|
|
|
{ |
|
40
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
41
|
|
|
|
|
42
|
|
|
if (count($users) === 1) { |
|
43
|
|
|
return $this->myStudentAgreementIndexAction($users[0][0]); |
|
44
|
|
|
} |
|
45
|
|
|
return $this->render('student/index.html.twig', [ |
|
46
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
47
|
|
|
'title' => null, |
|
48
|
|
|
'elements' => $users |
|
49
|
|
|
]); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @Route("/estudiantes/{id}", name="my_student_agreements", methods={"GET"}) |
|
54
|
|
|
* @Security("is_granted('USER_TRACK', student)") |
|
55
|
|
|
*/ |
|
56
|
|
|
public function myStudentAgreementIndexAction(User $student) |
|
57
|
|
|
{ |
|
58
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
59
|
|
|
$agreements = $this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getTutorizedAgreements($student, $this->getUser()); |
|
60
|
|
|
|
|
61
|
|
|
if (count($agreements) == 1) { |
|
62
|
|
|
return $this->myStudentAgreementCalendarAction($agreements[0]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$title = $student->getFullDisplayName(); |
|
66
|
|
|
return $this->render('student/calendar_agreement_select.html.twig', |
|
67
|
|
|
[ |
|
68
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
69
|
|
|
'breadcrumb' => [ |
|
70
|
|
|
['fixed' => $title] |
|
71
|
|
|
], |
|
72
|
|
|
'student' => $student, |
|
73
|
|
|
'title' => $title, |
|
74
|
|
|
'elements' => $agreements, |
|
75
|
|
|
'route_name' => 'my_student_agreement_calendar', |
|
76
|
|
|
'back_route_name' => count($users) === 1 ? 'frontpage' : 'my_student_index', |
|
77
|
|
|
'back_route_params' => [], |
|
78
|
|
|
]); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @Route("/estudiantes/seguimiento/{id}", name="my_student_agreement_calendar", methods={"GET"}) |
|
83
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
84
|
|
|
*/ |
|
85
|
|
|
public function myStudentAgreementCalendarAction(Agreement $agreement) |
|
86
|
|
|
{ |
|
87
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
88
|
|
|
$calendar = $this->getDoctrine()->getManager()->getRepository('AppBundle:Workday')->getArrayCalendar($agreement->getWorkdays()); |
|
89
|
|
|
$agreements = $this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getTutorizedAgreements($agreement->getStudent(), $this->getUser()); |
|
90
|
|
|
$title = (string) $agreement; |
|
91
|
|
|
|
|
92
|
|
|
$parent = (count($users) === 1 ? 'frontpage' : 'my_student_index'); |
|
93
|
|
|
|
|
94
|
|
|
return $this->render('student/tutor_calendar_agreement.html.twig', |
|
95
|
|
|
[ |
|
96
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
97
|
|
|
'breadcrumb' => [ |
|
98
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
99
|
|
|
['fixed' => (string) $agreement->getWorkcenter()], |
|
100
|
|
|
], |
|
101
|
|
|
'title' => $title, |
|
102
|
|
|
'user' => $this->getUser(), |
|
103
|
|
|
'calendar' => $calendar, |
|
104
|
|
|
'agreement' => $agreement, |
|
105
|
|
|
'route_name' => 'my_student_agreement_tracking', |
|
106
|
|
|
'back_route_name' => count($agreements) === 1 ? $parent : 'my_student_agreements', |
|
107
|
|
|
'back_route_params' => count($agreements) === 1 ? [] : ['id' => $agreement->getStudent()->getId()], |
|
108
|
|
|
'activities_stats' => $this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getActivitiesStats($agreement) |
|
109
|
|
|
]); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @Route("/estudiantes/seguimiento/{id}/operacion", name="my_student_agreement_calendar_operation", methods={"POST"}) |
|
114
|
|
|
* @Security("is_granted('AGREEMENT_LOCK', agreement) or is_granted('AGREEMENT_UNLOCK', agreement)") |
|
115
|
|
|
*/ |
|
116
|
|
|
public function operationWorkdayAction(Agreement $agreement, Request $request) |
|
117
|
|
|
{ |
|
118
|
|
View Code Duplication |
if ($request->request->has('week_lock') || $request->request->has('week_lock_print') || ($request->request->has('week_unlock'))) { |
|
|
|
|
|
|
119
|
|
|
$this->lockWeekHelper($agreement, $request, !$request->request->has('week_unlock')); |
|
120
|
|
|
|
|
121
|
|
|
if ($request->request->has('week_lock_print')) { |
|
122
|
|
|
$data = $request->request->get('week_lock_print'); |
|
123
|
|
|
$week = $data % 100; |
|
124
|
|
|
$year = intdiv($data, 100); |
|
125
|
|
|
return $this->redirectToRoute('my_student_weekly_report_download', ['id' => $agreement->getId(), 'week' => $week, 'year' => $year]); |
|
126
|
|
|
} |
|
127
|
|
|
$this->redirectToRoute('my_student_agreement_calendar', ['id' => $agreement->getId()]); |
|
128
|
|
|
} |
|
129
|
|
|
return $this->lockWorkdayAction($agreement, $request, $request->request->has('lock'), 'my_student_agreement_calendar'); |
|
130
|
|
|
} |
|
131
|
|
|
/** |
|
132
|
|
|
* @Route("/estudiantes/seguimiento/jornada/{id}", name="my_student_agreement_tracking", methods={"GET", "POST"}) |
|
133
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', workday.getAgreement())") |
|
134
|
|
|
*/ |
|
135
|
|
|
public function studentWorkdayAction(Workday $workday, Request $request) |
|
136
|
|
|
{ |
|
137
|
|
|
$agreement = $workday->getAgreement(); |
|
138
|
|
|
return $this->baseWorkdayAction($workday, $request, [ |
|
139
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
140
|
|
|
'breadcrumb' => [ |
|
141
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
142
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $workday->getAgreement()->getId()]], |
|
143
|
|
|
['fixed' => $workday->getDate()->format('d/m/Y')] |
|
144
|
|
|
], |
|
145
|
|
|
'back_route_name' => 'my_student_agreement_calendar' |
|
146
|
|
|
]); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @Route("/estudiantes/informe/{id}", name="my_student_agreement_report_form", methods={"GET", "POST"}) |
|
151
|
|
|
* @Security("is_granted('AGREEMENT_REPORT', agreement)") |
|
152
|
|
|
*/ |
|
153
|
|
|
public function studentReportAction(Agreement $agreement, Request $request) |
|
154
|
|
|
{ |
|
155
|
|
|
$breadcrumb = [ |
|
156
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
157
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'admin_group_student_calendar', 'options' => ['id' => $agreement->getId()]], |
|
158
|
|
|
['fixed' => $this->get('translator')->trans('form.report', [], 'student')] |
|
159
|
|
|
]; |
|
160
|
|
|
|
|
161
|
|
|
$routes = ['my_student_agreement_calendar', 'my_student_agreement_report_download']; |
|
162
|
|
|
|
|
163
|
|
|
return $this->workTutorReportAction($agreement, $request, $breadcrumb, $routes, 'student/report_form.html.twig'); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @Route("/alumnado/seguimiento/informe/descargar/{id}", name="admin_group_agreement_report_download", methods={"GET"}) |
|
168
|
|
|
* @Route("/estudiantes/informe/descargar/{id}", name="my_student_agreement_report_download", methods={"GET"}) |
|
169
|
|
|
* @Security("is_granted('AGREEMENT_REPORT', agreement)") |
|
170
|
|
|
*/ |
|
171
|
|
|
public function downloadStudentReportAction(Agreement $agreement) |
|
172
|
|
|
{ |
|
173
|
|
|
$translator = $this->get('translator'); |
|
174
|
|
|
|
|
175
|
|
|
$title = $translator->trans('form.report', [], 'student') . ' - ' . $agreement->getStudent(); |
|
176
|
|
|
|
|
177
|
|
|
$mpdf = $this->get('sasedev_mpdf'); |
|
178
|
|
|
$mpdf->init(); |
|
179
|
|
|
$this->fillWorkingTutorReport($mpdf, $translator, $agreement, $title); |
|
180
|
|
|
|
|
181
|
|
|
$title = str_replace(' ', '_', $title); |
|
182
|
|
|
return $mpdf->generateInlineFileResponse($title . '.pdf'); |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @Route("/estudiantes/ficha/descargar/{id}/{year}/{week}", name="my_student_weekly_report_download", methods={"GET"}) |
|
187
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
188
|
|
|
*/ |
|
189
|
|
|
public function downloadWeeklyReportAction(Agreement $agreement, $year, $week) |
|
190
|
|
|
{ |
|
191
|
|
|
/** @var EntityManager $em */ |
|
192
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
193
|
|
|
|
|
194
|
|
|
$isLocked = $em->getRepository('AppBundle:Workday')->isWeekLocked($agreement, $week, $year); |
|
195
|
|
|
|
|
196
|
|
|
if (false === $isLocked) { |
|
197
|
|
|
$this->denyAccessUnlessGranted('AGREEMENT_LOCK', $agreement); |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
$weekDays = $em->getRepository('AppBundle:Workday')->getWorkdaysInWeek($agreement, $week, $year); |
|
201
|
|
|
|
|
202
|
|
|
if (0 === count($weekDays)) { |
|
203
|
|
|
throw $this->createNotFoundException(); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
$weekInfo = $em->getRepository('AppBundle:Workday')->getWeekInformation($weekDays[0]); |
|
207
|
|
|
|
|
208
|
|
|
$translator = $this->get('translator'); |
|
209
|
|
|
|
|
210
|
|
|
$title = $translator->trans('form.weekly_report', [], 'student') . ' - ' . $agreement->getStudent() . ' - Semana ' . str_pad($weekInfo['current'], 2, '0', STR_PAD_LEFT); |
|
211
|
|
|
|
|
212
|
|
|
$mpdf = $this->get('sasedev_mpdf'); |
|
213
|
|
|
$mpdf->init(); |
|
214
|
|
|
|
|
215
|
|
|
$this->fillWeeklyReport($mpdf, $translator, $agreement, $weekDays, $title, $isLocked, $weekInfo); |
|
216
|
|
|
|
|
217
|
|
|
$title = str_replace(' ', '_', $title); |
|
218
|
|
|
return $mpdf->generateInlineFileResponse($title . '.pdf'); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @Route("/alumnado/seguimiento/programa/descargar/{id}", name="admin_group_teaching_program_report_download", methods={"GET"}) |
|
223
|
|
|
* @Route("/estudiantes/programa/descargar/{id}", name="my_student_teaching_program_report_download", methods={"GET"}) |
|
224
|
|
|
* @Security("is_granted('AGREEMENT_REPORT', agreement)") |
|
225
|
|
|
*/ |
|
226
|
|
View Code Duplication |
public function downloadTeachingProgramReportAction(Agreement $agreement) |
|
|
|
|
|
|
227
|
|
|
{ |
|
228
|
|
|
$translator = $this->get('translator'); |
|
229
|
|
|
|
|
230
|
|
|
$title = $translator->trans('form.training_program', [], 'training_program_report') . ' - ' . $agreement->getStudent() . ' - ' . $agreement->getWorkcenter(); |
|
231
|
|
|
|
|
232
|
|
|
$mpdf = $this->get('sasedev_mpdf'); |
|
233
|
|
|
$mpdf->init('', 'A4-L'); |
|
234
|
|
|
|
|
235
|
|
|
$obj = $mpdf->getMpdf(); |
|
236
|
|
|
$obj->SetImportUse(); |
|
237
|
|
|
$obj->SetDocTemplate('pdf/Programa_Formativo_seneca_vacio.pdf', true); |
|
238
|
|
|
$mpdf->useTwigTemplate('student/training_program_report.html.twig', [ |
|
239
|
|
|
'agreement' => $agreement, |
|
240
|
|
|
'title' => $title, |
|
241
|
|
|
'learning_program' => $this->getDoctrine()->getRepository('AppBundle:LearningOutcome')->getLearningProgramFromAgreement($agreement), |
|
242
|
|
|
'academic_year' => $this->getParameter('academic.year') |
|
243
|
|
|
]); |
|
244
|
|
|
|
|
245
|
|
|
$title = str_replace(' ', '_', $title); |
|
246
|
|
|
return $mpdf->generateInlineFileResponse($title . '.pdf'); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @Route("/alumnado/seguimiento/actividades/descargar/{id}", name="admin_group_activity_report_download", methods={"GET"}) |
|
251
|
|
|
* @Route("/estudiantes/actividades/descargar/{id}", name="my_student_activity_report_download", methods={"GET"}) |
|
252
|
|
|
* @Security("is_granted('AGREEMENT_REPORT', agreement)") |
|
253
|
|
|
*/ |
|
254
|
|
|
public function downloadActivityReportAction(Agreement $agreement) |
|
255
|
|
|
{ |
|
256
|
|
|
$translator = $this->get('translator'); |
|
257
|
|
|
|
|
258
|
|
|
$title = $translator->trans('form.activity_report', [], 'activity_report') . ' - ' . $agreement->getStudent(); |
|
259
|
|
|
|
|
260
|
|
|
$mpdf = $this->get('sasedev_mpdf'); |
|
261
|
|
|
$mpdf->init('', 'A4'); |
|
262
|
|
|
|
|
263
|
|
|
$obj = $mpdf->getMpdf(); |
|
264
|
|
|
$obj->SetImportUse(); |
|
265
|
|
|
$obj->SetDocTemplate('pdf/A4_vacio.pdf', true); |
|
266
|
|
|
|
|
267
|
|
|
$agreements = $agreement->getStudent()->getStudentAgreements(); |
|
268
|
|
|
|
|
269
|
|
|
$educationalTutors = [$agreement->getEducationalTutor()]; |
|
270
|
|
|
$totalHours = $this->getDoctrine()->getRepository('AppBundle:User')->countAgreementHours($agreement->getStudent()); |
|
271
|
|
|
|
|
272
|
|
|
$activities = []; |
|
273
|
|
|
$documentDate = null; |
|
274
|
|
|
|
|
275
|
|
|
/** @var Agreement $a */ |
|
276
|
|
|
foreach($agreements as $a) { |
|
277
|
|
|
$activities[] = [$a, $this->getDoctrine()->getRepository('AppBundle:Agreement')->getActivitiesStats($a)]; |
|
278
|
|
|
if (null === $documentDate || $a->getToDate() > $documentDate) { |
|
279
|
|
|
$documentDate = $a->getToDate(); |
|
280
|
|
|
} |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
$mpdf->useTwigTemplate('student/activity_report.html.twig', [ |
|
284
|
|
|
'agreement' => $agreement, |
|
285
|
|
|
'title' => $title, |
|
286
|
|
|
'activities' => $activities, |
|
287
|
|
|
'educational_tutors' => $educationalTutors, |
|
288
|
|
|
'total_hours' => $totalHours, |
|
289
|
|
|
'document_date' => $documentDate, |
|
290
|
|
|
'academic_year' => $this->getParameter('academic.year') |
|
291
|
|
|
]); |
|
292
|
|
|
|
|
293
|
|
|
$title = str_replace(' ', '_', $title); |
|
294
|
|
|
return $mpdf->generateInlineFileResponse($title . '.pdf'); |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @Route("/estudiantes/detalle/{id}", name="my_student_detail", methods={"GET"}) |
|
299
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
300
|
|
|
*/ |
|
301
|
|
View Code Duplication |
public function myStudentDetailAction(Agreement $agreement) |
|
|
|
|
|
|
302
|
|
|
{ |
|
303
|
|
|
$student = $agreement->getStudent(); |
|
304
|
|
|
$form = $this->createForm('AppBundle\Form\Type\StudentUserType', $student, [ |
|
305
|
|
|
'admin' => false, |
|
306
|
|
|
'disabled' => true |
|
307
|
|
|
]); |
|
308
|
|
|
|
|
309
|
|
|
return $this->render('student/student_detail.html.twig', |
|
310
|
|
|
[ |
|
311
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
312
|
|
|
'breadcrumb' => [ |
|
313
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
314
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $agreement->getId()]], |
|
315
|
|
|
['fixed' => $this->get('translator')->trans('student.detail', [], 'group')] |
|
316
|
|
|
], |
|
317
|
|
|
'title' => (string) $student, |
|
318
|
|
|
'user' => $student, |
|
319
|
|
|
'agreement' => $agreement, |
|
320
|
|
|
'form' => $form->createView(), |
|
321
|
|
|
'back' => 'my_student_agreement_calendar' |
|
322
|
|
|
]); |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @Route("/estudiantes/centro/{id}", name="workcenter_detail", methods={"GET"}) |
|
327
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
328
|
|
|
*/ |
|
329
|
|
View Code Duplication |
public function workCenterDetailAction(Agreement $agreement) |
|
|
|
|
|
|
330
|
|
|
{ |
|
331
|
|
|
$workcenter = $agreement->getWorkcenter(); |
|
332
|
|
|
$form = $this->createForm('AppBundle\Form\Type\WorkcenterType', $workcenter, [ |
|
333
|
|
|
'disabled' => true |
|
334
|
|
|
]); |
|
335
|
|
|
|
|
336
|
|
|
return $this->render('student/workcenter_detail.html.twig', |
|
337
|
|
|
[ |
|
338
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
339
|
|
|
'breadcrumb' => [ |
|
340
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
341
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $agreement->getId()]], |
|
342
|
|
|
['fixed' => $this->get('translator')->trans('form.workcenter', [], 'company')] |
|
343
|
|
|
], |
|
344
|
|
|
'title' => (string) $workcenter, |
|
345
|
|
|
'workcenter' => $workcenter, |
|
346
|
|
|
'agreement' => $agreement, |
|
347
|
|
|
'form' => $form->createView(), |
|
348
|
|
|
'back' => 'my_student_agreement_calendar' |
|
349
|
|
|
]); |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
private function attendanceForm(Request $request, Agreement $agreement, Form $form) |
|
353
|
|
|
{ |
|
354
|
|
|
$title = $this->get('translator')->trans('form.attendance_report', [], 'student'); |
|
355
|
|
|
|
|
356
|
|
|
$routeName = $request->get('_route'); |
|
357
|
|
|
if ($routeName === 'admin_group_attendance_report') { |
|
358
|
|
|
$breadcrumb = [ |
|
359
|
|
|
['fixed' => $agreement->getStudent()->getStudentGroup()->getName(), 'path' => 'admin_group_students', 'options' => ['id' => $agreement->getStudent()->getStudentGroup()->getId()]], |
|
360
|
|
|
['fixed' => (string) $agreement->getStudent(), 'path' => 'admin_group_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
361
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'admin_group_student_calendar', 'options' => ['id' => $agreement->getId()]], |
|
362
|
|
|
['fixed' => $title] |
|
363
|
|
|
]; |
|
364
|
|
|
$menuItem = $this->get('app.menu_builders_chain')->getMenuItemByRouteName('admin_tutor_group'); |
|
365
|
|
|
$backRoute = 'admin_group_student_calendar'; |
|
366
|
|
|
} elseif ($routeName === 'my_student_attendance_report') { |
|
367
|
|
|
$breadcrumb = [ |
|
368
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
369
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $agreement->getId()]], |
|
370
|
|
|
['fixed' => $title] |
|
371
|
|
|
]; |
|
372
|
|
|
$menuItem = $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'); |
|
373
|
|
|
$backRoute = 'my_student_agreement_calendar'; |
|
374
|
|
|
} else { |
|
375
|
|
|
$breadcrumb = [ |
|
376
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'student_calendar_agreement', 'options' => ['id' => $agreement->getId()]], |
|
377
|
|
|
['fixed' => $title] |
|
378
|
|
|
]; |
|
379
|
|
|
$menuItem = $this->get('app.menu_builders_chain')->getMenuItemByRouteName('student_calendar'); |
|
380
|
|
|
$backRoute = 'student_calendar_agreement'; |
|
381
|
|
|
} |
|
382
|
|
|
return $this->render('student/attendance.html.twig', |
|
383
|
|
|
[ |
|
384
|
|
|
'menu_item' => $menuItem, |
|
385
|
|
|
'breadcrumb' => $breadcrumb, |
|
386
|
|
|
'title' => (string) $title, |
|
387
|
|
|
'agreement' => $agreement, |
|
388
|
|
|
'form' => $form->createView(), |
|
389
|
|
|
'back' => $backRoute |
|
390
|
|
|
]); |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* @Route("/alumnado/seguimiento/asistencia/{id}", name="admin_group_attendance_report", methods={"GET"}) |
|
395
|
|
|
* @Route("/estudiantes/asistencia/{id}", name="my_student_attendance_report", methods={"GET"}) |
|
396
|
|
|
* @Route("/asistencia/{id}", name="attendance_report", methods={"GET"}) |
|
397
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
398
|
|
|
*/ |
|
399
|
|
|
public function attendanceReportAction(Request $request, Agreement $agreement) |
|
400
|
|
|
{ |
|
401
|
|
|
$form = $this->createForm('AppBundle\Form\Type\AttendanceType', new Attendance()); |
|
402
|
|
|
|
|
403
|
|
|
return $this->attendanceForm($request, $agreement, $form); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* @Route("/alumnado/seguimiento/asistencia/{id}", name="admin_group_attendance_report_download", methods={"POST"}) |
|
408
|
|
|
* @Route("/estudiantes/asistencia/{id}", name="my_student_attendance_report_download", methods={"POST"}) |
|
409
|
|
|
* @Route("/asistencia/{id}", name="attendance_report_download", methods={"POST"}) |
|
410
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
411
|
|
|
*/ |
|
412
|
|
|
public function downloadAttendanceReportAction(Request $request, Agreement $agreement) |
|
413
|
|
|
{ |
|
414
|
|
|
$attendance = new Attendance(); |
|
415
|
|
|
$form = $this->createForm('AppBundle\Form\Type\AttendanceType', $attendance); |
|
416
|
|
|
$form->handleRequest($request); |
|
417
|
|
|
|
|
418
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
|
419
|
|
|
$translator = $this->get('translator'); |
|
420
|
|
|
|
|
421
|
|
|
$title = $translator->trans('report.title', [], 'attendance_report') . ' - ' . $agreement->getStudent(); |
|
422
|
|
|
|
|
423
|
|
|
$mpdf = $this->get('sasedev_mpdf'); |
|
424
|
|
|
$mpdf->init('', 'A4-L'); |
|
425
|
|
|
|
|
426
|
|
|
$obj = $mpdf->getMpdf(); |
|
427
|
|
|
$obj->SetImportUse(); |
|
428
|
|
|
$obj->SetDocTemplate('pdf/Modelo_de_acreditacion_de_asistencia_a_la_empresa_FCT_vacio.pdf', true); |
|
429
|
|
|
|
|
430
|
|
|
$agreements = $agreement->getStudent()->getStudentAgreements(); |
|
|
|
|
|
|
431
|
|
|
|
|
432
|
|
|
$mpdf->useTwigTemplate('student/attendance_report.html.twig', [ |
|
433
|
|
|
'agreement' => $agreement, |
|
434
|
|
|
'attendance' => $attendance, |
|
435
|
|
|
'title' => $title, |
|
436
|
|
|
'academic_year' => $this->getParameter('academic.year') |
|
437
|
|
|
]); |
|
438
|
|
|
|
|
439
|
|
|
$title = str_replace(' ', '_', $title); |
|
440
|
|
|
return $mpdf->generateInlineFileResponse($title . '.pdf'); |
|
441
|
|
|
} |
|
442
|
|
|
else { |
|
443
|
|
|
return $this->attendanceForm($request, $agreement, $form); |
|
444
|
|
|
} |
|
445
|
|
|
} |
|
446
|
|
|
} |
|
447
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.