Skip to content

Commit 65f0326

Browse files
authored
Merge pull request #869 from portabilis/fallback
[2.7] Fallback para a página inicial
2 parents 83fbc75 + 4fa3e43 commit 65f0326

File tree

4 files changed

+320
-1
lines changed

4 files changed

+320
-1
lines changed

app/Http/Controllers/WebController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,13 @@ public function config(Repository $config)
2424
'footer' => $config->get('legacy.config.ieducar_internal_footer'),
2525
];
2626
}
27+
28+
public function fallback($uri)
29+
{
30+
if ($uri === 'web') {
31+
return redirect('intranet/home.php');
32+
}
33+
34+
return abort(404);
35+
}
2736
}

ieducar/intranet/home.php

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
<?php
2+
3+
use Illuminate\Http\Exceptions\HttpResponseException;
4+
use Illuminate\Http\RedirectResponse;
5+
6+
return new class {
7+
public function addLeadingZero($num)
8+
{
9+
if (is_numeric($num)) {
10+
if ($num < 10) {
11+
return '0' . $num;
12+
}
13+
14+
return $num;
15+
}
16+
17+
return 0;
18+
}
19+
20+
public function RenderHTML()
21+
{
22+
$id_pessoa = \Illuminate\Support\Facades\Auth::id();
23+
24+
if ($id_pessoa) {
25+
$endScript = '<script>var x = new Array();' . PHP_EOL;
26+
27+
$temp = '';
28+
29+
if (isset($_GET['negado'])) {
30+
$temp .= '<center><h3>Acesso negado para este usuário.</h3><br>Caso persista nas tentativas sua conta na intranet poderá ser bloqueada por tempo indeterminado.</center>';
31+
}
32+
33+
$pendencia_administrativa = dbBool(config('legacy.app.administrative_pending.exist'));
34+
$texto_pendencia = config('legacy.app.administrative_pending.msg');
35+
36+
if ($pendencia_administrativa) {
37+
echo '
38+
<script type="text/javascript" src="scripts/jquery/jquery-1.8.3.min.js"></script>
39+
<link rel="stylesheet" href="scripts/jquery/jquery-ui.min-1.9.2/css/custom/jquery-ui-1.9.2.custom.min.css">
40+
<script src="scripts/jquery/jquery-ui.min-1.9.2/js/jquery-ui-1.9.2.custom.min.js"></script>
41+
<div id="dialog" title="Aviso">
42+
'.$texto_pendencia.'
43+
</div>
44+
<script>
45+
var $j = jQuery.noConflict();
46+
47+
$j(function() {
48+
$j( "#dialog" ).dialog({
49+
width: 600,
50+
position: { my: "center", at: "top", of: window },
51+
buttons: [
52+
{
53+
text: "Entendi. Prosseguir utilizando o sistema.",
54+
click: function(){
55+
$j(this).dialog("close");
56+
}
57+
}
58+
]
59+
});
60+
61+
});
62+
</script>';
63+
}
64+
$temp .= '<table class=\'tablelistagem\' id=\'tableLocalizacao\'width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
65+
<tr height=\'10px\'>
66+
<td class=\'fundoLocalizacao\' colspan=\'2\'>
67+
<div id=\'localizacao\'>
68+
<a href=\'/intranet\' title=\'Ir para o início\'>
69+
<i class=\'fa fa-home\' aria-hidden=\'true\'></i>
70+
<span> Início</span>
71+
</a>
72+
<a class=\'flechinha\' href=\'#\'> / </a>
73+
<a href=\'#\' class=\'pagina_atual\'>Calendário</a>
74+
</div>
75+
</td>
76+
</tr>
77+
</table>';
78+
$temp .= '<table width="100%" height="400" align="center" border="0" cellspacing="4" cellpadding="0">';
79+
$temp .= '
80+
<tr>
81+
<td class="fundoCalendarioTopo" style="padding:0px;">DOM</td>
82+
<td class="fundoCalendarioTopo" style="padding:0px;">SEG</td>
83+
<td class="fundoCalendarioTopo" style="padding:0px;">TER</td>
84+
<td class="fundoCalendarioTopo" style="padding:0px;">QUA</td>
85+
<td class="fundoCalendarioTopo" style="padding:0px;">QUI</td>
86+
<td class="fundoCalendarioTopo" style="padding:0px;">SEX</td>
87+
<td class="fundoCalendarioTopo" style="padding:0px;">SAB</td>
88+
</tr>';
89+
90+
$mes = $_GET['mes'] ?? date('m');
91+
$ano = $_GET['ano'] ?? date('Y');
92+
93+
$temp_var = 0;
94+
95+
// Faz loop da quantidade de dias do Mês
96+
$max_comp_dia = 5;
97+
for ($i=1; $i <= date('t', mktime(0, 0, 0, $mes, 1, $ano)); $i++) {
98+
$qtd = 0;
99+
100+
$dataAtual = date('Y/m/d', mktime(0, 0, 0, $mes, $i, $ano));
101+
$dataAmanha = date('Y/m/d', mktime(0, 0, 0, $mes, $i + 1, $ano));
102+
$diaDaSemana = date('w', strtotime(substr($dataAtual, 0, 19)));
103+
104+
$compromisso_geral = '';
105+
106+
$data_array = explode('/', $dataAtual);
107+
$data_array = "{$data_array[2]}/{$data_array[1]}/{$data_array[0]}";
108+
109+
$db = new clsBanco();
110+
$db->Consulta("SELECT ref_cod_agenda FROM portal.agenda_responsavel WHERE ref_ref_cod_pessoa_fj = '{$id_pessoa}' AND principal = 1");
111+
112+
if ($db->ProximoRegistro()) {
113+
list($cod_agenda) = $db->Tupla();
114+
$obj_agenda = new clsAgenda($id_pessoa, false, $cod_agenda);
115+
} else {
116+
$obj_agenda = new clsAgenda($id_pessoa, $id_pessoa, false);
117+
$cod_agenda = $obj_agenda->getCodAgenda();
118+
}
119+
120+
$nomeAgenda = $obj_agenda->getNome();
121+
122+
$lista_compromissos = $obj_agenda->listaCompromissosDia($data_array);
123+
124+
if ($lista_compromissos) {
125+
foreach ($lista_compromissos as $compromisso) {
126+
if ($qtd < $max_comp_dia) {
127+
$disp_comp = $compromisso['descricao'];
128+
$titulo = $compromisso['titulo'];
129+
$qtd_tit_copia_desc = 5;
130+
131+
if ($titulo) {
132+
$disp_titulo = $titulo;
133+
} else {
134+
// se nao tiver titulo pega as X primeiras palavras da descricao
135+
// ( X = $qtd_tit_copia_desc )
136+
$disp_titulo = implode(' ', array_slice(
137+
explode(' ', $disp_comp),
138+
0,
139+
$qtd_tit_copia_desc
140+
));
141+
}
142+
143+
$disp_titulo = '- ' . $disp_titulo;
144+
145+
if (strlen($disp_titulo) > 15) {
146+
$disp_titulo = substr($disp_titulo, 0, 12) . '...';
147+
}
148+
149+
$temp_var++;
150+
$compromisso_geral .= "<span class='textoAgenda' id='comp_{$temp_var}'>$disp_titulo</span><br>";
151+
152+
if ($compromisso['importante'] && strtotime($compromisso['data_inicio']) > time()) {
153+
$endScript .= "x[{$temp_var}]= {$temp_var};";
154+
}
155+
}
156+
157+
$qtd++;
158+
}
159+
}
160+
161+
if ($compromisso_geral && $dataAtual > date('Y/m/d', time()) &&
162+
date('Y/m/d', strtotime(substr($dataAtual, 0, 19)) - 3 * 86400) >
163+
date('Y/m/d', time())) {
164+
$classe = 'fundoCalendarioLonge';
165+
} elseif ($compromisso_geral && $dataAtual > date('Y/m/d', time()) &&
166+
date('Y/m/d', strtotime(substr($dataAtual, 0, 19)) - 3 * 86400) <=
167+
date('Y/m/d', time())) {
168+
$classe = 'fundoCalendarioProximo';
169+
} elseif ($compromisso_geral && $dataAtual == date('Y/m/d', time())) {
170+
$classe = 'fundoCalendarioUrgente';
171+
} else {
172+
$classe = 'fundoCalendario';
173+
}
174+
175+
if ($qtd == 2) {
176+
$pulaLinha = '<br>';
177+
}
178+
179+
if ($qtd == 1) {
180+
$pulaLinha = '<br><br>';
181+
}
182+
183+
$data_temp = strtotime(substr($dataAtual, 0, 19));
184+
$compromisso_geral = ($compromisso_geral) ? "$compromisso_geral<a class='agenda-ver-todos' href='agenda.php?cod_agenda={$cod_agenda}&time=$data_temp' ><div align='center' class='textoAgenda'><b>Ver Todos</b></div>" : $compromisso_geral;
185+
186+
if ($i == 1) {
187+
$ultimoDiaUltimoMes = date('t', mktime(0, 0, 0, $mes - 1, 1, $ano));
188+
$temp .= '<tr>';
189+
for ($dias = 0; $dias < $diaDaSemana; $dias++) {
190+
$dia = $ultimoDiaUltimoMes - $diaDaSemana + 1 + $dias;
191+
$temp .= "<td class='fundoCalendarioMesDiferente' valign='top'><span class='diasMes'>$dia</span></td>";
192+
}
193+
194+
$temp .= "<td class='$classe' valign='top'><div class='dia_agenda'> " . $this->addLeadingZero($i) . " </div>$compromisso_geral</td>";
195+
} else {
196+
if ($diaDaSemana == 0) {
197+
$temp .= "</tr><tr><td class='$classe' valign='top'><div class='dia_agenda'> " . $this->addLeadingZero($i) . " </div>$compromisso_geral</td>";
198+
} else {
199+
$temp .= "<td class='$classe' valign='top'><div class='dia_agenda'> " . $this->addLeadingZero($i) . " </div>$compromisso_geral</td>";
200+
}
201+
}
202+
}
203+
204+
$endScript .= 'setInterval(\'pisca();\', 1000);';
205+
$dia = 1;
206+
207+
for ($i = $diaDaSemana; $i < 6; $i++) {
208+
$temp .= "<td class='fundoCalendarioMesDiferente' valign='top'><span class='diasMes'>$dia</span></td>";
209+
$dia++;
210+
}
211+
212+
$anterior = $mes - 1;
213+
$proximo = $mes + 1;
214+
215+
$proximo_ano = date('Y', mktime(0, 0, 0, $mes + 2, 0, $ano));
216+
$ano_anterior = date('Y', mktime(0, 0, 0, $mes, 0, $ano));
217+
218+
if ($proximo > 12) {
219+
$proximo = 1;
220+
}
221+
222+
if ($anterior < 1) {
223+
$anterior = 12;
224+
}
225+
226+
$endScript .= '
227+
var a = 0;
228+
function pisca()
229+
{
230+
for (var i = 1; i<x.length; i++) {
231+
if (typeof document.getElementById(\'comp_\' + x[i]) == \'object\') {
232+
obj = document.getElementById(\'comp_\' + x[i]);
233+
obj.className = (obj.className == \'textoAgenda\') ? \'textoAgendaVermelho\': \'textoAgenda\';
234+
}
235+
}
236+
a=1;
237+
}
238+
</script>';
239+
240+
$temp .= "</tr>
241+
<tr>
242+
<td colspan=\"6\" align=\"center\" class=\"fundoCalendarioTopo\">
243+
<a class=\"nav_agenda\" href='index.php?mes=$anterior&ano=$ano_anterior'>
244+
&laquo; Anterior
245+
</a> &nbsp;&nbsp;
246+
<a class=\"nav_agenda\" href='index.php?mes=$proximo&ano=$proximo_ano'>
247+
Próximo &raquo;
248+
</a>
249+
</td>
250+
<td align=center class='fundoCalendarioTopo'>$mes/$ano</td>
251+
</tr>
252+
<tr>
253+
<td colspan=\"7\" class=\"fundoCalendario\" style=\"height:15px; background-color: #fff;\"><h3 style=\"padding-top:2px;margin:0px\">Agenda do(a): <a href=\"agenda.php?cod_agenda={$cod_agenda}\">$nomeAgenda</a></h3></td>
254+
</tr>
255+
</table>{$endScript}";
256+
257+
return $temp;
258+
} else {
259+
throw new HttpResponseException(
260+
new RedirectResponse('logof.php?login=1')
261+
);
262+
}
263+
}
264+
public function mostraModalPesquisa($municipio, $linkPesquisa)
265+
{
266+
return '<script type="text/javascript" src="scripts/jquery/jquery-1.8.3.min.js"></script>
267+
<link rel="stylesheet" href="scripts/jquery/jquery-ui.min-1.9.2/css/custom/jquery-ui-1.9.2.custom.min.css">
268+
<script src="scripts/jquery/jquery-ui.min-1.9.2/js/jquery-ui-1.9.2.custom.min.js"></script>
269+
<div id="dialog" title="Pesquisa de satisfação">
270+
<p>Caro usuário(a), a Secretaria Mun. de Educação e a Portabilis Tecnologia, convidam você a responder a uma pesquisa de satisfação referente ao projeto de modernização da gestão escolar com o i-Educar em ' . $municipio . '.</p>
271+
<br/>
272+
<p><i>Você precisará de apenas 5 minutos para responder a pesquisa. :)</i></p>
273+
<br/>
274+
<p><b> Contamos com você! :)</b></p>
275+
</div>
276+
<script>
277+
var $j = jQuery.noConflict();
278+
279+
$j(function() {
280+
$j( "#dialog" ).dialog({
281+
width: 600,
282+
position: { my: "center", at: "top", of: window },
283+
buttons: [
284+
{
285+
text: "Participar da pesquisa",
286+
click: function(){
287+
window.open(' . '"' . $linkPesquisa . '"' . ' , "_blank");
288+
$j(this).dialog("close");
289+
}
290+
},
291+
{
292+
text: "N\u00e3o, obrigado",
293+
click: function(){
294+
$j(this).dialog("close");
295+
}
296+
}
297+
]
298+
});
299+
});
300+
</script>';
301+
}
302+
303+
public function Formular()
304+
{
305+
$this->titulo = 'Calendário';
306+
$this->processoAp = 0;
307+
}
308+
};

routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
->name('schoolclass.store');
150150
Route::delete('/turma', [SchoolClassController::class, 'delete'])
151151
->name('schoolclass.delete');
152+
153+
Route::fallback([WebController::class, 'fallback']);
152154
});
153155

154156
Route::group(['namespace' => 'Exports', 'prefix' => 'exports'], function () {

tests/Unit/Modules/FormulaMedia/Model/FormulaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testExecFormulaMediaMethod()
101101
]);
102102

103103
$this->assertEquals(8, $average);
104-
$this->assertEquals(5.8, $recuperation);
104+
$this->assertEqualsWithDelta(5.8, $recuperation, 0.00001); # TODO entender o motivo de ser necessário
105105
}
106106

107107
/**

0 commit comments

Comments
 (0)