-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_cad_cargo_politico.php
199 lines (185 loc) · 10.2 KB
/
form_cad_cargo_politico.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
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
include_once 'includes/conexao.php';
include_once 'includes/functions.php';
session_start();
?>
<html>
<head>
<?php include 'includes/head.html'; ?>
<link rel="stylesheet" href="css/jquery-ui-1.12.0.css">
<script src="js/jquery-1.12.4.js"></script>
<script src="js/jquery-ui-1.12.0.js"></script>
<script src="js/jquery.maskedinput.js"></script>
<script src="js/functions.js"></script>
</head>
<body>
<?php if (login_check($mysqli) == true)
{
include 'includes/cabecalho.php';
if (!empty ($_GET) && isset($_GET['alt']) && isset($_GET['cod_car_pol'])){
$cod_car_pol = $_GET['cod_car_pol'];
if ($resultado=$mysqli->query("SELECT cod_car_pol, nom_car_pol, ind_car_pol FROM gab_cargo_politico WHERE cod_car_pol='$cod_car_pol'")){
if ($resultado->num_rows){
$linha=$resultado->fetch_object();
}
}
}
?>
<div class="container" id="main">
<?php if (isset($_GET['msg'])){
echo '<div class="alert alert-success fade in"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>'.$_GET['msg'].'</strong></div>';
}else if (isset($_GET['err'])){
echo '<div class="alert alert-warning fade in "><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>'.$_GET['err'].'</strong></div>';
}
?>
<h1 class="h2">Cadastro de Cargo Político</h1>
<form name="form" class="form-horizontal" action="action_cad_cargo_politico.php" method="post">
<?php
if (!empty ($_GET) && isset($_GET['alt']) && isset($_GET['cod_car_pol']))
{
echo "<input type='hidden' name='alt' id='alt'>";
echo "<input type='hidden' name='cod_car_pol' value=".$_GET['cod_car_pol'].">";
}
?>
<div class="form-group">
<label class="col-md-2 control-label" autocomplete="on">Cargo Político:</label>
<div class="col-md-8">
<input name="nom_car_pol" type="text" placeholder="" class="form-control input-md" required
value="<?php if (!empty ($_GET) && isset($_GET['alt']) && isset($_GET['cod_car_pol'])) {echo escape($linha->nom_car_pol);}?>">
</div>
</div>
<?php
if(isset($_GET['alt']))
{
?>
<div class="form-group">
<label class="col-md-2 control-label" for="radios">Status:</label>
<div class="col-md-8">
<div class="radio">
<label for="ativo">
<input type="radio" name="ind_car_pol" id="ativo" value="A" <?php if (!empty ($_GET) && isset($_GET['alt']) && isset($_GET['cod_car_pol'])) {echo $linha->ind_car_pol == 'A' ? "checked" : null;}?>>
Ativo   
</label>
<label for="inativo">
<input type="radio" name="ind_car_pol" id="inativo" value="I" <?php if (!empty ($_GET) && isset($_GET['alt']) && isset($_GET['cod_car_pol'])) {echo $linha->ind_car_pol == 'I' ? "checked" : null;}?>>
Inativo
</label>
</div>
</div>
</div>
<?php
}
?>
<div class="form-group">
<div class="col-md-4 text-right">
<input type="submit" class="btn btn-default" value="Cadastrar">
<input type="reset" class="btn btn-default" value="Limpar">
</div>
</div>
</form>
<?php
$itens_por_pag = 10;
if(isset($_GET['pagina'])){$pagina = intval($_GET['pagina']);}else {$pagina=1;}
$aux=$pagina*10-10;
$records=array();
if ($results = $mysqli->query("SELECT cod_car_pol, nom_car_pol, ind_car_pol FROM gab_cargo_politico ORDER BY nom_car_pol ASC LIMIT $aux, $itens_por_pag "))
{
$num=$results->num_rows;
$num_total = $mysqli->query("SELECT cod_car_pol, nom_car_pol, ind_car_pol FROM gab_cargo_politico")->num_rows;
$num_paginas= ceil($num_total/$itens_por_pag);
if ($results->num_rows){
while($row = $results->fetch_object()){
$records[]=$row;
}
$results->free_result();
}
}
?>
<?php
if (count($records)){?>
<nav aria-label="Page navigation">
<ul class="pagination">
<li>
<a href="form_cad_cargo_politico.php?pagina=1" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for($i=1;$i<=$num_paginas;$i++) {
$estilo="";
if ($i==$pagina)
$estilo="class=\"active\"" ;
?>
<li <?php echo $estilo; ?>><a href="form_cad_cargo_politico.php?pagina=<?php echo $i; ?>"> <?php echo $i;?> </a></li><?php }
?>
<li>
<a href="form_cad_cargo_politico.php?pagina=<?php echo $num_paginas; ?>" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
<div class="table-of row">
<table id="example" class="mtab table table-striped table-hover table-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th>Cargo Político</th>
<th>Status</th>
<th>Alterar</th>
<th>Excluir</th>
</tr>
</thead>
<tbody>
<?php foreach($records as $r){?>
<tr>
<td width='60%'><?php echo escape($r->nom_car_pol); ?></td>
<td width='20%'><?php if($r->ind_car_pol == 'A') echo 'Ativo'; else echo 'Inativo'; ?></td>
<?php $cod_car_pol=$r->cod_car_pol;?>
<td width='10%'><a href="form_cad_cargo_politico.php?alt=1&cod_car_pol=<?php echo $cod_car_pol; ?>"><i class="fas fa-pencil-alt" style="font-size:20px; color:000000;"></i></a></td>
<td width='10%'><a href="action_cad_cargo_politico.php?del=1&cod_car_pol=<?php echo $cod_car_pol; ?>" onclick="return confirm('Confirma exclusão?');"><i class="fas fa-trash-alt" style="font-size:20px; color:000000;"></i></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<nav aria-label="Page navigation">
<ul class="pagination">
<li>
<a href="form_cad_cargo_politico.php?pagina=1" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for($i=1;$i<=$num_paginas;$i++) {
$estilo="";
if ($i==$pagina)
$estilo="class=\"active\"" ;
?>
<li <?php echo $estilo; ?>><a href="form_cad_cargo_politico.php?pagina=<?php echo $i; ?>"> <?php echo $i;?> </a></li><?php }
?>
<li>
<a href="form_cad_cargo_politico.php?pagina=<?php echo $num_paginas; ?>" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
<?php
}
?>
</div>
<?php include 'includes/footer.html';
}
else
{
?>
<p>
<span class="error">Você não tem autorização para acessar esta página.</span> Please <a href="index.php">login</a>.
</p>
<?php
}
?>
</body>
</html>