-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathemployee_full_leave.php
275 lines (268 loc) · 9.58 KB
/
employee_full_leave.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysqli_error());
}
$select_db = mysqli_select_db($conn,'interns');
if(! $select_db)
{
die("database connection failed".mysqli_error($conn));
}
session_start();
$c1=1;
$abcx=0;
$sql1= "select leave_id from apply_leave order by leave_id desc";
$result1=mysqli_query($conn, $sql1);
while($user= mysqli_fetch_row($result1))
{
$abcx= $user[0];
break;
}
$abcx=$abcx+1;
if(isset($_POST['submit']))
{
if(!empty($_POST['reason']))
{
$myuserid= $_COOKIE["id"];
$myusername=$_COOKIE["name"];
$typeofleave=$_POST['position_1'];
$concernedmanager=$_POST['username'];
$mydate= $_POST['date'];
$mydate_1= $_POST['date_1'];
$reason_1=$_POST['reason'];
$now= strtotime($mydate_1);
$your_date= strtotime($mydate);
$datediff= $now - $your_date;
$count= ($datediff/(60*60*24))+0.5;
$sql = "INSERT INTO apply_leave".
"(leave_id, user_id,leave_type, user_name, type_of_leave,concerned_manager, time_of_leave, date, date_till, count_leave, reason, status)".
"VALUES($abcx, '$myuserid','full leave','$myusername' ,'$typeofleave', '$concernedmanager', 'null', '$mydate', '$mydate_1',$count,'$reason_1' ,'pending')";
$retval = mysqli_query($conn, $sql );
if($retval ) {
echo "Entered data successfully\n";
header("location:employee_full_leave.php");
}
die('Could not enter data: ' . mysql_error());
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Employee Area | Apply For Leave</title>
<link rel="icon" href="http://localhost/registration/logo.png">
<link href="http://localhost/registration/css/bootstrap.min.css" rel="stylesheet">
<link href="http://localhost/registration/css/style.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Employee Page</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li ><a href="http://localhost/registration/employee.php">Dashboard</a></li>
<li ><a href="http://localhost/registration/apply_for_leave.php">Short Leave</a></li>
<li class="active"><a href="http://localhost/registration/employee_full_leave.php">Full Leave</a></li>
<li><a href="http://localhost/registration/employee_approved_request.php">Approved</a></li>
<li><a href="http://localhost/registration/employee_pending_request.php">Pending</a></li>
<li><a href="http://localhost/registration/employee_rejected_request.php">Rejected</a></li>
<li ><a href="http://localhost/registration/employee_view_all.php">View All</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Welcome</a></li>
<li><a href="http://localhost/registration/change_password.php">Change Password</a></li>
<li><a href="http://localhost/registration/logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<header id="header">
<div class="container">
<div class="row">
<div class="col-md-10">
<h1><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Dashboard<small>Full Leave</small></h1>
</div>
</div>
</div>
</header>
<section id="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li class="active">Dashboard</li>
<li class="active">Apply For Full Leave</li>
</ol>
</div>
</section>
<section id="main" >
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="list-group ">
<a href="#" class="list-group-item active main-color-bg"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> User INFO</a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> User ID<span class="badge"><?php echo $_COOKIE["id"]. "<br />"; ?></span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> User Name<span class="badge"><?php echo $_COOKIE["name"] . "<br />"; ?></span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Approved Leaves<span class="badge">
<?php
$myid_1=$_COOKIE["id"];
$myname=$_COOKIE["name"];
$count=0;
$sql="select user_id from apply_leave where user_id='$myid_1' and status='approved'";
$result=mysqli_query($conn, $sql);
while($user=mysqli_fetch_row($result))
{
$count++;
}
echo $count;
?>
</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-th-list" aria-hidden="true"></span> Pending Leaves<span class="badge">
<?php
$myid_1=$_COOKIE["id"];
$myname=$_COOKIE["name"];
$count=0;
$sql="select user_id from apply_leave where user_id='$myid_1' and status='pending'";
$result=mysqli_query($conn, $sql);
while($user=mysqli_fetch_row($result))
{
$count++;
}
echo $count;
?>
</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Rejected Leaves<span class="badge">
<?php
$myid_1=$_COOKIE["id"];
$myname=$_COOKIE["name"];
$count=0;
$sql="select user_id from apply_leave where user_id='$myid_1' and status='rejected'";
$result=mysqli_query($conn, $sql);
while($user=mysqli_fetch_row($result))
{
$count++;
}
echo $count;
?>
</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-th" aria-hidden="true"></span> All Leaves<span class="badge">
<?php
$myid_1=$_COOKIE["id"];
$myname=$_COOKIE["name"];
$count=0;
$sql="select user_id from apply_leave where user_id='$myid_1'";
$result=mysqli_query($conn, $sql);
while($user=mysqli_fetch_row($result))
{
$count++;
}
echo $count;
?>
</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Total Leaves Allowed<span class="badge">15</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Remaining Medical Leaves<span class="badge">
<?php
$count=5;
$abc=0;
$myid_1=$_COOKIE["id"];
$sql5="select count_leave from apply_leave where type_of_leave='medical' and user_id='$myid_1' and status='approved'";
$result5=mysqli_query($conn, $sql5);
while($user=mysqli_fetch_row($result5))
{
$abc= $user[0];
}
$xyz= $count- $abc;
if($xyz<0)
echo 0;
else
echo $xyz;
?>
</span></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Remaining Non-Medical Leaves<span class="badge">
<?php
$count=10;
$abc=0;
$myid_1=$_COOKIE["id"];
$sql5="select count_leave from apply_leave where type_of_leave='non_medical' and user_id='$myid_1' and status='approved'";
$result5=mysqli_query($conn, $sql5);
while($user=mysqli_fetch_row($result5))
{
$abc= $user[0];
}
$xyz= $count- $abc;
if($xyz<0)
echo 0;
else
echo $xyz;
?>
</span></a>
</div>
</div>
<!-- Website Overview -->
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading main-color-bg">
<h3 class="panel-title">Apply For Leave</h3>
</div>
<div class="panel-body">
<form action="" method="POST">
<div class="form-group">
<label>Type Of Leave</label>
<select value="leave_type" name="position_1">
<option value="">Select</option>
<option value="medical">Medical</option>
<option value="non_medical" >Non-Medical</option>
</select>
</div>
<div class="form-group">
<label>Concerned Manager</label>
<?php
$sql="Select user_name from user where position='officer/scientist'";
$result = mysqli_query($conn ,$sql );
echo "<Select name='username'>";
while($row = mysqli_fetch_array($result))
{
echo "<option value='".$row['user_name']."'>".$row['user_name']."</option>";
}
echo"</select>";
?>
</div>
<div class="input-group">
<label>From</label>
<input type="date" id="date" name="date" >
</div>
<div class="input-group">
<label>Till</label>
<input type="date" id="date" name="date_1" >
</div>
<div class="input-group">
<label>Reason</label>
<input type="text" id="reason" name="reason" placeholder="Maximum 35 characters">
</div>
<div class="input-group">
<button type="submit" name="submit" class="btn">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<footer id="footer">
Copyright © WESEE-ANNEXE | Developed by: Manish Mishra
</footer>
</body>
</html>