-
Notifications
You must be signed in to change notification settings - Fork 0
/
DGMbosshome.html
218 lines (189 loc) · 7.71 KB
/
DGMbosshome.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
211
212
213
214
215
216
217
218
<!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">
<title>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">
<a id="userlink" class="nav-link" href="">Username</a>
</li>
</span>
<li class="d-flex mx-1">
<a id = "signoutlink" class="nav-link" href="">Sign Out</a>
</li>
</span>
</div>
</div>
</nav>
<div class="container mt-3">
<table class="table table-dark">
<thead>
<th>Sno</th>
<th>Staff No</th>
<th>Letter Link</th>
<th>Leave Type</th>
<th>Approval To be Given</th>
</thead>
<tbody id="tbody1"></tbody>
</table>
</div>
<!-- Modal starts -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Approval panel</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<label class="labs">Staff No : </label>
<input type="text" id="Stamod"> <br>
<label class="labs">Letter Link : </label>
<input type="text" id="Appmod"> <br>
</div>
<div class="modal-footer">
<button id="UpdModBtn" class="btn btn-success">Update Record</button>
</div>
</div>
</div>
</div>
<!-- Modal ends -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="module">
let stdNo = 0;
let stdList = [];
let tbody = document.querySelector('#tbody1');
let userlink = document.querySelector('#userlink');
let signoutlink = document.querySelector('#signoutlink');
let header = document.querySelector("#hh");
var currentUser = null;
function AddItemToTable(stafn,letlink,leavtype){
let trow = document.createElement("tr");
let td1 = document.createElement('td');
let td2 = document.createElement('td');
let td3 = document.createElement('td');
let td4 = document.createElement('td');
stdList.push([stafn,letlink,leavtype]);
td1.innerHTML = ++stdNo;
td2.innerHTML = stafn;
td3.innerHTML = letlink;
td4.innerHTML = leavtype;
trow.appendChild(td1);
trow.appendChild(td2);
trow.appendChild(td3);
trow.appendChild(td4);
var ControlDiv = document.createElement("div");
ControlDiv.innerHTML = '<button type="button" class="btn btn-primary my-2 ml-2" data-toggle="modal" data-target="#exampleModalCenter">Edit Record</button>'
trow.appendChild(ControlDiv);
tbody1.appendChild(trow);
}
function AddAllItemsToTable(TheReporter){
stdNo=0;
document.querySelector('#tbody1').innerHTML = "";
tbody.innerHTML="";
TheReporter.forEach(element => {
AddItemToTable(element.stfn,element.urlmsg,element.leaname);
});
}
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,update,child,get} from "https://www.gstatic.com/firebasejs/9.23.0/firebase-database.js";
const db = getDatabase();
function UpdStd(){
update(ref(db,"DGM/" + Stamod.value),{
urlmsg : Appmod.value
})
.then(() => {
alert("Approval given successfully")
})
.catch((error) => {
alert(error)
})
}
function GetAllDataOnce(){
const dbRef = ref(db);
get(child(dbRef,"DGM"))
.then((snapshot) => {
var Report = [];
snapshot.forEach(childSnapshot => {
Report.push(childSnapshot.val());
});
AddAllItemsToTable(Report);
});
}
function getUsername(){
let keepLoggedIn = localStorage.getItem("keepLoggedIn");
if (keepLoggedIn == "yes") {
const userString = localStorage.getItem("Boss");
try {
currentUser = JSON.parse(userString);
} catch (error) {
console.error("Error parsing user data from localStorage:", error);
}
} else {
const userString = sessionStorage.getItem("Boss");
try {
currentUser = JSON.parse(userString);
} catch (error) {
console.error("Error parsing user data from sessionStorage:", error);
}
}
}
function Signout(){
sessionStorage.removeItem('user');
localStorage.removeItem('user');
localStorage.removeItem('keepLoggedIn');
window.location = "BossHome.html";
}
window.onload = function(){
getUsername();
if(currentUser == null){
signoutlink.innerHTML="Login";
signoutlink.classList.replace("nav-link","btn");
signoutlink.classList.add("btn-success");
signoutlink.href = "Bosslogin.html";
}
else{
GetAllDataOnce();
userlink.innerHTML= currentUser.username;
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()";
}
}
UpdModBtn.addEventListener('click',UpdStd)
</script>
</body>
</html>