-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
100 lines (87 loc) · 4.67 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
<?php
session_start();
include "Todo.php";
include "Alert.php";
$todo = new Todo();
# Crear una tarea
# Listar las tareas
# Eliminar las tareas
# editar las tareas
?>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<section class="vh-100" style="background-color: #eee;">
<div class="container py-5 h-100">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col col-lg-9 col-xl-7">
<div class="card rounded-3">
<div class="card-body p-4">
<h4 class="text-center my-3 pb-3">To Do App</h4>
<?php
(new Alert($_GET))->getMessage();
?>
<form method="POST" action="proccess.php" class="row row-cols-lg-auto g-3 justify-content-center align-items-center mb-4 pb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="form1" name="task" class="form-control" placeholder="Enter a task here" />
<input type="hidden" id="taskid" name="id" />
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
<table class="table mb-4">
<thead>
<tr>
<th scope="col">No.</th>
<th scope="col">Todo item</th>
<th scope="col">Status</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
$list = $todo->list();
foreach ($list as $key => $task) {
?>
<tr>
<th scope="row"><?= $key + 1 ?></th>
<td>
<span onclick="setTask(<?= $key ?>, '<?= $task['task'] ?>')" style="color:blue;cursor:pointer;"> <?= $task['task'] ?></span>
</td>
<td><?= $task['status'] == 0 ? "En progreso" : "Completada" ?></td>
<td>
<a href="delete.php?id=<?= $key ?>" class="btn btn-danger">Delete</a>
<a href="status.php?id=<?= $key ?>" class="btn btn-<?= $task['status'] == 0 ? "success" : "warning" ?> ms-1"><?= $task['status'] == 0 ? "Finalizar" : "Desmarcar" ?></a>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td>Total:</td>
<td><?= count($list) ?></td>
<td> </td>
<td><a href="clear.php" class="btn btn-danger" onclick="return confirm('Quieres eliminar todo?')">Eliminar Todo</a></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script>
function setTask(key, task) {
document.getElementById("form1").value = task;
document.getElementById("taskid").value = key;
}
</script>
</body>
</html>