-
Notifications
You must be signed in to change notification settings - Fork 1
/
appointment.php
191 lines (160 loc) · 4.68 KB
/
appointment.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
session_start();
?>
<?php
include("header.php");
if(isset($_POST[submit]))
{
if(isset($_GET[editid]))
{
$sql ="UPDATE appointment set appointment_title=$_POST[appointment_title],donor_id=$_POST[donor_id],staff_id=$_POST[staff_id], reason_for_appoinment=$_POST[reason_for_appoinment],appointment_date=$_POST[appointment_date],appointment_time=$_POST[appointment_time],status=$_POST[status] WHERE appointment_id=$_GET[editid]";
$qsql = mysqli_query($con,$sql);
if(mysqli_affected_rows($con) == 1)
{
echo "<script>alert(Appointment record updated successfully..);</script>";
}
else
{
echo mysqli_error($con);
}
}
else
{
$sql ="INSERT INTO appointment(appointment_title,donor_id,staff_id, reason_for_appoinment, appointment_date ,appointment_time ,status) VALUES($_POST[appointment_title],$_SESSION[donor_id],$_POST[staff_id],$_POST[reason_for_appoinment],$_POST[appointment_date],$_POST[appointment_time],Pending)";
$qsql = mysqli_query($con,$sql);
if(mysqli_affected_rows($con) == 1)
{
echo "<script>alert(Appointment Entry done successfully..);</script>";
echo "<script>window.location=viewappointment.php;</script>";
}
else
{
echo mysqli_error($con);
}
}
}
?>
<?php
if(isset($_GET[editid]))
{
$sqledit = "SELECT * FROM appointment WHERE appointment_id=$_GET[editid]";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
}
?>
<div id="page-header">
<div class="section-bg" style="background-image: url(img/background-2.jpg);"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="header-content">
<h1>Appoinment</h1>
</div>
</div>
</div>
</div>
</div>
</header>
<div class="section" style="padding-top: 1px;">
<div class="container">
<div class="row">
<main id="" class="col-md-12">
<div class="">
<div class="">
<div class="article-comments">
<div class="media">
<div class="media-left">
<img class="media-object" src="img/charity.jpg" style="width: 100px;height: 100px;">
</div>
<div class="media-body">
<div class="media-heading">
<h4>Visitor Appoinment Request Panel</h4>
</div>
<p>
<form method="post" action="" onsubmit="return validateform()">
<div class="row">
<div class="col-md-3" style="padding-top: 5px;">Appointment For </div>
<div class="col-md-9">
<input type="text" name="appointment_title" id="appointment_title" class="form-control" value="<?php echo $rsedit[appointment_title]; ?>">
<span id="errappointment_title" class="errorclass"></span>
</div>
</div>
<br>
<div class="row">
<div class="col-md-3" style="padding-top: 5px;"> Reason for Appointment </div>
<div class="col-md-9">
<textarea name="reason_for_appoinment" id="reason_for_appoinment" class="form-control"><?php echo $rsedit[reason_for_appoinment]; ?></textarea>
<span id="errreason_for_appoinment" class="errorclass"></span>
</div>
</div>
<br>
<div class="row">
<div class="col-md-3" style="padding-top: 5px;"> Appointment Date </div>
<div class="col-md-9">
<input type="date" name="appointment_date" id="appointment_date" class="form-control" min="<?php echo date("Y-m-d"); ?>" value="<?php echo $rsedit[appointment_date]; ?>">
<span id="errappointment_date" class="errorclass"></span>
</div>
</div>
<br>
<div class="row">
<div class="col-md-3" style="padding-top: 5px;"> Appointment Time </div>
<div class="col-md-9">
<input type="time" name="appointment_time" id="appointment_time" class="form-control" value="<?php echo $rsedit[appointment_time]; ?>">
<span id="errappointment_time" class="errorclass"></span>
</div>
</div>
<br>
<div class="row">
<div class="col-md-3" style="padding-top: 5px;"></div>
<div class="col-md-9">
<input type="submit" name="submit" id="submit" value="Request for Appoinment" class="form-control btn btn-success" style="width: 200px;">
</div>
</div>
</form>
</p>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</div>
<?php
include("footer.php");
?>
<script>
function validateform()
{
var i = 0;
$(.errorclass).html();
if(document.getElementById("appointment_title").value == "")
{
document.getElementById("errappointment_title").innerHTML = "Food item detail should not be empty..";
i=1;
}
if(document.getElementById("reason_for_appoinment").value == "")
{
document.getElementById("errreason_for_appoinment").innerHTML = "Quantity should not be empty..";
i=1;
}
if(document.getElementById("appointment_date").value == "")
{
document.getElementById("errappointment_date").innerHTML = "Address should not be empty..";
i=1;
}
if(document.getElementById("appointment_time").value == "")
{
document.getElementById("errappointment_time").innerHTML = "City should not be empty..";
i=1;
}
if(i == 0)
{
return true;
}
else
{
return false;
}
}
</script>