DefaultController::entrarAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
/*
3
  GESTCONV - Aplicación web para la gestión de la convivencia en centros educativos
4
5
  Copyright (C) 2015: 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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
24
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
25
26
class DefaultController extends Controller
27
{
28
    /**
29
     * @Route("/portada", name="portada",methods={"GET"})
30
     */
31 1
    public function indexAction()
32
    {
33
        $usuario = $this->getUser();
34
        $em = $this->getDoctrine()->getManager();
35
36
37
        $partesPendientes = $em->getRepository('AppBundle:Parte')
38
            ->countNoNotificados();
39
40
        $partesPendientesPropios = $em->getRepository('AppBundle:Parte')
41
            ->countNoNotificadosPorUsuario($usuario);
42
43
        $partesPendientesPropiosYTutoria = $em->getRepository('AppBundle:Parte')
44
            ->countNoNotificadosPorUsuarioOTutoria($usuario);
45
46
        if (true === $this->isGranted('ROLE_REVISOR')) {
47
48
            $partesTotales = $em->getRepository('AppBundle:Parte')->countAll();
49
50
            $partesSancionables = $em->getRepository('AppBundle:Parte')
51
                ->countSancionables();
52
53
            $partesSancionablesPrioritarios = $em->getRepository('AppBundle:Parte')
54
                ->countSancionablesPrioritarios();
55
56
            $sancionesNotificables = $em->getRepository('AppBundle:Sancion')
57
                ->countAlumnosNoNotificados();
58
59
            $sancionesTotales = $em->getRepository('AppBundle:Sancion')
60
                ->countAll();
61
        }
62
        else {
63
            $partesTotales = $em->getRepository('AppBundle:Parte')
64
                ->countPorUsuarioOTutoria($usuario);
65
66
            $partesSancionables = 0;
67
            $partesSancionablesPrioritarios = 0;
68
            $sancionesNotificables = $em->getRepository('AppBundle:Sancion')
69
                ->countNoNotificadosPorTutoria($usuario);
70 1
            $sancionesTotales = 0;
71
        }
72
73
        return $this->render('AppBundle:App:portada.html.twig', array(
74
            'cuenta' => array(
75
                'partes_pendientes' => $partesPendientes,
76
                'partes_pendientes_propios_y_tutoria' => $partesPendientesPropiosYTutoria,
77
                'partes_totales' => $partesTotales,
78
                'partes_pendientes_propios' => $partesPendientesPropios,
79
                'partes_sancionables' => $partesSancionables,
80
                'partes_sancionables_prioritarios' => $partesSancionablesPrioritarios
81
            ),
82
            'sanciones_notificables' => $sancionesNotificables,
83
            'sanciones_totales' => $sancionesTotales
84
        ));
85
    }
86
87
    /**
88
     * @Route("/entrar", name="usuario_entrar",methods={"GET"})
89
     */
90 1
    public function entrarAction()
91
    {
92 1
        $helper = $this->get('security.authentication_utils');
93
94 1
        return $this->render('AppBundle:App:entrada.html.twig',
95
            array(
96 1
                'last_username' => $helper->getLastUsername(),
97 1
                'error'         => $helper->getLastAuthenticationError()
98 1
            ));
99
    }
100
101
}
102