|
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\User; |
|
24
|
|
|
use AppBundle\Entity\Visit; |
|
25
|
|
|
use AppBundle\Entity\Workcenter; |
|
26
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
27
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
28
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @Security("is_granted('ROLE_TEACHING_TUTOR')") |
|
32
|
|
|
*/ |
|
33
|
|
|
class VisitController extends Controller |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @Route("/visitas", name="visit_index", methods={"GET"}) |
|
37
|
|
|
*/ |
|
38
|
|
|
public function teacherIndexAction() |
|
39
|
|
|
{ |
|
40
|
|
|
/** @var User $user */ |
|
41
|
|
|
$user = $this->getUser(); |
|
42
|
|
|
if ($this->isGranted('ROLE_DEPARTMENT_HEAD')) { |
|
43
|
|
|
$visits = $this->getDoctrine()->getManager()->getRepository('AppBundle:User')->getEducationalTutors(); |
|
44
|
|
|
} else { |
|
45
|
|
|
return $this->visitIndexAction($user); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $this->render('visit/tutor_index.html.twig', [ |
|
49
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('visit_index'), |
|
50
|
|
|
'title' => null, |
|
51
|
|
|
'elements' => $visits |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @Route("/visitas/{id}", name="visit_workcenter_index", methods={"GET"}) |
|
57
|
|
|
* @Security("is_granted('USER_VISIT_TRACK', tutor)") |
|
58
|
|
|
*/ |
|
59
|
|
|
public function visitIndexAction(User $tutor) |
|
60
|
|
|
{ |
|
61
|
|
|
$workcenters = $this->getDoctrine()->getManager()->getRepository('AppBundle:Visit')->getRelatedVisits($tutor); |
|
62
|
|
|
|
|
63
|
|
|
$title = (string) $tutor; |
|
64
|
|
|
|
|
65
|
|
|
return $this->render('visit/visit_index.html.twig', [ |
|
66
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('visit_index'), |
|
67
|
|
|
'breadcrumb' => [ |
|
68
|
|
|
['fixed' => $title] |
|
69
|
|
|
], |
|
70
|
|
|
'title' => $this->get('translator')->trans('browse.workcenter', ['%user%' => $title], 'visit'), |
|
71
|
|
|
'tutor' => $tutor, |
|
72
|
|
|
'elements' => $workcenters, |
|
73
|
|
|
'back_route_name' => $this->isGranted('ROLE_DEPARTMENT_HEAD') ? 'visit_index' : 'frontpage' |
|
74
|
|
|
]); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @Route("/visitas/{id}/resumen", name="visit_workcenter_summary_index", methods={"GET"}) |
|
79
|
|
|
* @Security("is_granted('USER_VISIT_TRACK', tutor)") |
|
80
|
|
|
*/ |
|
81
|
|
|
public function visitWorkcenterSummaryAction(User $tutor) |
|
82
|
|
|
{ |
|
83
|
|
|
$workcenters = $this->getDoctrine()->getManager()->getRepository('AppBundle:Workcenter')->getVisitRelatedWorkcenters($tutor); |
|
84
|
|
|
|
|
85
|
|
|
$title = (string) $tutor; |
|
86
|
|
|
|
|
87
|
|
|
return $this->render('visit/workcenter_summary.html.twig', [ |
|
88
|
|
|
'menu_item' => $this->get('app.menu_builders_chain')->getMenuItemByRouteName('visit_index'), |
|
89
|
|
|
'breadcrumb' => [ |
|
90
|
|
|
['fixed' => $title, 'path' => 'visit_workcenter_index', 'options' => ['id' => $tutor->getId()]], |
|
91
|
|
|
['fixed' => $this->get('translator')->trans('browse.summary', [], 'visit')] |
|
92
|
|
|
], |
|
93
|
|
|
'title' => $this->get('translator')->trans('browse.workcenter', ['%user%' => $title], 'visit'), |
|
94
|
|
|
'tutor' => $tutor, |
|
95
|
|
|
'elements' => $workcenters, |
|
96
|
|
|
'back_route_name' => $this->isGranted('ROLE_DEPARTMENT_HEAD') ? 'visit_index' : 'frontpage' |
|
97
|
|
|
]); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|