-
Notifications
You must be signed in to change notification settings - Fork 0
/
editar_grupo.php
68 lines (62 loc) · 2.55 KB
/
editar_grupo.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
<?php
require_once('includes/load.php');
$page_title = 'Editar Grupo';
// Checkin What level user has permission to view this page
page_require_level(1);
$e_group = find_by_id('user_groups',(int)$_GET['id']);
if(!$e_group){
$session->msg("d","Grupo não encontrado");
redirect('grupos.php');
}
if(isset($_POST['update'])){
$req_fields = array('group-name','group-level');
if(empty($errors)){
$name = remove_junk($db->escape($_POST['group-name']));
$level = remove_junk($db->escape($_POST['group-level']));
$status = remove_junk($db->escape($_POST['status']));
$query = "UPDATE user_groups SET ";
$query .= "group_name='{$name}',group_level='{$level}',group_status='{$status}'";
$query .= "WHERE ID='{$db->escape($e_group['id'])}'";
$result = $db->query($query);
if($result && $db->affected_rows() === 1){
$session->msg('s',"Grupo alterado com sucesso!");
redirect('grupos.php?id='.(int)$e_group['id'], false);
} else {
$session->msg('d','Desculpe, falha ao alterar o grupo.');
redirect('editar_grupo.php?id='.(int)$e_group['id'], false);
}
} else {
$session->msg("d", $errors);
redirect('editar_grupo.php?id='.(int)$e_group['id'], false);
}
}
?>
<?php include_once('layouts/header.php'); ?>
<div class="login-page">
<div class="text-center">
<h3>Editar Grupo</h3>
</div>
<?= display_msg($msg); ?>
<form method="post" action="editar_grupo.php?id=<?= (int)$e_group['id'];?>" class="clearfix">
<div class="form-group">
<label for="name" class="control-label">Nome do Grupo</label>
<input type="name" class="form-control" name="group-name" value="<?= remove_junk(ucwords($e_group['group_name'])); ?>" required>
</div>
<div class="form-group">
<label for="level" class="control-label">Nível do Grupo</label>
<input type="number" class="form-control" name="group-level" value="<?= (int)$e_group['group_level']; ?>" required>
</div>
<div class="form-group">
<label for="status">Estado</label>
<select class="form-control" name="status" required>
<option <?php if($e_group['group_status'] === '1') echo 'selected="selected"';?> value="1"> Ativo </option>
<option <?php if($e_group['group_status'] === '0') echo 'selected="selected"';?> value="0"> Inativo </option>
</select>
</div>
<div class="form-group clearfix">
<button type="submit" name="update" class="btn btn-info">Atualizar</button>
<a href="grupos.php" class="btn btn-danger">Cancelar</a>
</div>
</form>
</div>
<?php include_once('layouts/footer.php'); ?>