-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequestForm.php
176 lines (128 loc) · 4.94 KB
/
RequestForm.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
170
171
172
173
174
175
176
<?php
session_start();
$user_id= $_SESSION['id'];
require_once "database_connect.php";
// $service_name=$_POST['id_service'];
// echo $service_name;
if (isset($_POST['add_request']))
{
$pet=$_POST['pet'];
$service=$_POST['service'];
$date=$_POST['date'];
$note=$_POST['note'];
$id_appoointement=$_POST['app_id'];
$day;
if($id_appoointement!=null){
}
$q="SELECT id,day, time,services FROM appaintments_available";
$result=mysqli_query($conn,$q);
while ($row=mysqli_fetch_array($result)) {
if($row['id']==$id_appoointement)
{
$da=$row['day'];
$tim=$row['time'];
break;}
}
$query="INSERT INTO request_appointement(pet, service, day, time, note, status,user_id)
VALUES ('$pet','$service','$da','$tim','$note','waiting','$user_id')";
if ($conn->query($query) === TRUE) {
echo "<script> alert('Request Added Successfully');</script>";
$last_id = $conn->insert_id;
} else {
echo "<script> alert('Request Is Not Added');</script>";
echo "Error: " . $query . "<br>" . $conn->error;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Happy Paws Clinic </title>
<link rel ="stylesheet" href="css/RequestForm_Style.css">
<script>
const times = [];
function select_service(){
var select = document.getElementById('servi');
var value = select.options[select.selectedIndex].value;
// alert(value);
console.log(value);
document.getElementById('id_service').value=value;
// document.getElementById('id_service').submit;
var xmlhttp;
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else
xmlhttp = new ActiveXobject(" Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 & xmlhttp.status == 200)
document.getElementById("dat_time").innerHTML = xmlhttp.responseText;
}
xmlhttp.open("GET", "get_time_service.php?value=" + value, true);
xmlhttp.send();
}
function select(){
var select = document.getElementById('dat_time');
var value = select.options[select.selectedIndex].value;
// alert(value);
console.log(value);
document.getElementById('id').value=value;
}
</script>
</head>
<body style= "background-image:url(image/design.png);">
<?php include 'header.php'; ?>
<!-- Title -->
<h1 class="title">
Request an Appointment
</h1>
<!-- Request Form Area -->
<form method="post" action="RequestForm.php">
<!-- fieldset_requestEdit -->
<fieldset class="" style= "background-image:url(image/fieldset2.png);">
<!-- Select a pet -->
<p> <label class="labels">Pet:</label>
<select name ="pet" required>
<option value="">selects pet:</option>
<?php
$query="SELECT id, name FROM pets where user_id=$user_id";
$result=mysqli_query($conn,$query);
while ($row=mysqli_fetch_array($result)) {
echo "<option value=".$row['name'] . ">" . $row['name'] . "</option>";
}
?>
</select>
</p> <br> <hr> <br>
<!-- Select a service -->
<p> <label class="labels">Service:</label>
<select name = "service" required id="servi" onchange="select_service()" >
<option value="">selects Service:</option>
<?php
$query="SELECT name FROM services";
$result=mysqli_query($conn,$query);
while ($row=mysqli_fetch_array($result)) {
echo "<option value=".$row['name'] . ">" . $row['name'] . "</option>";}
?>
</select>
</p> <br> <hr> <br>
<p> <label class="labels">Available Dates and Times:</label>
<br> <br>
<input type="hidden" name="app_id" id="id" value="0">
<input type="hidden" name="id_service" id="id_service" value="0">
<select name ="date" required id="dat_time" onchange="select()" >
<option value="">select Dates and Times:</option>
<?php
?>
</select>
</form> <br> <hr> <br>
<!-- note -->
<p> <label class="labels">Note:</label> </p>
<br>
<textarea id ="note" name = "note" rows="5" cols="40"> Write here any special notes to take them into account.</textarea>
<br> <br> <br>
<input type = "submit" id="submit" value = "Submit" name="add_request" >
<a href="Home.php" id="link_id"> <button type = "button" id="bac_requset"> Cancel </button> </a>
</fieldset>
</form>
</body>
</html>