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