/
ajaxalterastatusregistro.php
66 lines (50 loc) · 1.09 KB
/
ajaxalterastatusregistro.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
<?php
//--utf8_encode --
session_start();
include_once "cls/conexao.class.php";
include_once 'inc/comuns.inc.php';
function Main()
{
try
{
$obj = new ReflectionClass("Comuns");
$tabela = $_POST['t'];
$tabela = $obj->getConstant($tabela);
$registro = base64_decode($_POST['r']);
$sql = "SELECT Ativo FROM " . $tabela . " WHERE Codigo = :pcod;";
$cnn = Conexao2::getInstance();
$q = $cnn->prepare($sql);
$q->bindParam(":pcod", $registro, PDO::PARAM_INT);
$q->execute();
$rs = $q->fetch(PDO::FETCH_OBJ);
if ($rs->Ativo == 1)
{
$status = 0;
}
else
{
$status = 1;
}
$q->closeCursor();
$sql = "UPDATE " . $tabela . " SET Ativo = :pnovo WHERE Codigo = :pcod;";
$q = $cnn->prepare($sql);
$q->bindParam(":pnovo", $status, PDO::PARAM_INT);
$q->bindParam(":pcod", $registro, PDO::PARAM_INT);
$q->execute();
echo($status);
}
catch (PDOException $ex)
{
echo($ex->getMessage());
}
}
if (Comuns::EstaLogado())
{
Main();
}
else
{
$msg = base64_encode("@lng[Você deve estar logado para acessar esta tela]");
header("Location:index.php?m=" . $msg);
}
?>