-
Notifications
You must be signed in to change notification settings - Fork 0
/
carregaAvisos.php
72 lines (55 loc) · 2.07 KB
/
carregaAvisos.php
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
<?php
include_once "conexao.php";
include_once "Usuario.php";
if(!isset($_SESSION)) session_start();
$conexao = conexao::getConexao();
if(!isset($_SESSION["usuario"])){
header("location: index.php");
}
$dados = $_SESSION["usuario"];
if(isset($_POST["min"])){
try{
$min = trim(addslashes($_POST["min"]));
$cod = $dados->getCodUsuario();
$comando = $conexao->prepare("SELECT id_aviso, titulo, situacao, data_envio FROM avisos WHERE id_usuario_avisos = :id ORDER BY id_aviso DESC LIMIT $min, 10");
$comando->bindParam(":id", $cod);
$comando->execute();
$dadoMsg = $comando->fetchAll();
$html = null;
if(count($dadoMsg) > 0){
$i = $min;
foreach($dadoMsg as $valor){
$id = htmlspecialchars($valor[0]);
$titulo = htmlspecialchars($valor[1]);
$situacao = (htmlspecialchars($valor[2]) == "V") ? "Visualizado" : "Não Visualizado";
$data = explode("-", htmlspecialchars($valor[3]));
$data = $data[2] . "/" . $data[1] . "/" . $data[0];
$html .= "<tr class='trMsg'>
<td onclick='carregaAvisoUser($id, $i)'>$data</td>
<td onclick='carregaAvisoUser($id, $i)'>$titulo</td>
<td id='situcaoMsg$i' onclick='carregaAvisoUser($id, $i)'>$situacao</td>
<td class='linhaOp'>
<i class='fas fa-eye' title='Visualizar' onclick='carregaAvisoUser($id, $i)'></i>
<i class='fas fa-trash-alt' title='Deletar' onclick='deletaAviso($id)'></i>
</td>
</tr>";
$i++;
}
if(count($dadoMsg) >= 10){
$html .= "<tr id='trMsgLoading'>
<td colspan='4'><button class='carregarMaisT' onclick='carregaAvisos(this)'><i class='fas fa-plus' title='Carregar Mais'></i></button></td>
</tr>";
}
}else{
$html = "<tr><td colspan='4'><h4>Você não tem nenhuma mensagem</h4></td></tr>";
}
echo $html;
}catch(Exeption $ex){
echo "<tr id='trMsgLoading'>
<td colspan='4'><button class='carregarMaisT' onclick='carregaAvisos(this)'><i class='fas fa-plus' title='Carregar Mais'></i></button></td>
</tr>";
}
}else{
header("location: Inicio.php");
}
?>