forked from rafajefer/marketing-multinivel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
111 lines (101 loc) · 3.81 KB
/
index.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
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
<?php
session_start();
require_once 'config.php';
require_once 'funcoes.php';
// Verifica se sessão está vázia, caso esteja redireciona para login.php
if (empty($_SESSION['uLogin'])) {
header("Location: login.php");
exit;
}
// Busca o nome do usuário logado
$id = $_SESSION['uLogin'];
$sql = "SELECT usuarios.nome, patentes.nome as patente FROM usuarios LEFT JOIN patentes ON usuarios.patente = patentes.id WHERE usuarios.id = :id";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(":id", $id);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$data = $stmt->fetch();
$_SESSION['usuario']['nome'] = $data['nome'];
$_SESSION['usuario']['patente'] = $data['patente'];
} else {
header("Location: login.php");
exit;
}
$sql = "SELECT count(*) as count FROM usuarios";
$stmt = $pdo->prepare($sql);
$stmt->execute();
if($stmt->rowCount() > 0) {
$data = $stmt->fetch();
$total = $data['count'];
} else {
$total = 0;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sistema de Marketing Multinível</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<!-- Start .\ Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="javascript:void(0)">MMN</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navb">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="index.php">Dashboard</a>
</li>
<!-- Dropdown -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
Usuários
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="cadastro.php">Novo</a>
<a class="dropdown-item" href="usuarios.php">Listar</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="javascript:void(0)">Disabled</a>
</li>
</ul>
<!-- Navbar text-->
<span class="navbar-text mr-5">
Olá, <?php echo $_SESSION['usuario']['nome']; ?> <sup><span class="badge badge-success"><?php echo $_SESSION['usuario']['patente']; ?></span></sup>
</span>
<ul class="navbar-nav my-auto">
<li class="nav-item active">
<a class="nav-link btn btn-sm btn-danger my-2 my-sm-0" href="deslogar.php">Deslogar</a>
</li>
</ul>
</div>
</nav>
<!-- Start .\ Navbar -->
<div class="jumbotron jumbotron-fluid">
<div class="container pb-5">
<h1>Sistema de Marketing Multinível</h1>
<h2><?php echo $total; ?> usuários cadastrados</h2>
</div>
</div>
<div class="container">
<?php
// Lista usuarios
$usuarios = listaUsuarios($id, $limite);
exibir($usuarios);
?>
<pre>
<?php // print_r($usuarios);?>
</pre>
</div>
</body>
</html>