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