|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
6
|
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Ffsecondaria controller. |
|
10
|
|
|
*/ |
|
11
|
|
|
class FfsecondariaController extends FiCoreController |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
1 |
|
public function indexAction(Request $request) |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
1 |
|
$this->setup($request); |
|
18
|
1 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
|
|
19
|
1 |
|
$bundle = $this->getBundle(); |
|
|
|
|
|
|
20
|
1 |
|
$controller = $this->getController(); |
|
21
|
1 |
|
$container = $this->container; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
1 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
|
|
|
|
|
|
24
|
1 |
|
$ffprincipaleSelect = array(); |
|
25
|
|
|
//Imposta il filtro a TUTTI come default |
|
26
|
1 |
|
$ffprincipaleSelect[] = array("valore" => "", "descrizione" => "Tutti", "default" => true); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
1 |
|
$em = $this->getDoctrine()->getManager(); |
|
29
|
|
|
|
|
30
|
1 |
|
$q = $em->createQueryBuilder(); |
|
31
|
|
|
|
|
32
|
1 |
|
$ffprincipales = $q->select('f') |
|
33
|
1 |
|
->from($nomebundle . ':Ffprincipale', 'f') |
|
34
|
1 |
|
->orderBy('f.descrizione') |
|
35
|
1 |
|
->getQuery() |
|
36
|
1 |
|
->getResult(); |
|
37
|
|
|
|
|
38
|
1 |
|
foreach ($ffprincipales as $ffprincipale) { |
|
39
|
1 |
|
$ffprincipaleSelect[] = array( |
|
40
|
1 |
|
"valore" => $ffprincipale->getDescrizione(), |
|
|
|
|
|
|
41
|
1 |
|
"descrizione" => $ffprincipale->getDescrizione(), |
|
|
|
|
|
|
42
|
1 |
|
"default" => false); |
|
|
|
|
|
|
43
|
1 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
$dettaglij = array( |
|
46
|
|
|
'descsec' => array( |
|
47
|
1 |
|
array('nomecampo' => 'descsec', |
|
48
|
1 |
|
'lunghezza' => '400', |
|
49
|
1 |
|
'descrizione' => 'Descrizione tabella secondaria', |
|
50
|
1 |
|
'tipo' => 'text',),), |
|
51
|
|
|
'ffprincipale_id' => array( |
|
52
|
1 |
|
array('nomecampo' => 'ffprincipale.descrizione', |
|
53
|
1 |
|
'lunghezza' => '400', |
|
54
|
1 |
|
'descrizione' => 'Descrizione record principale', |
|
55
|
1 |
|
'tipo' => 'select', |
|
56
|
|
|
'valoricombo' => $ffprincipaleSelect |
|
57
|
1 |
|
), |
|
58
|
1 |
|
), |
|
59
|
1 |
|
); |
|
60
|
1 |
|
$escludi = array('nota'); |
|
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
$campiextra = array( |
|
63
|
1 |
|
array('nomecampo' => 'lunghezzanota', 'descrizione' => 'Lunghezza Nota', 'tipo' => 'integer'), |
|
64
|
1 |
|
array('nomecampo' => 'attivoToString', 'lunghezza' => '80', 'descrizione' => 'Attivo string', 'tipo' => 'text'), |
|
65
|
1 |
|
); |
|
66
|
|
|
|
|
67
|
|
|
$paricevuti = array( |
|
68
|
1 |
|
'nomebundle' => $nomebundle, |
|
69
|
1 |
|
'nometabella' => $controller, |
|
70
|
1 |
|
'dettaglij' => $dettaglij, |
|
71
|
1 |
|
'campiextra' => $campiextra, |
|
72
|
1 |
|
'escludere' => $escludi, |
|
73
|
1 |
|
'container' => $container,); |
|
74
|
|
|
|
|
75
|
1 |
|
$testatagriglia = Griglia::testataPerGriglia($paricevuti); |
|
76
|
|
|
|
|
77
|
1 |
|
$testatagriglia['multisearch'] = 1; |
|
78
|
1 |
|
$testatagriglia['showconfig'] = 1; |
|
|
|
|
|
|
79
|
1 |
|
$testatagriglia['showadd'] = 1; |
|
|
|
|
|
|
80
|
1 |
|
$testatagriglia['showedit'] = 1; |
|
|
|
|
|
|
81
|
1 |
|
$testatagriglia['showdel'] = 1; |
|
|
|
|
|
|
82
|
|
|
|
|
83
|
1 |
|
$testatagriglia['showexcel'] = 1; |
|
|
|
|
|
|
84
|
1 |
|
$testatagriglia['showimportexcel'] = 1; |
|
85
|
|
|
|
|
86
|
1 |
|
$testatagriglia["filterToolbar_searchOnEnter"] = true; |
|
|
|
|
|
|
87
|
1 |
|
$testatagriglia["filterToolbar_searchOperators"] = true; |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
1 |
|
$testatagriglia['parametritesta'] = json_encode($paricevuti); |
|
90
|
1 |
|
$this->setParametriGriglia(array('request' => $request)); |
|
91
|
1 |
|
$testatagriglia['parametrigriglia'] = json_encode(self::$parametrigriglia); |
|
92
|
|
|
|
|
93
|
1 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
|
|
|
|
|
|
94
|
1 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
|
|
|
|
|
|
95
|
|
|
|
|
96
|
1 |
|
$testata = json_encode($testatagriglia); |
|
|
|
|
|
|
97
|
|
|
$twigparms = array( |
|
98
|
1 |
|
'nomecontroller' => $controller, |
|
99
|
1 |
|
'testata' => $testata, |
|
100
|
1 |
|
'canread' => $canRead, |
|
101
|
1 |
|
); |
|
102
|
|
|
|
|
103
|
1 |
|
if (!$canRead) { |
|
104
|
|
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
|
|
|
|
|
|
105
|
|
|
} else { |
|
106
|
1 |
|
return $this->render($nomebundle . ':' . $controller . ':index.html.twig', $twigparms); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
4 |
|
public function setParametriGriglia($prepar = array()) |
|
111
|
|
|
{ |
|
112
|
4 |
|
$this->setup($prepar['request']); |
|
113
|
4 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
|
|
114
|
4 |
|
$bundle = $this->getBundle(); |
|
|
|
|
|
|
115
|
4 |
|
$controller = $this->getController(); |
|
116
|
|
|
|
|
117
|
4 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
|
|
|
|
|
|
118
|
4 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
|
|
|
|
|
|
119
|
4 |
|
if (!$canRead) { |
|
120
|
1 |
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
|
|
|
|
|
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
3 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
|
|
|
|
|
|
124
|
3 |
|
$escludi = array('nota', 'ffprincipale'); |
|
|
|
|
|
|
125
|
3 |
|
$tabellej = array(); |
|
|
|
|
|
|
126
|
3 |
|
$precondizioniAvanzate = array(); |
|
|
|
|
|
|
127
|
3 |
|
$tabellej['ffprincipale_id'] = array('tabella' => 'ffprincipale', 'campi' => array('descrizione')); |
|
128
|
|
|
|
|
129
|
3 |
|
$campiextra = array(array('lunghezzanota'), array('attivoToString')); |
|
130
|
|
|
|
|
131
|
3 |
|
$precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
132
|
3 |
|
'nomecampo' => 'intero', |
|
133
|
3 |
|
'operatore' => '>=', |
|
134
|
3 |
|
'valorecampo' => 1,); |
|
135
|
3 |
|
$precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
136
|
3 |
|
'nomecampo' => 'data', |
|
137
|
3 |
|
'operatore' => '<=', |
|
138
|
3 |
|
'valorecampo' => date('Y-m-d'), |
|
139
|
3 |
|
'operatorelogico' => 'AND',); |
|
140
|
|
|
|
|
141
|
3 |
|
$paricevuti = array('container' => $this->container, |
|
142
|
3 |
|
'nomebundle' => $nomebundle, |
|
143
|
3 |
|
'tabellej' => $tabellej, |
|
144
|
3 |
|
'nometabella' => $controller, |
|
145
|
3 |
|
'campiextra' => $campiextra, |
|
146
|
3 |
|
'escludere' => $escludi, |
|
147
|
3 |
|
'precondizioniAvanzate' => $precondizioniAvanzate,); |
|
148
|
|
|
|
|
149
|
3 |
|
if (!empty($prepar)) { |
|
150
|
3 |
|
$paricevuti = array_merge($paricevuti, $prepar); |
|
151
|
3 |
|
} |
|
152
|
|
|
|
|
153
|
3 |
|
self::$parametrigriglia = $paricevuti; |
|
154
|
3 |
|
} |
|
155
|
|
|
} |
|
156
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.