forked from harshjoeyit/ExpendiShare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
254 lines (222 loc) · 9.68 KB
/
dashboard.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
session_start();
if (!isset($_SESSION['user'])) {
header("Location: ./index.php");
}
$title = "Dashboard | ExpendiShare";
include_once('components/header.php');
?>
<div class="container flex">
<!-- Left Sidebar-->
<aside class="sidebar">
<div class="sidebar-widget">
<h2 class="widget-title">My Friends</h2>
<!-- <input class="hello"type="checkbox" value="hello">Hello</input> -->
<div id="display-friends"></div>
</div>
<div class="sidebar-widget">
<h2 class="widget-title">My Groups</h2>
<!-- <input class="hello"type="checkbox" value="hello">Hello</input> -->
<div id="display-grp"></div>
</div>
</aside>
<!-- Main container -->
<section class="main">
<div class="container row">
<h2>Main Dashboard</h2>
<button id = "add-expense-btn"class="btn">Add Expense</button>
<button id = "show-expenses-btn" class="btn">Show Expenses</button>
</div>
<div class="show-expense">
<div class="row">
<div>
<h3>You Owe</h3>
</div>
<div>
<h3>You Paid</h3>
</div>
</div>
</div>
<div class="container" id ="add-expense">
<div class="col">
<h2>Add Expense</h2>
<div class="form-field select">
<label>Select Expense Type</label>
<select class = "select-expense-type">
<option name="expensetype" selected value="selectexpensetype" disabled>Select Expense Type</option>
<option name="expensetype" value="1">Individuals</option>
<option name="expensetype" value="2">Group</option>
</select>
</div><br>
<div class="form-field select" id="select-group">
<label>Select Group</label>
<select class = "group-data">
<option name="expensetype" selected value="selectexpensetype" disabled>Select Expense Type</option>
<option name="expensetype" value="1">Individuals</option>
<option name="expensetype" value="2">Group</option>
</select>
</div>
<div class="form-field row" id = "splitingmembers" style="justify-content: center">
<span>With:</span>
<span id = "membersname"></span>
<button id="chose-frnd-btn"class="btn">Select</button>
<div id="select-frnd" class="modal">
<div class="modal-form">
<h2>Select Friends</h2>
<div id = "select-frnd-content" class="modal-content">
</div>
<div class="modal-close-btn">X</div>
</div>
</div>
</div>
<div class="form-field select">
<label>Select Spliting Type</label>
<select id = "select-split-type">
</select>
</div><br>
<div class="form-field select friendpaid" style="display: none;">
<label>Who paid</label>
<select id = "whopaid">
</select>
</div>
<div class="modal" id="custom-split">
<div class="modal-form" id="custom-split-form">
<h2>Custom splitting</h2>
<div id="custom-split-content" class="modal-content grid-container">
</div>
<div class="modal-close-btn">X</div>
</div>
</div>
<div class="form-field col">
<label> Amount </label>
<input type="number" name="amount" id="amountBox" max-length="10" required>
</div> <br>
<div class="form-field select">
<label> Category </label>
<select class="select-expense-category">
<option name="expensecategory" selected disabeld>Select Category</option>
<?php
include_once('class.misc.php');
$misc = new misc();
$categorys = $misc->getExpenseCategory();
foreach($categorys as $category) {
?>
<option name="expensecategory" data-id="<?php echo $category[1];?>"><?php echo $category[0]; ?></option>
<?php
}
?>
</select>
<!-- <input type="text" name="category" id="categoryBox" max-length="50" size="50" required> -->
</div><br>
<div class="form-field">
<label> Description </label>
<input type="text" name="description" id="description" max-length="50" size="50">
</div><br>
<p id="split-success-message" style="display: none;">Success message</p>
</div>
<button id="split" class="btn">Split</button>
</div>
</section>
<!-- Right sidebar -->
<aside class = "sidebar">
<div class="sidebar-widget">
<h2 class="widget-title">Add Friends</h2>
<div class="widget-field">
<label>Friend Username</label>
<input name="friend" id="searchFriends" type="text" style="text-transform:lowercase" max-length="40" required>
</div>
<p id="add-response-message" class="error"></p>
<div>
<button id="add" class="btn"> Add </button>
</div>
<p id="success-message" style="display: none;">Success message</p>
<br>
<div id="searchResults"></div>
</div>
<div class="sidebar-widget">
<h2 class="widget-title">Create Group</h2>
<div class="widget-field">
<label>Group Name</label>
<input name="groupname" id="create-grp" type="text" style="text-transform:lowercase" max-length="40" required>
</div>
<p id="add-response-message-create-grp" class="error"></p>
<div>
<button id="create-grp-btn" class="btn"> Create </button>
</div>
<div class="modal" id="create-grp-modal">
<div class="modal-form" id="create-grp-modal-from">
<h2>Select Members</h2>
<div id="create-grp-content" class="modal-content">
</div>
<div class="modal-close-btn">X</div>
</div>
</div>
<p id="success-message" style="display: none;">Success message</p>
<br>
<!-- <div id="searchResults"></div> -->
</div>
<!-- <div class="btn" id="checked">Hello</div> -->
</aside>
</div>
<script>
$(document).ready(function() {
var username = "<?php echo $_SESSION['user']; ?>";
displayFriends(username);
displayGroups(username);
liveSearch();
spliting();
$('#add-expense').hide();
$('.show-expense').hide();
$('#select-group').hide();
$('#add-expense-btn').click(function () {
$('.show-expense').hide();
$('#add-expense').toggle();
displaySplitingTypes();
});
$('#show-expenses-btn').click(function () {
$('#add-expense').hide();
$('.show-expense').toggle();
});
$('#add').on('click', function(e) {
e.preventDefault();
var friend = $('input[name="friend"]').val();
console.log(friend);
addFriend(username, friend);
});
$('.modal-close-btn').on('click', function() {
$('.modal').hide();
});
$('#create-grp-btn').on('click', function() {
console.log("create grp clicked");
var msg = $('#add-response-message-create-grp').text();
if(msg == "Available") {
var grpName = $('input[name="groupname"]').val();
var members = [];
console.log(grpName);
if(grpName == "") {
$('#add-response-message-create-grp').html("Group Name cannot be blank");
} else {
$('#create-grp-modal').show();
displayFriendsInModalForm(username, "create-grp");
$('#create-grp-modal').on('click', '#create-grp-btn', function() {
console.log("Selected Members data retrived");
$('#create-grp-content input[type="checkbox"]').each(function() {
var member = $(this);
if(member.is(":checked")) {
members.push(member.val());
}
});
$('#create-grp-modal').hide();
// console.log(members);
createGroup(grpName, members);
displayGroups(username);
});
}
}
});
});
</script>
<script src = "./js/dashboard.js"></script>
<?php
include_once('components/footer.php');
?>