-
Notifications
You must be signed in to change notification settings - Fork 4
/
letter.php
210 lines (205 loc) · 7.41 KB
/
letter.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php confirm_logged_in(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>GVP Academics</title>
<link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<?php $message = "";
if($_GET['link']=="student"){
$uid = $_SESSION['user_id'];
$uname = $_SESSION['username'];
$page = "student.php";
}
else{
$uid = $_SESSION['user_id'];
$uname = $_SESSION['username'];
$page = "staff.php";
}
?>
<?php
if(isset($_POST['cancel']))
{
redirect_to($_SESSION['page']."?link=");
}
?>
<?php
if(isset($_POST['submit'])){
$place = $_POST['place'];
$d1 = $_POST['d1'];
$m1 = $_POST['m1'];
$y1 = $_POST['y1'];
$letterto = $_POST['letterto'];
$subject = $_POST['subject'];
$content = $_POST['content'];
$request = $_POST['request'];
if(isset($_POST['check']) && $_POST['check']== "1")
{
$d2 = $_POST['d2'];
$m2 = $_POST['m2'];
$y2 = $_POST['y2'];
$d3 = $_POST['d3'];
$m3 = $_POST['m3'];
$y3 = $_POST['y3'];
//code for leave letter************************************
if(notnull($place) && notnull($d1) && notnull($d2) && notnull($m1) && notnull($m2) && notnull($y1) && notnull($y2) && notnull($letterto) && notnull($subject) && notnull($content) && notnull($request) && notnull($d3) && notnull($m3) && notnull($y3)){
$date = $y1 . "-" . $m1 . "-" . $d1;
$fromdate = $y2 . "-" . $m2 . "-" . $d2;
$todate = $y3 . "-" . $m3 . "-" . $d3;
$qr = mysql_query("INSERT INTO letter values('', '{$uid}', '{$place}', '{$date}', '{$letterto}', '{$_SESSION['dept']}','{$subject}', '{$content}', '{$fromdate}', '{$todate}', '{$request}','0')") or die(mysql_error());
if(!$qr){
$message = "Submission failed..!";
}
else {
$message = "Succesfully sent";
}
}
else {
$message = "Every field must be filled in leave letter..!";
}
}
else
{
if(notnull($place) && notnull($d1) && notnull($m1) && notnull($y1) && notnull($letterto) && notnull($subject) && notnull($content) && notnull($request)){
$date = $y1 . "-" . $m1 . "-" . $d1;
$qr = mysql_query("INSERT INTO letter values('', '{$uid}', '{$place}', '{$date}', '{$letterto}', '{$_SESSION['dept']}','{$subject}', '{$content}', '', '', '{$request}','0')") or die(mysql_error());
if(!$qr){
$message = "Submission failed..!";
}
else {
$message = "Succesfully sent";
}
}
else {
$message = "Every field must be filled..!";
}
}
}
else
{
$d1 = "";
$d2 = "";
$d3 = "";
$m1 = "";
$m2 = "";
$m3 = "";
$y1 = "";
$y2 = "";
$y3 = "";
$place = "";
$request = "Kindly grant me permission...";
$content = "The content of the letter, reason ...";
$subject = "Requesting leave for...";
$letterto = "";
}
?>
<table id="structure">
<tr>
<td id="page">
<fieldset>
<legend align="center"><h2>Edit your Letter</h2></legend>
<table>
<form action="letter.php?link=<?php echo $_GET['link']; ?>" method="post" name="form1">
<?php if (!empty($message)) {echo "<tr><td><p id='err' class=\"message\">" . $message . "</p></td></tr>";} ?>
<tr>
<td><b>From (Place)</b></td><td>:<input type="text" name="place" value="<?php echo $place; ?>" ></td>
</tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td><b>Date </b></td><td><table><tr><td><select name="d1" ><option value="">day-</option><?php day(); ?></select></td><td><select name="m1"><option value="">month</option><?php month(); ?></select></td><td><select name="y1"><option value="">year</option><?php year(); ?></select></td></tr></table></td>
</tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td><b>Letter to</b></td><td>:<select name="letterto" ><option value="">--staff--</option><option value="">HOD</option><option value="">Principal</option>
<?php
$uid = $_SESSION['user_id'];
if($_SESSION['page'] == "student.php")
{
$dept = $_SESSION['dept'];
$semester = $_SESSION['semester'];
$section = $_SESSION['section'];
$subqry = mysql_query("select distinct(fid) from subject where dept = '{$dept}' and semester = '{$semester}' and section = '{$section}'");
if($subqry)
{
while($q = mysql_fetch_array($subqry))
{
$qry = mysql_query("select * from staff where fid = '{$q['fid']}'");
$fname = mysql_fetch_array($qry);
//$fname = mysql_fetch_array($qry);
echo '<option value="'.$fname['fid'].'">'. $fname['fusername'] .'</option>';
}
}
else $message = "No data found..!";
}
else
{
$qry = mysql_query("select fusername from staff where dept = '{$_SESSION['dept']}'");
while($fname = mysql_fetch_array($qry))
//$fname = mysql_fetch_array($qry);
echo '<option value="'.$_SESSION['user_id'].'">'. $fname['fusername'] .'</option>';
}
?>
</select></td></tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td><b>Subject</b></td><td>:<textarea type="text" name="subject" rows="3" cols="40"><?php echo $subject; ?></textarea></td>
</tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td><b>Content</b></td><td>:<textarea type="text" name="content" rows="3" cols="40"><?php echo $content; ?></textarea></td>
</tr>
<tr><td><p><input type="checkbox" name="check" id="active" value="1" onChange="myf()"/>Check, for Leave letter</p></td></tr>
<script type="text/javascript">
function myf()
{
if(document.form1.check.checked)
document.getElementById("active_sub").style.visibility="visible";
else
document.getElementById("active_sub").style.visibility="hidden";
}
</script>
<tr><td><h2> </h2></td><td>
<table style="visibility:hidden" id="active_sub">
<tr><td><b>From Date:</b></td>
<td>
<table>
<tr>
<td><select name='d2'><option value=''>-day-</option>"<?php echo day(); ?>"</select></td>
<td><select name='m2'><option value=''>-month-</option>"<?php echo month(); ?>"</select></td>
<td><select name='y2'><option value=''>-year-</option>"<?php echo year(); ?>"</select></td>
</tr>
</table>
</td>
</tr>
<tr><td><h3> </h3></td></tr>
<tr><td><b>To Date:</b></td>
<td>
<table>
<tr>
<td><select name='d3'><option value=''>-day-</option>"<?php echo day(); ?>"</select></td>
<td><select name='m3'><option value=''>-month-</option>"<?php echo month(); ?>"</select></td>
<td><select name='y3'><option value=''>-year-</option>"<?php echo year(); ?>"</select></td>
</tr>
</table>
</td>
</tr>
</table></td></tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td><b>Request</b></td><td>:<textarea type="text" name="request" rows="3" cols="40"><?php echo $request; ?></textarea></td>
</tr>
<tr><td><h3> </h3></td></tr>
<tr>
<td colspan="2"> </td><td><input type="submit" name="submit" value="Submit"></td><td><input type="submit" name="cancel" value="Cancel"></td></tr>
</form>
</table>
</fieldset>
</td>
</tr>
</table>
<?php include("includes/footer.php"); ?>