educar_consulta_movimento_geral_lst.php
9.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
use iEducar\Modules\Reports\QueryFactory\MovimentoGeralQueryFactory;
require_once 'include/clsBase.inc.php';
require_once 'include/clsBanco.inc.php';
require_once 'include/clsListagem.inc.php';
require_once 'lib/Portabilis/Date/Utils.php';
require_once 'Portabilis/View/Helper/Application.php';
class clsIndex extends clsBase
{
public function Formular()
{
$this->SetTitulo($this->_instituicao . ' i-Educar - Consulta de movimento geral');
$this->processoAp = 9998900;
}
}
class indice extends clsListagem
{
public function Gerar()
{
$params = [];
$params['ano'] = $this->getQueryString('ano');
$params['curso'] = $this->getQueryString('curso');
$params['data_inicial'] = $this->getQueryString('data_inicial');
$params['data_final'] = $this->getQueryString('data_final');
$this->breadcrumb('Consulta de movimento geral', ['educar_index.php' => 'Escola']);
$required = [
'ano',
'data_inicial',
'data_final'
];
foreach ($required as $req) {
if (empty($params[$req])) {
$this->simpleRedirect('/intranet/educar_index.php');
}
}
$params['data_inicial'] = Portabilis_Date_Utils::brToPgSQL($params['data_inicial']);
$params['data_final'] = Portabilis_Date_Utils::brToPgSQL($params['data_final']);
$params['seleciona_curso'] = empty($params['curso']) ? 0 : 1;
$base = new clsBanco();
$base->FraseConexao();
$connectionString = 'pgsql:' . $base->getFraseConexao();
$data = (new MovimentoGeralQueryFactory(new \PDO($connectionString), $params))
->getData();
$this->titulo = 'Parâmetros';
$this->acao = 'go("/intranet/educar_consulta_movimento_geral.php")';
$this->nome_acao = "Nova consulta";
$cursos = [];
if (empty($params['curso'])) {
$cursos[] = 'Todos';
} else {
$cursoIds = join(', ', $params['curso']);
$dadosCursos = (array)Portabilis_Utils_Database::fetchPreparedQuery(
"select nm_curso from pmieducar.curso where cod_curso in ({$cursoIds});"
);
foreach ($dadosCursos as $curso) {
$cursos[] = $curso['nm_curso'];
}
}
$this->addCabecalhos([
'Ano',
'Cursos',
'Data inicial',
'Data final'
]);
$this->addLinhas([
filter_var($params['ano'], FILTER_SANITIZE_STRING),
join('<br>', $cursos),
filter_var($this->getQueryString('data_inicial'), FILTER_SANITIZE_STRING),
filter_var($this->getQueryString('data_final'), FILTER_SANITIZE_STRING)
]);
$params['curso'] = empty($params['curso']) ? '' : join(',', $params['curso']);
$linkTemplate = '<a href="#" class="mostra-consulta" style="font-weight: bold;" data-api="ConsultaMovimentoGeral" data-params=\'%s\' data-tipo="%s">%d</a>';
foreach ($data as $key => $value) {
foreach ($value as $k => $v) {
switch ($k) {
case 'cod_escola':
case 'escola':
case 'ciclo':
case 'aee':
case 'localizacao':
continue;
break;
default:
$paramsCopy = $params;
$paramsCopy['escola'] = $value['cod_escola'];
$paramsCopy = json_encode($paramsCopy);
$data[$key][$k] = sprintf($linkTemplate, $paramsCopy, $k, $v);
}
}
}
$data = json_encode($data);
$tableScript = <<<JS
(function () {
let paramsTable = document.querySelectorAll('#form_resultado .tablelistagem')[0];
paramsTable.setAttribute('style', 'width: 100%;');
let data = {$data};
let table = [];
table.push('<table class="tablelistagem" style="width: 100%; margin-bottom: 100px;" cellspacing="1" cellpadding="4" border="0">');
table.push('<tr>');
table.push('<td class="titulo-tabela-listagem" colspan="19">Resultados</td>');
table.push('</tr>');
table.push('<tr>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Escola</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Ed. Inf. Integ.</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Ed. Inf. Parc..</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">1° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">2° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">3° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">4° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">5° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">6° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">7° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">8° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">9° Ano</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" colspan="3">Eliminados</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Rem.</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Recla.</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Óbito</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;" rowspan="2">Localização</td>');
table.push('</tr>');
table.push('<tr>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;">AD</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;">AB</td>');
table.push('<td class="formdktd" style="font-weight: bold; text-align: center;">TR</td>');
table.push('</tr>');
for (let i = 0; i < data.length; i++) {
let item = data[i];
let cellClass = ((i % 2) === 0) ? 'formlttd' : 'formmdtd';
table.push('<tr>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.escola + ' ' + item.ciclo + item.aee + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ed_inf_int + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ed_inf_parc + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_1 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_2 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_3 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_4 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_5 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_6 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_7 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_8 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.ano_9 + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.admitidos + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.aband + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.transf + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.rem + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.recla + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.obito + '</td>');
table.push('<td class="' + cellClass + '" valign="top" align="left">' + item.localizacao + '</td>');
table.push('</tr>');
}
table.push('<tr>');
table.push('<td class="formmttd" valign="top" align="left" colspan="19"><strong>Legenda</strong><br>* Escola possui AEE<br>** Escola possui regime por ciclo<br>*** Escola possui regime por ciclo e AEE</td>');
table.push('</tr>');
table.push('</table>');
let base = document.querySelectorAll('#corpo')[0];
let wrapper= document.createElement('div');
wrapper.innerHTML = table.join('');
let tableObj = wrapper.firstChild;
base.appendChild(tableObj);
})();
JS;
Portabilis_View_Helper_Application::embedJavascript($this, $tableScript, false);
Portabilis_View_Helper_Application::loadJavascript($this, ['/intranet/scripts/consulta_movimentos.js']);
}
}
$pagina = new clsIndex();
$miolo = new indice();
$pagina->addForm($miolo);
$pagina->MakeAll();