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
|
2 |
|
public function indexAction(Request $request) |
14
|
|
|
{ |
15
|
|
|
|
16
|
2 |
|
$this->setup($request); |
17
|
2 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
18
|
2 |
|
$bundle = $this->getBundle(); |
|
|
|
|
19
|
2 |
|
$controller = $this->getController(); |
20
|
2 |
|
$container = $this->container; |
|
|
|
|
21
|
|
|
|
22
|
2 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
23
|
|
|
|
24
|
2 |
|
$ffprincipaleSelect = $this->getComboSelectFfprincipale(); |
25
|
|
|
|
26
|
|
|
$dettaglij = array( |
27
|
2 |
|
'descsec' => array( |
28
|
|
|
array('nomecampo' => 'descsec', |
29
|
|
|
'lunghezza' => '400', |
30
|
|
|
'descrizione' => 'Descrizione tabella secondaria', |
31
|
|
|
'tipo' => 'text',),), |
32
|
|
|
'ffprincipale_id' => array( |
33
|
2 |
|
array('nomecampo' => 'ffprincipale.descrizione', |
34
|
2 |
|
'lunghezza' => '400', |
35
|
2 |
|
'descrizione' => 'Descrizione record principale', |
36
|
2 |
|
'tipo' => 'select', |
37
|
2 |
|
'valoricombo' => $ffprincipaleSelect |
38
|
|
|
), |
39
|
|
|
), |
40
|
|
|
); |
41
|
2 |
|
$escludi = array('nota'); |
|
|
|
|
42
|
|
|
|
43
|
|
|
$campiextra = array( |
44
|
2 |
|
array('nomecampo' => 'lunghezzanota', 'descrizione' => 'Lunghezza Nota', 'tipo' => 'integer'), |
45
|
|
|
array('nomecampo' => 'attivoToString', 'lunghezza' => '80', 'descrizione' => 'Attivo string', 'tipo' => 'text'), |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
$paricevuti = array( |
49
|
2 |
|
'nomebundle' => $nomebundle, |
50
|
2 |
|
'nometabella' => $controller, |
51
|
2 |
|
'dettaglij' => $dettaglij, |
52
|
2 |
|
'campiextra' => $campiextra, |
53
|
2 |
|
'escludere' => $escludi, |
54
|
2 |
|
'container' => $container, |
55
|
|
|
/* "ordinecolonne" => array("ffprincipale_id", "descsec", "importo", "intero") */ ); |
|
|
|
|
56
|
|
|
|
57
|
2 |
|
$griglia = $this->get("ficorebundle.griglia"); |
|
|
|
|
58
|
2 |
|
$testatagriglia = $griglia->testataPerGriglia($paricevuti); |
59
|
|
|
|
60
|
2 |
|
$this->setDefaultGridSettings($testatagriglia); |
61
|
|
|
|
62
|
2 |
|
$testatagriglia['parametritesta'] = json_encode($paricevuti); |
63
|
2 |
|
$this->setParametriGriglia(array('request' => $request)); |
64
|
2 |
|
$testatagriglia['parametrigriglia'] = json_encode(self::$parametrigriglia); |
65
|
|
|
|
66
|
2 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
|
|
|
|
67
|
2 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
|
|
|
|
68
|
|
|
|
69
|
2 |
|
$testata = json_encode($testatagriglia); |
|
|
|
|
70
|
|
|
$twigparms = array( |
71
|
2 |
|
'nomecontroller' => $controller, |
72
|
2 |
|
'testata' => $testata, |
73
|
2 |
|
'canread' => $canRead, |
74
|
|
|
); |
75
|
|
|
|
76
|
2 |
|
if (!$canRead) { |
77
|
|
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
|
|
|
|
78
|
|
|
} else { |
79
|
2 |
|
return $this->render($nomebundle . ':' . $controller . ':index.html.twig', $twigparms); |
80
|
|
|
} |
81
|
|
|
} |
82
|
2 |
|
private function setDefaultGridSettings(&$testatagriglia) |
83
|
|
|
{ |
84
|
2 |
|
$testatagriglia['multisearch'] = 1; |
85
|
2 |
|
$testatagriglia['showconfig'] = 1; |
|
|
|
|
86
|
2 |
|
$testatagriglia['showadd'] = 1; |
|
|
|
|
87
|
2 |
|
$testatagriglia['showedit'] = 1; |
|
|
|
|
88
|
2 |
|
$testatagriglia['showdel'] = 1; |
|
|
|
|
89
|
|
|
|
90
|
2 |
|
$testatagriglia['showexcel'] = 1; |
91
|
|
|
|
92
|
2 |
|
$testatagriglia["filterToolbar_searchOnEnter"] = true; |
|
|
|
|
93
|
2 |
|
$testatagriglia["filterToolbar_searchOperators"] = true; |
|
|
|
|
94
|
2 |
|
$testatagriglia["sortname"] = "data, descsec"; |
|
|
|
|
95
|
2 |
|
$testatagriglia["sortorder"] = "desc"; |
|
|
|
|
96
|
2 |
|
} |
97
|
2 |
|
private function getComboSelectFfprincipale() |
98
|
|
|
{ |
99
|
2 |
|
$em = $this->getDoctrine()->getManager(); |
|
|
|
|
100
|
2 |
|
$ffprincipaleSelect = array(); |
101
|
|
|
//Imposta il filtro a TUTTI come default |
102
|
2 |
|
$ffprincipaleSelect[] = array("valore" => "", "descrizione" => "Tutti", "default" => true); |
|
|
|
|
103
|
|
|
|
104
|
2 |
|
$q = $em->createQueryBuilder(); |
105
|
|
|
|
106
|
2 |
|
$ffprincipales = $q->select('f') |
107
|
2 |
|
->from('FiCoreBundle:Ffprincipale', 'f') |
108
|
2 |
|
->orderBy('f.descrizione') |
109
|
2 |
|
->getQuery() |
110
|
2 |
|
->getResult(); |
111
|
|
|
|
112
|
2 |
|
foreach ($ffprincipales as $ffprincipale) { |
113
|
2 |
|
$ffprincipaleSelect[] = array( |
114
|
2 |
|
"valore" => $ffprincipale->getDescrizione(), |
|
|
|
|
115
|
2 |
|
"descrizione" => $ffprincipale->getDescrizione(), |
|
|
|
|
116
|
|
|
"default" => false); |
|
|
|
|
117
|
|
|
} |
118
|
2 |
|
return $ffprincipaleSelect; |
119
|
|
|
} |
120
|
7 |
|
public function setParametriGriglia($prepar = array()) |
121
|
|
|
{ |
122
|
7 |
|
$this->setup($prepar['request']); |
123
|
7 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
124
|
7 |
|
$bundle = $this->getBundle(); |
|
|
|
|
125
|
7 |
|
$controller = $this->getController(); |
126
|
|
|
|
127
|
7 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
|
|
|
|
128
|
7 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
|
|
|
|
129
|
7 |
|
if (!$canRead) { |
130
|
1 |
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
6 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
|
|
|
|
134
|
6 |
|
$escludi = array('nota', 'ffprincipale'); |
|
|
|
|
135
|
6 |
|
$tabellej = array(); |
|
|
|
|
136
|
6 |
|
$precondizioniAvanzate = array(); |
|
|
|
|
137
|
6 |
|
$tabellej['ffprincipale_id'] = array('tabella' => 'ffprincipale', 'campi' => array('descrizione')); |
138
|
|
|
|
139
|
6 |
|
$campiextra = array(array('lunghezzanota'), array('attivoToString')); |
140
|
|
|
|
141
|
|
|
/* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
|
|
|
142
|
|
|
'nomecampo' => 'intero', |
143
|
|
|
'operatore' => '>=', |
144
|
|
|
'valorecampo' => 1, |
145
|
|
|
'operatorelogico' => 'OR'); */ |
146
|
|
|
|
147
|
|
|
//$precondizioni = array('ffprincipale_id' => '1'); |
|
|
|
|
148
|
6 |
|
$precondizioni = array(); |
|
|
|
|
149
|
6 |
|
$precondizioniAvanzate = array(); |
150
|
|
|
|
151
|
|
|
/* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
|
|
|
152
|
|
|
'nomecampo' => 'descsec', |
153
|
|
|
'operatore' => 'is', //'operatore' => 'not in' |
154
|
|
|
'valorecampo' => null); */ |
155
|
|
|
|
156
|
6 |
|
$precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
157
|
|
|
'nomecampo' => 'descsec', |
158
|
|
|
'operatore' => 'is not', //'operatore' => 'not in' |
159
|
|
|
'valorecampo' => null); |
160
|
|
|
|
161
|
|
|
/* $listaffsecondaria = array(); |
|
|
|
|
162
|
|
|
$listaffsecondaria[] = "1° secondaria legato al 1° record PRINCIPALE"; |
163
|
|
|
$listaffsecondaria[] = "2° SECONDARIA legato al 1° record principale"; |
164
|
|
|
$listaffsecondaria[] = "10° secondaria legato al 2° record principale ed è l'ultimo record"; |
165
|
|
|
$listaffsecondaria[] = "6° secondaria legato al 2° record principale"; |
166
|
|
|
$precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
167
|
|
|
'nomecampo' => 'descsec', |
168
|
|
|
'operatore' => 'in', //'operatore' => 'not in' |
169
|
|
|
'valorecampo' => $listaffsecondaria); */ |
170
|
|
|
|
171
|
|
|
/* $listaffsecondaria = array(); |
|
|
|
|
172
|
|
|
$listaffsecondaria[] = "1° secondaria legato al 1° record PRINCIPALE"; |
173
|
|
|
$listaffsecondaria[] = "2° SECONDARIA legato al 1° record principale"; |
174
|
|
|
$listaffsecondaria[] = "10° secondaria legato al 2° record principale ed è l'ultimo record"; |
175
|
|
|
$listaffsecondaria[] = "6° secondaria legato al 2° record principale"; |
176
|
|
|
$precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
177
|
|
|
'nomecampo' => 'descsec', |
178
|
|
|
'operatore' => 'not in', //'operatore' => 'not in' |
179
|
|
|
'valorecampo' => $listaffsecondaria); */ |
180
|
|
|
|
181
|
|
|
/* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
|
|
|
182
|
|
|
'nomecampo' => 'intero', |
183
|
|
|
'operatore' => '=', |
184
|
|
|
'valorecampo' => 1, |
185
|
|
|
'operatorelogico' => 'OR',); */ |
186
|
|
|
|
187
|
|
|
/* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
|
|
|
188
|
|
|
'nomecampo' => 'intero', |
189
|
|
|
'operatore' => '<', |
190
|
|
|
'valorecampo' => 100, |
191
|
|
|
'operatorelogico' => 'OR',); */ |
192
|
|
|
|
193
|
|
|
/* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
|
|
|
|
194
|
|
|
'nomecampo' => 'data', |
195
|
|
|
'operatore' => '<=', |
196
|
|
|
'valorecampo' => date('Y-m-d'), |
197
|
|
|
'operatorelogico' => 'AND',); */ |
198
|
|
|
|
199
|
|
|
|
200
|
|
|
// $lista[] = '1° secondaria legato al 1° record principale'; |
|
|
|
|
201
|
|
|
// $lista[] = '2° secondaria legato al 1° record principale'; |
202
|
|
|
// $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria', |
203
|
|
|
// 'nomecampo' => 'descsec', |
204
|
|
|
// 'operatore' => 'in', |
205
|
|
|
// 'valorecampo' => $lista, |
206
|
|
|
// 'operatorelogico' => 'AND',); |
207
|
|
|
|
208
|
|
|
|
209
|
6 |
|
$paricevuti = array('container' => $this->container, |
210
|
6 |
|
'nomebundle' => $nomebundle, |
211
|
6 |
|
'tabellej' => $tabellej, |
212
|
6 |
|
'nometabella' => $controller, |
213
|
6 |
|
'campiextra' => $campiextra, |
214
|
6 |
|
'escludere' => $escludi, |
215
|
6 |
|
'precondizioni' => $precondizioni, |
216
|
6 |
|
'precondizioniAvanzate' => $precondizioniAvanzate, |
217
|
|
|
/* "ordinecolonne" => array("ffprincipale_id", "descsec", "importo", "intero") */ |
|
|
|
|
218
|
|
|
); |
219
|
|
|
|
220
|
6 |
|
if (!empty($prepar)) { |
221
|
6 |
|
$paricevuti = array_merge($paricevuti, $prepar); |
222
|
|
|
} |
223
|
|
|
|
224
|
6 |
|
self::$parametrigriglia = $paricevuti; |
225
|
6 |
|
} |
226
|
|
|
} |
227
|
|
|
|
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.