-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
134 lines (106 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
$acao = 'recuperarTarefasPendentes';
require 'tarefa_controller.php';
/*echo '<pre>';
print_r($tarefas);
echo '</pre>';
*/
?>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>App Lista Tarefas</title>
<link rel="stylesheet" href="css/estilo.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<script>
function editar(id, txt_tarefa) {
//criar um form de edição
let form = document.createElement('form')
form.action = 'index.php?pag=index&acao=atualizar'
form.method = 'post'
form.className = 'row'
//criar um input para entrada do texto
let inputTarefa = document.createElement('input')
inputTarefa.type = 'text'
inputTarefa.name = 'tarefa'
inputTarefa.className = 'col-9 form-control'
inputTarefa.value = txt_tarefa
//criar um input hidden para guardar o id da tarefa
let inputId = document.createElement('input')
inputId.type = 'hidden'
inputId.name = 'id'
inputId.value = id
//criar um button para envio do form
let button = document.createElement('button')
button.type = 'submit'
button.className = 'col-3 btn btn-info'
button.innerHTML = 'Atualizar'
//incluir inputTarefa no form
form.appendChild(inputTarefa)
//incluir inputId no form
form.appendChild(inputId)
//incluir button no form
form.appendChild(button)
//teste
//console.log(form)
//selecionar a div tarefa
let tarefa = document.getElementById('tarefa_'+id)
//limpar o texto da tarefa para inclusão do form
tarefa.innerHTML = ''
//incluir form na página
tarefa.insertBefore(form, tarefa[0])
}
function remover(id) {
location.href = 'index.php?pag=index&acao=remover&id='+id;
}
function marcarRealizada(id) {
location.href = 'index.php?pag=index&acao=marcarRealizada&id='+id;
}
</script>
</head>
<body>
<nav class="navbar navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">
<img src="img/logo.png" width="30" height="30" class="d-inline-block align-top" alt="">
App Lista Tarefas
</a>
</div>
</nav>
<div class="container app">
<div class="row">
<div class="col-md-3 menu">
<ul class="list-group">
<li class="list-group-item active"><a href="#">Tarefas pendentes</a></li>
<li class="list-group-item"><a href="nova_tarefa.php">Nova tarefa</a></li>
<li class="list-group-item"><a href="todas_tarefas.php">Todas tarefas</a></li>
</ul>
</div>
<div class="col-md-9">
<div class="container pagina">
<div class="row">
<div class="col">
<h4>Tarefas pendentes</h4>
<hr />
<?php foreach($tarefas as $indice => $tarefa) { ?>
<div class="row mb-3 d-flex align-items-center tarefa">
<div class="col-sm-9" id="tarefa_<?= $tarefa->id ?>">
<?= $tarefa->tarefa ?>
</div>
<div class="col-sm-3 mt-2 d-flex justify-content-between">
<i class="fas fa-trash-alt fa-lg text-danger" onclick="remover(<?= $tarefa->id ?>)"></i>
<i class="fas fa-edit fa-lg text-info" onclick="editar(<?= $tarefa->id ?>, '<?= $tarefa->tarefa ?>')"></i>
<i class="fas fa-check-square fa-lg text-success" onclick="marcarRealizada(<?= $tarefa->id ?>)"></i>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>