-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarefas.php
97 lines (57 loc) · 1.9 KB
/
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
<?php
session_start();
include "config.php";
include "banco.php";
include "ajudantes.php";
$exibir_tabela = true;
$tem_erros = false;
$erros_validacao = array();
if (tem_post()) {
$tarefa = array();
if (isset($_POST['nome']) && strlen($_POST['nome']) > 0) {
$tarefa['nome'] = $_POST['nome'];
} else {
$tem_erros = true;
$erros_validacao['nome'] = 'O nome da tarefa é obrigatório!';
}
$tarefa['nome'] = $_POST['nome'];
if (isset($_POST['descricao'])) {
$tarefa['descricao'] = $_POST['descricao'];
} else {
$tarefa['descricao'] = '';
}
if (isset($_POST['prazo']) && strlen($_POST['prazo']) > 0) {
if (validar_data($_POST['prazo'])) {
$tarefa['prazo'] = traduz_data_para_banco($_POST['prazo']);
} else {
$tem_erros = true;
$erros_validacao['prazo'] = 'O prazo não é uma data válida!';
}
} else {
$tarefa['prazo'] = '';
}
$tarefa['prioridade'] = $_POST['prioridade'];
if (isset($_POST['concluida'])) {
$tarefa['concluida'] = 1;
} else {
$tarefa['concluida'] = 0;
}
if (!$tem_erros) {
gravar_tarefa($conexao, $tarefa);
if (isset($_POST['lembrete']) && $_POST['lembrete'] == '1') {
enviar_email($tarefa);
}
header('Location: tarefas.php');
die();
}
}
$lista_tarefas = buscar_tarefas($conexao);
$tarefa = array(
'id' => 0,
'nome' => (isset($_POST['nome'])) ? $_POST['nome'] : '',
'descricao' => (isset($_POST['descricao'])) ? $_POST['descricao'] : '',
'prazo' => (isset($_POST['prazo'])) ? traduz_data_para_banco($_POST['prazo']) : '',
'prioridade' => (isset($_POST['prioridade'])) ? $_POST['prioridade'] : 1,
'concluida' => (isset($_POST['concluida'])) ? $_POST['concluida'] : ''
);
include "template.php";