-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToDo.php
144 lines (132 loc) · 5.91 KB
/
ToDo.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
135
136
137
138
139
140
141
142
143
144
<?php
include('functions/db_config.php');
session_start();
if(!isset($_SESSION["user_id"])){
header('location:index.php');
};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ToDo List</title>
<!-- Latest compiled and minified CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<a class="btn btn-primary" href="functions/function.php?logout=true" role="button" style="float:right">Logout</a>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add to Contuct List</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php
if(isset($_SESSION['user_id'])){
$user_id= $_SESSION['user_id'];
}
?>
<input type="hidden" id="user_id" value="<?php echo $user_id?>">
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" autocomplete="off" class="form-control" id="title">
</div>
<div class="mb-3">
<label for="Time" class="form-label">Time</label>
<input type="time" autocomplete="off" class="" id="time">
</div>
<div class="mb-3">
<label for="Color" class="form-label">Color</label>
<input type="color" autocomplete="off" class="" id="color">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-info" onclick="adduser()">Save changes</button>
</div>
</div>
</div>
</div>
<!-- Update Modal -->
<div class="modal fade" id="updateData" tabindex="-1" aria-labelledby="updateData" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateDataLabel">Update ToDO List</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php
if(isset($_SESSION['user_id'])){
$username= $_SESSION['user_id'];
}
?>
<input type="hidden" id="user_id" value="<?php echo $user_id?>">
<div class="mb-3">
<label for="updateTitle" class="form-label">Title</label>
<input type="text" autocomplete="off" class="form-control" id="updateTitle">
</div>
<div class="mb-3">
<label for="UpdateTime" class="form-label">Time</label>
<input type="time" autocomplete="off" class="" id="UpdateTime">
</div>
<div class="mb-3">
<label for="UpdateColor" class="form-label">Color</label>
<input type="color" autocomplete="off" class="" id="UpdateColor">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-info">Update</button>
<input type="hidden" name="hiddenData" id="hiddenData">
</div>
</div>
</div>
</div>
<div class="container my-3">
<h1 class="text-center">ToDo</h1>
<!-- Button trigger modal -->
<button type="button" class="btn btn-dark m-4" data-bs-toggle="modal" data-bs-target="#exampleModal">
Add List
</button>
<div id="displaytable"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.2/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="js/index.js"></script>
<script>
function DeleteData(deleteID){
$.ajax({
url:"functions/function.php",
type:"post",
data:{
deleteID:deleteID
},
success:function(data,status){
display();
}
})
};
function editData(editID) {
$('#hiddenData').val(editID);
$.post("functions/function.php",{editID:editID},function(data,status){
//console.log(data);
var userID =JSON.parse(data);
//console.log(userID);
$('#updateTitle').val(userID.title);
$('#UpdateTime').val(userID.time);
$('#UpdateColor').val(userID.color);
});
$('#updateData').modal('show');
}
</script>
</body>
</html>