-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDGMApprovalmail.html
160 lines (139 loc) · 5.62 KB
/
SDGMApprovalmail.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="style1.css">
<title>Staff Home</title>
</head>
<body>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Home</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">Welcome to Request Form App</a>
</li>
</ul>
<span class="navbar-text">
<li class="d-flex mx-1">
<a id="userlink" class="nav-link" href="">Username</a>
</li>
</span>
<span class="navbar-text">
<li class="d-flex mx-1">
<a id="desiglink" class="nav-link" href="">Designation</a>
</li>
</span>
<span class="navbar-text">
<li class="d-flex mx- 1">
<a id="stafflink" class="nav-link" href="">Staff No</a>
</li>
</span>
<span class="navbar-text">
<li class="d-flex mx-1">
<a id = "signoutlink" class="nav-link" href="">Sign Out</a>
</li>
</span>
</div>
</div>
</nav>
<div class="container">
<h1>Check for Approval</h1>
<button id="findbtn" class="inputBox">Click here</button>
<h3 id="findlet" type="text"></h3>
<h3 id="findtyp" type="text"></h3> <br><br>
</div>
</div>
<h3 id="hh"></h3>
<script type="module">
let findBtn = document.querySelector('#findbtn');
let findletter = document.querySelector('#findlet');
let findtype = document.querySelector('#findtyp');
let userlink = document.querySelector('#userlink');
let desiglink = document.querySelector('#desiglink');
let stafflink = document.querySelector('#stafflink');
let signoutlink = document.querySelector('#signoutlink');
let header = document.querySelector("#hh");
var currentUser = null;
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.23.0/firebase-app.js";
const firebaseConfig = {
apiKey: "AIzaSyBYvXKpYca8HNsRxzF5DtwUOwBbmmGl8_4",
authDomain: "leavdev.firebaseapp.com",
projectId: "leavdev",
storageBucket: "leavdev.appspot.com",
messagingSenderId: "315047366295",
appId: "1:315047366295:web:c8639d9659c35e00e723d2"
};
const app = initializeApp(firebaseConfig);
import {getDatabase,ref,set,child,get} from "https://www.gstatic.com/firebasejs/9.23.0/firebase-database.js";
const db = getDatabase();
function getUsername(){
let keepLoggedIn = localStorage.getItem("keepLoggedIn");
if (keepLoggedIn == "yes") {
const userString = localStorage.getItem("StaffMember");
try {
currentUser = JSON.parse(userString);
} catch (error) {
console.error("Error parsing user data from localStorage:", error);
}
} else {
const userString = sessionStorage.getItem("StaffMember");
try {
currentUser = JSON.parse(userString);
} catch (error) {
console.error("Error parsing user data from sessionStorage:", error);
}
}
}
function Signout(){
sessionStorage.removeItem('StaffMember');
localStorage.removeItem('StaffMember');
localStorage.removeItem('keepLoggedIn');
window.location = "StaffHome.html";
}
function Find(){
const dbref = ref(db);
get(child(dbref,"SDGM/" + currentUser.staffno))
.then((snapshot) => {
if(snapshot.exists()){
findletter.innerHTML = "Approval Status:" + snapshot.val().urlmsg;
findtype.innerHTML = "Leave Status:" + snapshot.val().leaname;
}else{
alert("No Data Found");
}
})
.catch((error) => {
alert(error);
})
}
window.onload = function(){
getUsername();
if(currentUser == null){
signoutlink.innerHTML="Login";
signoutlink.classList.replace("nav-link","btn");
signoutlink.classList.add("btn-success");
signoutlink.href = "Stafflogin.html";
}
else{
userlink.innerHTML= currentUser.username;
desiglink.innerHTML= currentUser.designation;
stafflink.innerHTML= currentUser.staffno;
userlink.classList.replace("btn","nav-link");
userlink.classList.remove("btn-primary");
userlink.href = "#";
signoutlink.innerHTML="Sign Out";
signoutlink.classList.replace("btn","nav-link");
signoutlink.classList.remove("btn-success");
signoutlink.href = "javascript:Signout()";
}
}
findBtn.addEventListener('click',Find);
</script>
</body>
</html>