-
Notifications
You must be signed in to change notification settings - Fork 3
/
assignlocation.php
169 lines (162 loc) · 5.87 KB
/
assignlocation.php
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
<?php
session_start();
include_once "php/config.php";
$usersql=mysqli_query($conn,"SELECT * FROM users WHERE user_id={$_SESSION['unique_id']}");
$user=mysqli_fetch_assoc($usersql);
if($user['role']!=1)
{
header("location: mainpage.php");
}
include_once("navigation.php");
?>
<!-- this is a comment -->
<center><form action="" class="form-horizontal" method="post" name="myForm" id="formassign">
<br>
<br>
<input type="text" name="radiovalue" id="radiovalue" hidden>
<div class="form-group pt-2">
<div class="radio">
<label style="font-size: 16px"><input type="radio" id="compradio" name="optradio">Assign Location To Component</label>
</div>
<br>
<div class="radio">
<label style="font-size: 16px"><input type="radio" name="optradio" id="systemtradio">Assign Location To System </label>
</div>
</div>
<div class="form-group" id="inputcompcheck">
</div>
<div class="form-group" id="assigncomponents" hidden>
<center><h4 class="text-center"></h4>Assign Location To Component</center>
<br><br>
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-2">
<input type="text" class="form-control" id="assigncomponent" name="assigncomponent" placeholder="Component ID" required>
</div>
<div class="col-md-2">
<select id="compcat" class="dropdown" name="comploc" style="width:130px;height:30px">
<?php
$categorysql=mysqli_query($conn,"SELECT * FROM location");
$output ="";
while($category=mysqli_fetch_assoc($categorysql))
{
if($category['lab_name']!="STORE" and $category['lab_name']!="DISPOSED")
{
$output.='<option value="'.$category['lab_name'].'">'.$category['lab_name'].'</option>';
}
}
echo $output;
?>
</select>
<!-- </ul> -->
<!-- </div> -->
</div>
</div>
<br>
<br>
<div class="row">
<div class="col-md-5"></div>
<div class="col-md-1">
<button type="submit" class="btn btn-primary" id="assigncomponentbtn" name="add" style="margin-left:50px">Assign Location</button>
</div>
</div>
</div>
<br>
<div class="form-group" id="assignsystem" hidden>
<div class="row">
<center><h4 class="text-center">Assign Location To System</h4></center>
</div>
<br>
<br>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-2">
<input type="text" class="form-control" id="assignsystem" name="fromassignsystem" placeholder="From System ID" required>
</div>
<div class="col-md-2">
<input type="text" class="form-control" id="assignsystem" name="toassignsystem" placeholder="To System ID" required>
</div>
<div class="col-md-2">
<select id="compcat" class="dropdown" name="sysloc" style="width:130px;height:30px">
<?php
$categorysql=mysqli_query($conn,"SELECT * FROM location");
$output ="";
while($category=mysqli_fetch_assoc($categorysql))
{
if($category['lab_name']!="STORE" and $category['lab_name']!="DISPOSED")
{
$output.='<option value="'.$category['lab_name'].'">'.$category['lab_name'].'</option>';
}
}
echo $output;
?>
</select>
<!-- </ul> -->
<!-- </div> -->
</div>
</div>
<br>
<br>
<div class="row">
<div class="col-md-5"></div>
<div class="col-md-1">
<button type="submit" class="btn btn-primary" id="assignsystembtn" name="add" style="margin-left:50px">Assign Location</button>
</div>
</div>
</div>
<br>
<br>
</form></center><br><br><br>
<?php
include_once("footer.php");
?>
<script>
const form= document.querySelector("#formassign")
document.getElementById("systemtradio").onclick=(e)=>{
document.getElementById("radiovalue").value="systemradio";
document.getElementById("assigncomponents").style.display="none";
document.getElementById("assignsystem").style.display="block";
}
document.getElementById("compradio").onclick=(e)=>{
document.getElementById("radiovalue").value="compradio";
document.getElementById("assignsystem").style.display="none";
document.getElementById("assigncomponents").style.display="block";
}
document.getElementById("assignsystembtn").onclick=(e)=>{
e.preventDefault();
let xhr = new XMLHttpRequest();
xhr.open("POST", "php/assignsystem.php", true);
xhr.onload = ()=>{
if(xhr.readyState === XMLHttpRequest.DONE){
if(xhr.status === 200){
let data = xhr.response;
alert(data);
location.href("assignlocation.php");
}
}
}
let formData = new FormData(form);
xhr.send(formData);
}
document.getElementById("assigncomponentbtn").onclick=(e)=>
{
e.preventDefault();
let xhr = new XMLHttpRequest();
xhr.open("POST", "php/assigncomponent.php", true);
xhr.onload = ()=>{
if(xhr.readyState === XMLHttpRequest.DONE){
if(xhr.status === 200){
let data = xhr.response;
alert(data);
location.href("assignlocation.php");
}
}
}
let formData = new FormData(form);
xhr.send(formData);
}
</script>
</body>
</html>