-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodas_tarefas.php
131 lines (113 loc) · 5.28 KB
/
todas_tarefas.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
<?php
$acao = 'recuperar';
require 'tarefa_controller.php';
?>
<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){
// form de edição
let form = document.createElement('form')
form.action = "tarefa_controller.php?acao=atualizar"
form.method = 'post'
form.className = 'row'
// entrada do texto
let inputTarefa = document.createElement('input')
inputTarefa.type = 'text'
inputTarefa.name = 'tarefa'
inputTarefa.className = 'col-8 form-control'
inputTarefa.value = txt_tarefa
// input hidden para guardar o id da tarefa a ser enviado ao BD
let inputId = document.createElement('input')
inputId.type = 'hidden'
inputId.name = 'id'
inputId.value = id
// button
let button = document.createElement('button')
button.type = 'submit'
button.className = 'col-3 btn btn-info ml-1'
button.innerHTML = 'Atualizar'
// ARVORE DE ELEMENTOS:
// Incluindo o Input no Form
form.appendChild(inputTarefa)
// Incluir imputID no form
form.appendChild(inputId)
// Incluindo o button no Form
form.appendChild(button)
//EDITANDO O CONTEUDO
// Selecionando a div a ser editada
let tarefa = document.getElementById('tarefa_'+id)
// Limpar o texto da tarefa para inclusão do form
tarefa.innerHTML = ''
// Inclusão do Form na Página
tarefa.insertBefore(form,tarefa[0])
}
function remover(id){
location.href = 'todas_tarefas.php?acao=remover&id='+id;
}
function marcarRealizada(id){
location.href = 'todas_tarefas.php?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-sm-3 menu">
<ul class="list-group">
<li class="list-group-item"><a href="index.php">Tarefas pendentes</a></li>
<li class="list-group-item"><a href="nova_tarefa.php">Nova tarefa</a></li>
<li class="list-group-item active"><a href="#">Todas tarefas</a></li>
</ul>
</div>
<div class="col-sm-9">
<div class="container pagina">
<div class="row">
<div class="col">
<h4>Todas tarefas</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 ?>
<?php if($tarefa->status == 'pendente'){?>
<label class="text-danger">(<?= $tarefa->status ?>)</label>
<?php } else if($tarefa->status == 'realizado') {?>
<label class="text-success">(<?= $tarefa->status ?>)</label>
<?php } ?>
</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>
<?php if($tarefa->status == 'pendente') { ?>
<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>
<?php } ?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>