-
Notifications
You must be signed in to change notification settings - Fork 0
/
budg_new.html
210 lines (183 loc) · 7.72 KB
/
budg_new.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
207
208
209
210
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Home | Voyager</title>
<link rel = "stylesheet" href = "trav_hmpg-style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Aladin&display=swap" rel="stylesheet">
<style>
#page{
margin-top:60px;
height:fit-content;
display:flex;
flex-direction: column;
color:white;
}
.budget{
background-color: black;
}
.btn{
width:fit-content;
display:flex;
justify-content:center;
background-color:black;
padding:10px;
cursor: pointer;
border:1px solid white;
margin:auto;
}
.btn:hover{
background-color: grey;
}
td{
text-align:center;
}
</style>
</head>
<body>
<div class = "nav-bar">
<p style = "margin:5px;">
<a id = "logo" href = "start_page.html">
<img src="images/logo2-1.png" alt="logo" width = 250px;>
</a>
<div class ="dropdown">
<div id = "prof" style = "display: flex; cursor:pointer;" onmouseover="noarrow()" onmouseout="arrow()">
<span id = "arrow" style = "font-size:40px; height:fit-content; margin-top:px; width:25px;">⌄</span>
<img src="images/img.jpg" height="50px" style = "margin-top:5px; margin-left:8 px; border-radius:25px;">
</div>
<p id = "drop">
<span><a href = "profile_details.html" style = "cursor:pointer;">Profile</a></span><br>
<span><a onclick = "logout()" style = "cursor:pointer;">Log Out</a></span>
</p>
</div>
</p>
</div>
<div id = "page">
<div id="content" style="display:flex; flex-direction:column;margin:auto;">
<!--div id="1" class="budget" style="margin:50px;height:fit-content; width:55vw;">
<h1 style="text-align:left;">budget name</h1>
<table style="margin:auto;">
<tr>
<td><input name="1" class="ename" placeholder="Expense name"></td>
<td><input name="3" class="eamt" planceholder="Amount spent"></td>
</tr>
</table>
<div class="btn" id= "add-exp-btn" onclick="add_exp('1')">Add new expense</div>
</div-->
<div>
<h1 style="text-align:left;">Add Budget</h1>
<table style="margin:auto;">
<tr>
<td><input name="bname" id="bname" placeholder="Budget name"></td>
<td><input name="bamt" id="bamt" placeholder="Budget amt"></td>
</tr>
</table>
<div class="btn" id= "add-budg-btn" onclick="add_budg()">Add new budget</div>
</div>
</div>
</div>
<footer>
©Copyright Voyager pvt. ltd. All Rights Reserved<br>
Designed by Subhashree M
</footer>
<script>
document.getElementById("drop").addEventListener("mouseover", function(){noarrow();});
document.getElementById("drop").addEventListener("mouseout", function(){arrow();});
var url_string = window.location.href;
var url = new URL(url_string);
var paramValue = url.searchParams.get("tid");
//window.alert(paramValue);
get_all();
setInterval(sessionValidater,2000);
function sessionValidater(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//window.alert(this.responseText);
if(this.responseText.split(",")[0]){
}
else{
window.location.replace("login.html");
}
}
}
xhttp.open("GET", "GetSession", true);
xhttp.send();
}
function get_all(){
//window.alert("hey");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//window.alert(this.responseText);
//window.alert("hey");
var ender = "<div><h1 style='text-align:left;'>Add Budget</h1><table style='margin:auto;''><tr><td><input name='bname' id='bname' placeholder='Budget name'></td><td><input name='bamt' id='bamt' placeholder='Budget amt'></td></tr></table><div class='btn' id= 'add-budg-btn' onclick='add_budg()''>Add new budget</div></div>"
document.getElementById("content").innerHTML = this.responseText+ender;
display_stat();
}
}
xhttp.open("GET", "BudgExpDetails?tid="+paramValue, true);
xhttp.send();
}
function display_stat(){
var ele1 = document.getElementsByTagName("h3");
var ele2 = document.getElementsByClassName("tot");
for(var i = 0; i < ele1.length; i++){
if(parseFloat(ele1[i].innerHTML.split("\t")[1])<=parseFloat(ele2[i].innerHTML.split("=")[1])){
ele2[i].style.border = "1px solid red";
}
}
}
function add_budg(){
if(document.getElementById("bname").value=="" || document.getElementById("bamt").value==""){
window.alert("enter correct values!");
return;
}
else{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//window.alert(this.responseText);
this.responseText;
get_all();
}
}
xhttp.open("GET", "InsertBudg?trip_id="+paramValue+"&group_name="+document.getElementById("bname").value+"&amt="+document.getElementById("bamt").value, true);
xhttp.send();
}
}
function add_exp(bid){
//window.alert(bid);
//window.alert(parseInt(bid)-1)
if(document.getElementsByClassName("ename")[parseInt(bid)-1].value=="" || document.getElementsByClassName("eamt")[parseInt(bid)-1].value==""){
window.alert("enter correct values!");
return;
}
else{
var url1 = "InsertExp?trip_id="+paramValue+"&budget_id="+bid+"&exp_dets="+document.getElementsByClassName("ename")[parseInt(bid)-1].value+"&amt_spent="+document.getElementsByClassName("eamt")[parseInt(bid)-1].value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//window.alert(url1);
this.responseText;
get_all();
}
}
xhttp.open("GET", url1, true);
xhttp.send();
}
}
function noarrow(){
document.getElementById("arrow").innerHTML = "";
}
function arrow(){
document.getElementById("arrow").innerHTML = "⌄";
}
function logout(){
window.location.replace("LogOut");
}
</script>
</body>
</html>