-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
105 lines (86 loc) · 2.9 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
<?php
include_once("tarefa.php");
$Tarefa = new Tarefa;
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : "" ;
$tarefa = isset($cursorShow['Tarefa']) ? $cursorShow['Tarefa'] : "" ;
switch($action){
case "inserir":
$Tarefa->UsuarioID = 0;
$Tarefa->Usuario = 'todos';
$Tarefa->Tarefa = $_REQUEST["Tarefa"];
$Tarefa->Tipo = 'obrigatório';
$Tarefa->Prioridade = 0;
$Tarefa->inserir();
break;
case "alterar":
$Tarefa->_id = $_REQUEST['_id'];
$Tarefa->Tarefa = $_REQUEST['Tarefa'];
$Tarefa->mudar_tarefa();
$cursorShow = $Tarefa->consultar($_REQUEST['_id']);
break;
case "alterarPrioridade":
$Tarefa->_id = $_REQUEST['_id'];
$Tarefa->modo = $_REQUEST['p'];
$Tarefa->mudar_prioridade();
$cursorShow = $Tarefa->consultar($_REQUEST['_id']);
break;
case "excluir":
$Tarefa->_id = $_REQUEST['_id'];
$Tarefa->excluir();
$cursorShow = $Tarefa->consultar($_REQUEST['_id']);
break;
default:
$cursorShow = (isset($_REQUEST['_id'])) ? $Tarefa->consultar($_REQUEST['_id']) : "";
$tarefa = isset($cursorShow['Tarefa']) ? $cursorShow['Tarefa'] : "" ;
}//fim switch
$filter = array();
$cursor = $Tarefa->listar($filter);
$cursor->sort(array('Prioridade' => -1))->limit(41)->skip(0);
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>iMasters - Sistema de Tarefas</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>TODO LIST</h1>
<section>
<form action='index.php' method='post'>
<label>Nova tarefa</label>
<input type='text' id='Tarefa' name='Tarefa' />
<input type='hidden' name='_id' value='<?php echo $_REQUEST['_id'];?>' />
<input type='hidden' name='action' value='inserir' />
<input type='submit' value='Inserir' />
</form>
<form action='index.php' method='post'>
<label>Alterar tarefa</label>
<input type='text' id='Tarefa' name='Tarefa' value='<?=$tarefa?>' />
<input type='hidden' name='_id' value='<?=$_REQUEST["_id"];?>' />
<input type='hidden' name='action' value='alterar' />
<input type='submit' value='Alterar' />
</form>
<ul id="tarefas-listagem">
<?php
$li_open = "<li>";
$li_close = "</li>";
foreach($cursor as $i => $item){
$btn_deletar = "<a href='?action=excluir&_id=$i'>[x]</a>";
$tarefa_nome = "<a href='?_id=$i'>" . $item['Tarefa'] . "</a> ";
$controles = "<span id='updown'>[<a href='?action=alterarPrioridade&_id=$i&p=up'>⇑</a>
 <a href='?action=alterarPrioridade&_id=$i&p=down'>⇓</a>]
$item[Prioridade]</span><br/>";
$tarefa_linha = $li_open;
$tarefa_linha .= $btn_deletar;
$tarefa_linha .= " - ";
$tarefa_linha .= $tarefa_nome;
$tarefa_linha .= $controles;
$tarefa_linha .= $li_close;
echo $tarefa_linha;
}
?>
</ul>
</section>
</body>
</html>