-
Notifications
You must be signed in to change notification settings - Fork 0
/
sistemaEdit.php
108 lines (90 loc) · 3.57 KB
/
sistemaEdit.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
<?php
/* CLEAR CACHE */
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//header("Content-Type: application/xml; charset=utf-8");
require_once 'appConfig.php';
include_once 'api/config/database.php';
include_once 'api/objects/sistema.php';
// get database connection
$database = new Database();
$db = $database->getConnection();
// prepare objects
$sistema = new Sistema($db);
// GET variables
$py_idsistema = md5('idsistema');
$sql = $sistema->readSingle($_GET[''.$py_idsistema.'']);
if ($sql->rowCount() > 0) {
#while($row = $sql->fetch(PDO::FETCH_OBJ)) {}
$row = $sql->fetch(PDO::FETCH_OBJ);
?>
<form class="form-edit-sistema">
<div class="modal-header">
<h4 class="modal-title">
<span>Editar Sistema</span>
<span class="text-muted">
<small>(<i class="fas fa-bell"></i> Campo obrigatório)</small>
</span>
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="hidden" name="rand" id="rand_edit_sistema" value="<?php echo md5(mt_rand()); ?>">
<input type="hidden" name="idsistema" id="idsistema_edit_sistema" value="<?php echo $_GET[''.$py_idsistema.'']; ?>">
<div class="form-group">
<label for="descricao"><i class="fas fa-bell"></i> Descrição</label>
<input type="text" name="descricao" id="descricao_edit_sistema" maxlength="100"
value="<?php echo $row->descricao; ?>" class="form-control" placeholder="Descrição" required>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button type="submit" class="btn btn-primary btn-edit-sistema">Salvar</button>
</div>
</form>
<script defer>
$(document).ready(function() {
const fade = 150,
delay = 100,
//timeout = 60000,
//filelist = [],
Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 1000
});
/* EDITAR SISTEMA */
$('.form-edit-sistema').submit(function(e) {
e.preventDefault();
$.post('api/sistema/update.php', $(this).serialize(), function(data) {
$('.btn-edit-sistema').html('<img src="dist/img/rings.svg" class="loader-svg">').fadeTo(fade, 1);
switch(data) {
case 'true':
Toast.fire({icon: 'success',title: 'Sistema editado.'}).then((result) => {
window.setTimeout("location.href='inicio'", delay);
});
break;
default:
Toast.fire({icon: 'error',title: data});
break;
}
$('.btn-edit-sistema').html('Salvar').fadeTo(fade, 1);
});
return false;
});
});
</script>
<?php
} else {
echo'
<blockquote class="quote-danger">
<h5>Erro</h5>
<p>O sistema não foi encontrado.</p>
</blockquote>';
}
?>