-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_add.html
79 lines (73 loc) · 3.56 KB
/
admin_add.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
<!DOCTYPE html>
<html>
<head>
<title>Add hospital</title>
<link rel="stylesheet" href="css\style16.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="split left">
<div class="userimg" >
<img src="other/avatar.png" style="width: 45%; height:60% ;padding: 15px; background-size: cover; border-radius: 110px;">
</div>
<div class="navbar">
<button class="btn" onclick="window.location.href='admin_addhospital.html'">Add Hospital</button>
<button class="btn" onclick="window.location.href='admin_approvefeedback.html'">Feebacks</button>
<button class="btn" style="background-color: white;" onclick="window.location.href='admin_add.html'">Add Medicines | Operations | Tests</button>
<button class="btn" onclick="window.location.href='admin_check.html'">Check Medicines | Operations | Tests</button>
</div>
</div>
<div class="split right">
<div class="header">Add another Medicine/Operation/Test</div>
<div class="card">
<form class="cardform"action="#">
<select class="box" id="type">
<option class="boxopt" value="" disabled selected hidden > Select type from below</option>
<option class="boxopt" value="Medical Test">Medical Test</option>
<option class="boxopt" value="Drug">Drug</option>
<option class="boxopt" value="Operation">Operation</option>
</select>
<input type="text" id="name" class="box" placeholder="Enter name of test/medicine/operation">
<input type="number" id="cost" class="box" placeholder="Enter the cost">
<button onclick="submitService()" class="submitbox" >Submit</button>
</form>
<h2 id="error" style="color: red;"></h2>
<h2 id="message" style="color: green;"></h2>
</div>
</div>
</body>
<script>
function submitService(){
let type = document.getElementById("type").value
let name = document.getElementById("name").value
let cost = document.getElementById("cost").value
if(type == "" || name == "" || cost == ""){
document.getElementById("error").innerHTML = "Missing Values !!!"
}else{
var myHeaders = new Headers();
myHeaders.append("Authorization", `Token ${localStorage.getItem('token')}`);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"name": name,
"type": type,
"cost": cost,
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:8000/servicesview/", requestOptions)
.then(response => response.text())
.then((result) => {
document.getElementById("message").innerHTML = "Service Successfully Added!!!"
})
.catch((error) => {
console.log(error)
document.getElementById("error").innerHTML = "There was some Error!! Please try again"
});
}
}
</script>
</html>