1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cdf\BiCoreBundle\Utils\Tabella; |
4
|
|
|
|
5
|
|
|
use Cdf\BiCoreBundle\Utils\Entity\EntityUtils; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @property \Doctrine\ORM\EntityManager $em |
9
|
|
|
* @property \Cdf\BiCoreBundle\Utils\Permessi\PermessiUtils $permessi |
10
|
|
|
* @property \Symfony\Component\Security\Core\Security $user |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
15
|
|
|
*/ |
16
|
|
|
class Tabella |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
use TabellaQueryTrait, |
|
|
|
|
20
|
|
|
TabellaOpzioniTrait, |
21
|
|
|
TabellaDecoderTrait; |
22
|
|
|
|
23
|
|
|
protected $parametri; |
24
|
|
|
protected $colonnedatabase; |
25
|
|
|
protected $opzionitabellacore; |
26
|
|
|
protected $configurazionecolonnetabella; |
27
|
|
|
protected $entityname; |
28
|
|
|
protected $tablename; |
29
|
|
|
protected $modellocolonne; |
30
|
|
|
protected $paginacorrente; |
31
|
|
|
protected $righeperpagina; |
32
|
|
|
protected $estraituttirecords; |
33
|
|
|
protected $prefiltri; |
34
|
|
|
protected $filtri; |
35
|
|
|
protected $wheremanuale; |
36
|
|
|
protected $colonneordinamento; |
37
|
|
|
protected $permessi; |
38
|
|
|
protected $records; |
39
|
|
|
protected $paginetotali; |
40
|
|
|
protected $righetotali; |
41
|
|
|
protected $traduzionefiltri; |
42
|
|
|
protected $maxordine = 0; |
43
|
|
|
protected $em; |
44
|
|
|
protected $user; |
45
|
|
|
|
46
|
12 |
|
public function __construct($doctrine, $parametri = '{}') |
47
|
|
|
{ |
48
|
12 |
|
$this->parametri = $parametri; |
49
|
12 |
|
if (isset($this->parametri['em'])) { |
50
|
12 |
|
$this->em = $doctrine->getManager(ParametriTabella::getParameter($this->parametri['em'])); |
51
|
|
|
} else { |
52
|
|
|
$this->em = $doctrine->getManager(); |
53
|
|
|
} |
54
|
|
|
|
55
|
12 |
|
$this->tablename = $this->getTabellaParameter("tablename"); |
|
|
|
|
56
|
12 |
|
$this->entityname = $this->getTabellaParameter("entityclass"); |
|
|
|
|
57
|
12 |
|
$this->entityname = str_replace("FiBiCoreBundle", "BiCoreBundle", $this->entityname); |
|
|
|
|
58
|
12 |
|
$this->permessi = json_decode($this->getTabellaParameter("permessi")); |
|
|
|
|
59
|
12 |
|
$this->modellocolonne = json_decode($this->getTabellaParameter('modellocolonne', array()), true); |
|
|
|
|
60
|
12 |
|
$this->paginacorrente = $this->getTabellaParameter("paginacorrente"); |
|
|
|
|
61
|
12 |
|
$this->paginetotali = $this->getTabellaParameter("paginetotali"); |
|
|
|
|
62
|
12 |
|
$this->righeperpagina = $this->getTabellaParameter('righeperpagina', 15); |
63
|
|
|
|
64
|
12 |
|
$this->estraituttirecords = $this->getTabellaParameter('estraituttirecords', 0) === "1" ? true : false; |
|
|
|
|
65
|
12 |
|
$this->colonneordinamento = json_decode($this->getTabellaParameter('colonneordinamento', array()), true); |
66
|
12 |
|
$this->prefiltri = json_decode($this->getTabellaParameter('prefiltri', array()), true); |
|
|
|
|
67
|
12 |
|
$this->filtri = json_decode($this->getTabellaParameter('filtri', array()), true); |
|
|
|
|
68
|
12 |
|
$this->wheremanuale = $this->getTabellaParameter("wheremanuale", null); |
|
|
|
|
69
|
12 |
|
$this->user = $this->parametri["user"]; |
|
|
|
|
70
|
|
|
|
71
|
12 |
|
$utils = new EntityUtils($this->em, $this->entityname); |
|
|
|
|
72
|
12 |
|
$this->colonnedatabase = $utils->getEntityColumns($this->entityname); |
|
|
|
|
73
|
12 |
|
$this->opzionitabellacore = $this->getOpzionitabellaFromCore(); |
|
|
|
|
74
|
12 |
|
$this->configurazionecolonnetabella = $this->getAllOpzioniTabella(); |
75
|
12 |
|
} |
76
|
12 |
|
private function getTabellaParameter($name, $default = null) |
77
|
|
|
{ |
78
|
12 |
|
$risposta = null; |
79
|
12 |
|
if (isset($this->parametri[$name])) { |
80
|
12 |
|
$risposta = ParametriTabella::getParameter($this->parametri[$name]); |
81
|
|
|
} else { |
82
|
12 |
|
$risposta = $default; |
83
|
|
|
} |
84
|
12 |
|
return $risposta; |
85
|
|
|
} |
86
|
12 |
|
public function calcolaPagineTotali($limit) |
87
|
|
|
{ |
88
|
12 |
|
if ($this->righetotali == 0) { |
89
|
1 |
|
return 1; |
90
|
|
|
} |
91
|
|
|
/* calcola in mumero di pagine totali necessarie */ |
92
|
12 |
|
return ceil($this->righetotali / ($limit == 0 ? 1 : $limit)); |
93
|
|
|
} |
94
|
|
|
|
95
|
12 |
|
public function getPaginacorrente() |
96
|
|
|
{ |
97
|
12 |
|
return $this->paginacorrente; |
98
|
|
|
} |
99
|
7 |
|
public function getPaginetotali() |
100
|
|
|
{ |
101
|
7 |
|
return $this->paginetotali; |
102
|
|
|
} |
103
|
12 |
|
public function getRigheperpagina() |
104
|
|
|
{ |
105
|
12 |
|
return $this->righeperpagina; |
106
|
|
|
} |
107
|
12 |
|
public function getRighetotali() |
108
|
|
|
{ |
109
|
12 |
|
return $this->righetotali; |
110
|
|
|
} |
111
|
7 |
|
public function getTraduzionefiltri() |
112
|
|
|
{ |
113
|
7 |
|
return $this->traduzionefiltri; |
114
|
|
|
} |
115
|
10 |
|
public function getConfigurazionecolonnetabella() |
116
|
|
|
{ |
117
|
10 |
|
return $this->configurazionecolonnetabella; |
118
|
|
|
} |
119
|
12 |
|
protected function setMaxOrdine($ordinecorrente) |
120
|
|
|
{ |
121
|
12 |
|
if ($ordinecorrente > $this->maxordine) { |
122
|
12 |
|
$this->maxordine = $ordinecorrente; |
123
|
|
|
} |
124
|
12 |
|
} |
125
|
12 |
|
protected function getMaxOrdine() |
126
|
|
|
{ |
127
|
12 |
|
return $this->maxordine; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|