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