-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_trips.html
executable file
·207 lines (171 loc) · 6.93 KB
/
my_trips.html
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ghumao</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/navbar_css.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Ghumao</a>
</div>
</div>
</nav>
<img class="width-match-parent" src="img/travel-nurse.jpg">
<p></p>
<div class="container">
<div id="previous-list">
</div>
<button class="btn btn-default" data-toggle="modal" data-target="#destination-modal">Add a new trip!</button>
</div>
<!--MODAL-->
<div class="modal fade" id="destination-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">What's your destination?</h4>
</div>
<div class="modal-body">
<form class="inline">
<div class="form-group">
<label for="destination-name" class="control-label">Destination</label>
<input type="text" class="form-control" id="destination-name">
</div>
<div class="form-group">
<label for="trip-date" class="control-label">From</label>
<input type="date" class="form-control" id="trip-date">
</div>
</form>
<span id="error1" class="error-class"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="btn-continue1">Continue</button>
</div>
</div>
</div>
</div>
<script>
$('#btn-continue1').click(function(){
//Validate data
if(document.getElementById('destination-name').value == "")
document.getElementById('error1').innerHTML = "Please select a destination";
else{
localStorage.setItem("destination", document.getElementById('destination-name').value);
$('#destination-modal').modal('hide');
console.log('Making a request for destination');
$.ajax({
url: 'backend/group_add.php',
type: 'post',
dataType: 'json',
data: JSON.parse('{"owner_id":"'+ localStorage.getItem("user_id") +'", "location":"'+ document.getElementById('destination-name').value+'"}'),
success: function(data) {
console.log(data);
localStorage.setItem("group_id", data);
}
});
$('#people-modal').modal('show');
}
});
</script>
<div class="modal fade" id="people-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">Visiting with?</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="search-input" class="control-label">Search</label>
<input type="text" class="form-control" id="search-input">
</div>
<div id="contacts-list">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="button-continue2">Continue</button>
</div>
</div>
</div>
</div>
<script>
// This will fetch a list of all the previous trips
var all_trips;
console.log('Making a request for previous trips');
$.ajax({
url: 'backend/group_display1.php',
type: 'post',
dataType: 'json',
data: JSON.parse('{"user_id":"'+localStorage.getItem("user_id")+'"}'),
success: function(data) {
console.log(data);
all_trips = data;
for(var i in data){
$('#previous-list').append(
'<div class="panel panel-default" onclick=launch_trip('+i+')>'+
'<div class="container-fluid">'+
'<h3 class="card-title">'+
data[i]['location'] + ' trip'
+'</h3>'+
'</div></div>'
);
}
console.log(data[i]);
}
});
var launch_trip = function(i){
localStorage.setItem("group_id", ""+all_trips[i]['group_id']);
console.log('group_id set to:' + localStorage.getItem("group_id"));
window.location="dashboard.html";
}
var contacts_all;
$.get('backend/user_display.php', function(data, status){
var json = JSON.parse(data);
console.log('Req: ' + json);
contacts_all = json;
for(var i in json){
console.log(json[i]);
console.log(json[i]["user_name"])
$('#contacts-list').append(
'<div class="container card-select-people">'
+'<input type="checkbox" name="contacts-checkbox"> ' +
json[i]['user_name'] +
'</input></div>'
);
}
});
$('#button-continue2').click(function(){
var checkboxes = document.getElementsByName('contacts-checkbox');
var checkedObjects = [];
for(var i=0 ; i<checkboxes.length; i++){
if(checkboxes[i].checked){
console.log(contacts_all[i]);
$.ajax({
url: 'backend/member_add.php',
type: 'post',
dataType: 'json',
data: JSON.parse('{"user_id":"'+contacts_all[i]["user_id"]+'","group_id":"'+localStorage.getItem("group_id")+'"}'),
success: function(data) {
console.log(data);
console.log(data[i]);
}
});
}
}
window.location = "places-selection.html";
});
</script>
</body>
</html>
<!--
TODO: Replace normal button by FAB