|
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\Report; |
|
25
|
|
|
use AppBundle\Entity\User; |
|
26
|
|
|
use AppBundle\Entity\Workday; |
|
27
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
28
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
29
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
30
|
|
|
|
|
31
|
|
|
class MyStudentController extends BaseController |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @Route("/estudiantes", name="my_student_index", methods={"GET"}) |
|
35
|
|
|
*/ |
|
36
|
|
|
public function myStudentIndexAction() |
|
37
|
|
|
{ |
|
38
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
39
|
|
|
|
|
40
|
|
|
if (count($users) === 1) { |
|
41
|
|
|
return $this->myStudentAgreementIndexAction($users[0][0]); |
|
42
|
|
|
} |
|
43
|
|
|
return $this->render('student/index.html.twig', [ |
|
44
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
45
|
|
|
'title' => null, |
|
46
|
|
|
'elements' => $users |
|
47
|
|
|
]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @Route("/estudiantes/{id}", name="my_student_agreements", methods={"GET"}) |
|
52
|
|
|
* @Security("is_granted('USER_TRACK', user)") |
|
53
|
|
|
*/ |
|
54
|
|
|
public function myStudentAgreementIndexAction(User $user) |
|
55
|
|
|
{ |
|
56
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
57
|
|
|
$agreements = $user->getStudentAgreements(); |
|
58
|
|
|
|
|
59
|
|
|
if (count($agreements) == 1) { |
|
60
|
|
|
return $this->myStudentAgreementCalendarAction($agreements[0]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$title = $user->getFullDisplayName(); |
|
64
|
|
|
return $this->render('student/calendar_agreement_select.html.twig', |
|
65
|
|
|
[ |
|
66
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
67
|
|
|
'breadcrumb' => [ |
|
68
|
|
|
['fixed' => $title] |
|
69
|
|
|
], |
|
70
|
|
|
'student' => $user, |
|
71
|
|
|
'title' => $title, |
|
72
|
|
|
'elements' => $agreements, |
|
73
|
|
|
'route_name' => 'my_student_agreement_calendar', |
|
74
|
|
|
'back_route_name' => count($users) === 1 ? 'frontpage' : 'my_student_index', |
|
75
|
|
|
'back_route_params' => [], |
|
76
|
|
|
]); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @Route("/estudiantes/seguimiento/{id}", name="my_student_agreement_calendar", methods={"GET"}) |
|
81
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', agreement)") |
|
82
|
|
|
*/ |
|
83
|
|
|
public function myStudentAgreementCalendarAction(Agreement $agreement) |
|
84
|
|
|
{ |
|
85
|
|
|
$users = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getAgreementRelatedStudents($this->getUser()); |
|
86
|
|
|
$calendar = $this->getDoctrine()->getManager()->getRepository('AppBundle:Workday')->getArrayCalendar($agreement->getWorkdays()); |
|
87
|
|
|
$title = (string) $agreement->getWorkcenter(); |
|
88
|
|
|
$agreements = $agreement->getStudent()->getStudentAgreements(); |
|
89
|
|
|
|
|
90
|
|
|
$parent = (count($users) === 1 ? 'frontpage' : 'my_student_index'); |
|
91
|
|
|
|
|
92
|
|
|
return $this->render('student/tutor_calendar_agreement.html.twig', |
|
93
|
|
|
[ |
|
94
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
95
|
|
|
'breadcrumb' => [ |
|
96
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
97
|
|
|
['fixed' => $title], |
|
98
|
|
|
], |
|
99
|
|
|
'title' => $title, |
|
100
|
|
|
'user' => $this->getUser(), |
|
101
|
|
|
'calendar' => $calendar, |
|
102
|
|
|
'agreement' => $agreement, |
|
103
|
|
|
'route_name' => 'my_student_agreement_tracking', |
|
104
|
|
|
'back_route_name' => count($agreements) === 1 ? $parent : 'my_student_agreements', |
|
105
|
|
|
'back_route_params' => count($agreements) === 1 ? []: ['id' => $agreement->getStudent()->getId()], |
|
106
|
|
|
'activities_stats' => $this->getDoctrine()->getManager()->getRepository('AppBundle:Agreement')->getActivitiesStats($agreement) |
|
107
|
|
|
]); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @Route("/estudiantes/seguimiento/{id}/operacion", name="my_student_agreement_calendar_operation", methods={"POST"}) |
|
112
|
|
|
* @Security("is_granted('AGREEMENT_LOCK', agreement) or is_granted('AGREEMENT_UNLOCK', agreement)") |
|
113
|
|
|
*/ |
|
114
|
|
|
public function operationWorkdayAction(Agreement $agreement, Request $request) |
|
115
|
|
|
{ |
|
116
|
|
|
if ($request->request->has('week_lock') || ($request->request->has('week_unlock'))) { |
|
117
|
|
|
return $this->lockWeekAction($agreement, $request, $request->request->has('week_lock'), 'my_student_agreement_calendar'); |
|
118
|
|
|
} else { |
|
119
|
|
|
return $this->lockWorkdayAction($agreement, $request, $request->request->has('lock'), 'my_student_agreement_calendar'); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
/** |
|
123
|
|
|
* @Route("/estudiantes/seguimiento/jornada/{id}", name="my_student_agreement_tracking", methods={"GET", "POST"}) |
|
124
|
|
|
* @Security("is_granted('AGREEMENT_ACCESS', workday.getAgreement())") |
|
125
|
|
|
*/ |
|
126
|
|
|
public function studentWorkdayAction(Workday $workday, Request $request) |
|
127
|
|
|
{ |
|
128
|
|
|
$agreement = $workday->getAgreement(); |
|
129
|
|
|
return $this->baseWorkdayAction($workday, $request, [ |
|
130
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
131
|
|
|
'breadcrumb' => [ |
|
132
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
133
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $workday->getAgreement()->getId()]], |
|
134
|
|
|
['fixed' => $workday->getDate()->format('d/m/Y')] |
|
135
|
|
|
], |
|
136
|
|
|
'back_route_name' => 'my_student_agreement_calendar' |
|
137
|
|
|
]); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @Route("/estudiantes/informe/{id}", name="my_student_agreement_report_form", methods={"GET", "POST"}) |
|
142
|
|
|
* @Security("is_granted('AGREEMENT_REPORT', agreement)") |
|
143
|
|
|
*/ |
|
144
|
|
|
public function studentReportAction(Agreement $agreement, Request $request) |
|
145
|
|
|
{ |
|
146
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
147
|
|
|
if (null === $agreement->getReport()) { |
|
148
|
|
|
$report = new Report(); |
|
149
|
|
|
$report->setAgreement($agreement); |
|
150
|
|
|
$em->persist($report); |
|
151
|
|
|
} else { |
|
152
|
|
|
$report = $agreement->getReport(); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
$form = $this->createForm('AppBundle\Form\Type\ReportType', $report); |
|
156
|
|
|
$form->handleRequest($request); |
|
157
|
|
|
|
|
158
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
|
159
|
|
|
$report->setSignDate(new \DateTime()); |
|
160
|
|
|
$em->flush(); |
|
161
|
|
|
$this->addFlash('success', $this->get('translator')->trans('alert.saved', [], 'student')); |
|
162
|
|
|
return $this->redirectToRoute('my_student_agreement_calendar', ['id' => $agreement->getId()]); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
return $this->render('student/report_form.html.twig', [ |
|
166
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('my_student_index'), |
|
167
|
|
|
'breadcrumb' => [ |
|
168
|
|
|
['fixed' => $agreement->getStudent()->getFullDisplayName(), 'path' => 'my_student_agreements', 'options' => ['id' => $agreement->getStudent()->getId()]], |
|
169
|
|
|
['fixed' => (string) $agreement->getWorkcenter(), 'path' => 'my_student_agreement_calendar', 'options' => ['id' => $agreement->getId()]], |
|
170
|
|
|
['fixed' => $this->get('translator')->trans('form.report', [], 'student')] |
|
171
|
|
|
], |
|
172
|
|
|
'form' => $form->createView(), |
|
173
|
|
|
'agreement' => $agreement |
|
174
|
|
|
]); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|