-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaurav_adminPortal.html
More file actions
536 lines (504 loc) · 15.3 KB
/
saurav_adminPortal.html
File metadata and controls
536 lines (504 loc) · 15.3 KB
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
<script>
var studentList = [];
var courseList = [];
var batchList = [];
var adminList = [
{ id: 1, adminName: "saurav", adminPassword: 121 },
{ id: 2, adminName: "keshav", adminPassword: 121 },
];
var studentId = 1;
var courseId = 1;
var batchId = 1;
var doWhile = true;
do {
var choice = parseInt(
prompt("Enter your User Profile: \n1. Admin \n2. Student \n3. Exit")
);
switch (choice) {
case 1:
//-------------------------------Admin Secton--------------------------------------
var adminUserName = prompt("Enter your Admin Username: ");
var adminFlag = 0;
for (var a of adminList) {
if (adminUserName == a.adminName) {
adminFlag = 1;
var adminUserPassword = prompt("Enter your Admin Password: ");
if (adminUserPassword == a.adminPassword) {
adminFlag = 2;
alert("Login Successfull, Welcome to Admin Side");
}
}
}
if (adminFlag == 0) {
alert("Invalid Admin UserName !!!");
} else if (adminFlag == 1) {
alert("Invalid Admin Password !!!");
} else {
var adminDoWhile = true;
do {
var adminChoice = parseInt(
prompt(
"Enter your choice: \n1. Manage Course \n2. Manage Batch \n3. Manage Student \n4. Payment Collection"
)
);
switch (adminChoice) {
case 1:
//-------------------------------Manage Course--------------------------------------
var adminCourseDoWhile = true;
do {
var adminCourseChoice = parseInt(
prompt(
"Enter your choice: \n1. Add a Course \n2. View Courses"
)
);
switch (adminCourseChoice) {
case 1:
//-------------------------------Add a Course--------------------------------------
var courseDoWhile = true;
do {
var courseName = prompt("Enter the Course Name: ");
var courseFees = parseInt(
prompt("Enter the Course Fees: ")
);
var courseObject = {
course_Id: courseId++,
course_Name: courseName,
course_Fees: courseFees,
};
courseList.push(courseObject);
if (
parseInt(
prompt(
"Do still want to continue with \n1. Add Course \n2. Exit"
)
) == 2
) {
courseDoWhile = false;
}
} while (courseDoWhile);
break;
case 2:
//-------------------------------View Courses-----------------------------------
var viewCourse = "";
for (var c of courseList) {
viewCourse +=
".Course Id - " +
c.course_Id +
" " +
".Course Name - " +
c.course_Name +
" " +
".Course Fees - " +
c.course_Fees +
"\n";
}
alert(viewCourse);
break;
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Manage Course \n2. Exit"
)
) == 2
) {
adminCourseDoWhile = false;
}
} while (adminCourseDoWhile);
break;
case 2:
//-------------------------------Manage Batch--------------------------------------
var adminBatchDoWhile = true;
do {
var adminBatchChoice = parseInt(
prompt(
"Enter your choice: \n1. Create a Batch \n2. View Batches"
)
);
switch (adminBatchChoice) {
case 1:
//-------------------------------Create a Batch--------------------------------------
var batchDoWhile = true;
do {
var batchName = prompt("Enter the Batch Name: ");
var viewCourse = "";
for (var c of courseList) {
viewCourse +=
".Course Id - " +
c.course_Id +
" " +
".Course Name - " +
c.course_Name +
" " +
".Course Fees - " +
c.course_Fees +
"\n";
}
alert(viewCourse);
var batchCourse = prompt(
"Enter a Course which you want to add in the batch: "
);
var courseInd = -1;
for (var c of courseList) {
if (batchCourse == c.course_Name) {
courseInd = 0;
break;
}
}
if (courseInd == -1) {
alert("Invalid course name !!!");
} else {
var batchObject = {
batch_Id: batchId++,
batch_Name: batchName,
batch_Course: batchCourse,
};
batchList.push(batchObject);
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Create Batch \n2. Exit"
)
) == 2
) {
batchDoWhile = false;
}
} while (batchDoWhile);
break;
case 2:
//-------------------------------View Batch List--------------------------------------
var viewBatch = "";
for (var b of batchList) {
viewBatch +=
".Batch Id - " +
b.batch_Id +
" " +
".Batch Name - " +
b.batch_Name +
" " +
".Course in Batch - " +
b.batch_Course +
"\n";
}
alert(viewBatch);
break;
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Manage Batch \n2. Exit"
)
) == 2
) {
adminBatchDoWhile = false;
}
} while (adminBatchDoWhile);
break;
case 3:
//-------------------------------Manage Student--------------------------------------
var adminStudentDoWhile = true;
do {
var adminStudentChoice = parseInt(
prompt(
"Enter your choice: \n1. Register a Student \n2. View Students"
)
);
switch (adminStudentChoice) {
case 1:
//-------------------------------Register a Student--------------------------------------
var studentDoWhile = true;
do {
var studentName = prompt("Enter Name: ");
var studentUsername = prompt("Enter Username: ");
var studentPassword = prompt("Enter Password: ");
var studentCourseList = [];
var totalFees = 0;
var studentCourseDoWhile = true;
do {
var viewCourse = "";
for (var c of courseList) {
viewCourse +=
".Course Id - " +
c.course_Id +
" " +
".Course Name - " +
c.course_Name +
" " +
".Course Fees - " +
c.course_Fees +
"\n";
}
alert(viewCourse);
var studentCourse = prompt("Enter Course Name: ");
var courseInd = -1;
for (var c of courseList) {
if (studentCourse == c.course_Name) {
courseInd = 0;
totalFees += c.course_Fees;
break;
}
}
if (courseInd == -1) {
alert("Invalid course name !!!");
} else {
studentCourseList.push(studentCourse);
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Enter Course \n2. Exit"
)
) == 2
) {
studentCourseDoWhile = false;
}
} while (studentCourseDoWhile);
var studentBatchList = [];
var studentBatchDoWhile = true;
do {
var viewBatch = "";
for (var b of batchList) {
viewBatch +=
".Batch Id - " +
b.batch_Id +
" " +
".Batch Name - " +
b.batch_Name +
" " +
".Course in Batch - " +
b.batch_Course +
"\n";
}
alert(viewBatch);
var studentBatch = prompt("Enter Batch Id: ");
var batchInd = -1;
for (var b of batchList) {
if (studentBatch == b.batch_Id) {
batchInd = b.batch_Name;
break;
}
}
if (batchInd == -1) {
alert("Invalid Batch id !!!");
} else {
studentBatchList.push(batchInd);
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Enter Batch \n2. Exit"
)
) == 2
) {
studentBatchDoWhile = false;
}
} while (studentBatchDoWhile);
var totalInstallment = parseInt(
prompt("Enter how many installments ?")
);
var feesPerInstallment = totalFees / totalInstallment;
var feesBunch = [];
var installment = {
payment_id: 1,
payment: feesPerInstallment,
status: "paid",
};
feesBunch.push(installment);
for (var i = 2; i <= totalInstallment; i++) {
var installment = {
payment_id: i,
payment: feesPerInstallment,
status: "pending",
};
feesBunch.push(installment);
}
var studentData = {
student_id: studentId++,
student_name: studentName,
student_username: studentUsername,
student_password: studentPassword,
total_fees: totalFees,
total_installment: totalInstallment,
per_installment: feesPerInstallment,
remaining_fees: totalFees - feesPerInstallment,
remaining_installment: totalInstallment - 1,
status: "active",
fees_bunch: feesBunch,
};
studentList.push(studentData);
if (
parseInt(
prompt(
"Do still want to continue with \n1. Register a Student \n2. Exit"
)
) == 2
) {
studentDoWhile = false;
}
} while (studentDoWhile);
break;
case 2:
//-------------------------------View Students--------------------------------------
var studentOutputString = "";
for (var s of studentList) {
studentOutputString +=
".Student Id - " +
s.student_id +
" " +
".Name - " +
s.student_name +
" " +
".Username - " +
s.student_username +
" " +
"\n.Total Fees - " +
s.total_fees +
" " +
".Total Installments - " +
s.total_installment +
" " +
".Fees per Installment - " +
s.per_installment +
" " +
"\n.Remaining Installments - " +
s.remaining_installment +
" " +
".Remaining Fees - " +
s.remaining_fees +
" " +
".Status - " +
s.status +
"\n";
}
alert(studentOutputString);
break;
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Manage Student \n2. Exit"
)
) == 2
) {
adminStudentDoWhile = false;
}
} while (adminStudentDoWhile);
break;
case 4:
//-------------------------------Payment Collection--------------------------------------
var studentPaymentDoWhile = true;
do {
var studentOutputString = "";
for (var s of studentList) {
studentOutputString +=
".Student Id - " +
s.student_id +
" " +
".Name - " +
s.student_name +
" " +
".Remaining Installments - " +
s.remaining_installment +
" " +
".Remaining Fees - " +
s.remaining_fees +
"\n";
}
alert(studentOutputString);
var studentInputId = parseInt(
prompt(
"Enter Student Id from the above data whose fees you want to add ?"
)
);
var studentInputFeesBunch = -1;
for (var s of studentList) {
if (studentInputId == s.student_id) {
studentInputFeesBunch = s.fees_bunch;
for (var f of studentInputFeesBunch) {
if (f.status == "pending") {
f.status = "paid";
s.remaining_installment -= 1;
s.remaining_fees -= s.per_installment;
alert("Payment Collected Successfully !!!");
break;
}
}
break;
}
}
if (studentInputFeesBunch == -1) {
alert("Invalid student id !!!");
}
if (
parseInt(
prompt(
"Do still want to continue with \n1. Payment Collection \n2. Exit"
)
) == 2
) {
studentPaymentDoWhile = false;
}
} while (studentPaymentDoWhile);
break;
default:
alert("Enter appropriate choice..!!!");
break;
}
if (
parseInt(
prompt("Do still want to continue with \n1. Admin \n2. Exit")
) == 2
) {
adminDoWhile = false;
}
} while (adminDoWhile);
}
break;
case 2:
//-------------------------------Student Section--------------------------------------
var studentLoginUsername = prompt("Enter your Student Username: ");
var studentFlag = 0;
for (var s of studentList) {
if (studentLoginUsername == s.student_username) {
studentFlag = 1;
var studentUserPassword = prompt("Enter your Student Password: ");
if (studentUserPassword == s.student_password) {
studentFlag = 2;
alert("Login Successfull, Welcome to Student Side");
alert("Show installment structure: ");
var outputInstallmentString = "";
for (var p of s.fees_bunch) {
outputInstallmentString +=
".Payment Id - " +
p.payment_id +
" " +
".Payment - " +
p.payment +
" " +
".Status - " +
p.status +
"\n";
}
alert(outputInstallmentString);
break;
}
}
}
if (studentFlag == 0) {
alert("Invalid Student UserName !!!");
} else if (studentFlag == 1) {
alert("Invalid Student Password !!!");
}
break;
case 3:
//-------------------------------Exit from Portal--------------------------------------
alert("Thank You! for visiting our system...");
doWhile = false;
break;
default:
alert("Enter appropriate choice..!!!");
break;
}
} while (doWhile);
</script>