-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddleave.php
191 lines (173 loc) · 7.47 KB
/
addleave.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 include('header.php');?>
<?php
include_once('controller/connect.php');
$dbs = new database();
$db=$dbs->connection();
$empid = $_SESSION['User']['EmployeeId'];
$sql = mysqli_query($db,"select * from type_of_leave ");
$leavedetails = mysqli_query($db,"select * from leavedetails where EmpId='$empid' ");
if(isset($_POST['Apply']))
{
$leave = $_POST['leavestatus'];
$reason = $_POST['reason'];
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
$leavestatus = "Pending";
/*date formate*/
$date = str_replace('/', '-', $startdate);
$startd = date('Y-m-d', strtotime($date));
$datee = str_replace('/', '-', $enddate);
$endd = date('Y-m-d', strtotime($datee));
/*end date formate*/
mysqli_query($db,"insert into leavedetails values(null,'$empid','$leave','$reason','$startd','$endd','$leavestatus')");
echo "<script>window.location='addleave.php';</script>";
}
?>
<ol class="breadcrumb" style="margin: 10px 0px ! important;">
<li class="breadcrumb-item"><a href="Home.php">Home</a><i class="fa fa-angle-right"></i>Leave<i class="fa fa-angle-right"></i>Add Leave</li>
</ol>
<form method="POST">
<div class="container-fluid" style="margin-bottom: 30px;margin-top: 10px; background: white;">
<div class="row">
<h2 style="color: #1abc9c;">Apply Leave</h2><hr>
<div class="col-md-5 control-label">
<label class="control-label">Type Leave</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-sun-o" aria-hidden="true"></i>
</span>
<select name="leavestatus" title="Select Leave" style="text-transform: capitalize; " required>
<option value="">-- Select leave --</option>
<?php while($row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?php echo $row['LeaveId']; ?>"><?php echo $row['Type_of_Name'];?></option>
<?php } ?>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="col-md-5 control-label">
<label class="control-label">Reason</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-pencil" aria-hidden="true"></i>
</span>
<input type="text" name="reason" class="form-control" required="">
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="col-md-5 control-label">
<label class="control-label">Start Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar" aria-hidden="true"></i>
</span>
<input type="text" id="StartDate" title="Select First Date" name="startdate" class="form-control" required="" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')">
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="col-md-5 control-label">
<label class="control-label">End Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar" aria-hidden="true"></i>
</span>
<input type="text" id="EndDate" name="enddate" title="Select End Date" class="form-control" required="" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')">
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="col-md-3 form-group">
<button type="submit" name="Apply" title="Apply" class="btn btn-primary">Apply</button>
<button type="reset" class="btn btn-default" title="Reset">Reset</button>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="validation-form" style="margin-bottom: 30px;margin-top: -10px; background: white; ">
<h2>View Leave</h2>
<div class="row" style="color: white; margin-right: 0; margin-left: 0;">
<div style="background: red;" class="col-md-1 control-label">
<h5>ID</h5>
</div>
<div style="background: red;" class="col-md-2 control-label">
<h5>Leave Status</h5>
</div>
<div style="background: red; " class="col-md-2 control-label">
<h5>Reason</h5>
</div>
<div style="background: red;" class="col-md-2 control-label">
<h5>Start Date</h5>
</div>
<div style="background: red;" class="col-md-2 control-label">
<h5>End Date</h5>
</div>
<div style="background: red;" class="col-md-1 control-label">
<h5>Status</h5>
</div>
<div style="background: red; text-align: center;" class="col-md-2 control-label">
<h5>Action</h5>
</div>
</div>
<?php $i=1; while($rom = mysqli_fetch_assoc($leavedetails)) {
$typeid = $rom['TypesLeaveId'];
$typename = mysqli_query($db,"select * from type_of_leave where LeaveId='$typeid' ");
$typen = mysqli_fetch_assoc($typename); ?>
<div class="row" style="margin-right: 0; margin-top: 10px; margin-left: 0;">
<div class="col-md-1" ><?php $i=$i; echo $i; $i++;?></div>
<div class="col-md-2"><?php echo ucfirst((isset($typen['Type_of_Name']))?$typen['Type_of_Name']:""); ?></div>
<div class="col-md-2" ><?php echo(isset($rom['Reason']))?$rom['Reason']:""; ?></div>
<div class="col-md-2"><?php echo(isset($rom['StateDate']))?$rom['StateDate']:""; ?></div>
<div class="col-md-2"><?php echo(isset($rom['EndDate']))?$rom['EndDate']:""; ?></div>
<div class="col-md-1"><?php echo(isset($rom['LeaveStatus']))?$rom['LeaveStatus']:""; ?></div>
<?php if($rom['LeaveStatus'] == "Pending") {?>
<div class="col-md-2" style="text-align: center;"><a onclick="history.go(0)" title="Refresh"><i class="la fa fa-refresh" style="color: #050100;" aria-hidden="true"></i></a></div>
<?php } else if($rom['LeaveStatus'] == "Accept"){ ?>
<div class="col-md-2" style="text-align: center;"><a title="Accept"><i class="fa fa-check" aria-hidden="true"> </i></a></div>
<?php } else {?>
<div class="col-md-2" style="text-align: center;"><a title="Denied"><i class="fa fa-times" style="color:#E83114;" aria-hidden="true"> </i></a></div>
<?php } ?>
</div><hr>
<?php }?>
</div>
</form>
<!--Font Awesome spin icon it code-->
<script>
$(".la").mouseover(function (e)
{
$(this).removeClass('fa fa-refresh')
$(this).addClass('fa fa-refresh fa-spin')
}).mouseout(function (e)
{
$(this).removeClass('fa fa-refresh fa-spin')
$(this).addClass('fa fa-refresh')
})
</script>
<!--Font Awesome code End-->
<?php include('footer.php'); ?>
<script type="text/javascript">
$('#EndDate').datetimepicker({
yearOffset:0,
lang:'ch',
timepicker:false,
format:'d/m/Y',
formatDate:'Y/m/d',
minDate:'2015/01/01', // yesterday is minimum date
maxDate:'2030/01/01' // and tommorow is maximum date calendar
});
$('#StartDate').datetimepicker({
yearOffset:0,
lang:'ch',
timepicker:false,
format:'d/m/Y',
formatDate:'Y/m/d',
minDate:'2015/01/01', // yesterday is minimum date
maxDate:'2030/01/01' // and tommorow is maximum date calendar
});
</script>