-
Notifications
You must be signed in to change notification settings - Fork 1
/
leave.php
105 lines (101 loc) · 3.98 KB
/
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
<?php
require('top.inc.php');
if(isset($_GET['type']) && $_GET['type']=='delete' && isset($_GET['id'])){
$id=mysqli_real_escape_string($con,$_GET['id']);
mysqli_query($con,"delete from `leave` where id='$id'");
}
if(isset($_GET['type']) && $_GET['type']=='update' && isset($_GET['id'])){
$id=mysqli_real_escape_string($con,$_GET['id']);
$status=mysqli_real_escape_string($con,$_GET['status']);
mysqli_query($con,"update `leave` set leave_status='$status' where id='$id'");
}
if($_SESSION['ROLE']==1){
$sql="select `leave`.*, employee.name,employee.id as eid from `leave`,employee where `leave`.employee_id=employee.id order by `leave`.id desc";
}else{
$eid=$_SESSION['USER_ID'];
$sql="select `leave`.*, employee.name ,employee.id as eid from `leave`,employee where `leave`.employee_id='$eid' and `leave`.employee_id=employee.id order by `leave`.id desc";
}
$res=mysqli_query($con,$sql);
?>
<div class="content pb-0">
<div class="orders">
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h4 class="box-title">Leave </h4>
<?php if($_SESSION['ROLE']==2){ ?>
<h4 class="box_title_link"><a href="add_leave.php">Add Leave</a> </h4>
<?php } ?>
</div>
<div class="card-body--">
<div class="table-stats order-table ov-h">
<table class="table ">
<thead>
<tr>
<th width="5%">S.No</th>
<th width="5%">ID</th>
<th width="15%">Employee Name</th>
<th width="14%">From</th>
<th width="14%">To</th>
<th width="15%">Description</th>
<th width="18%">Leave Status</th>
<th width="10%"></th>
</tr>
</thead>
<tbody>
<?php
$i=1;
while($row=mysqli_fetch_assoc($res)){?>
<tr>
<td><?php echo $i?></td>
<td><?php echo $row['id']?></td>
<td><?php echo $row['name'].' ('.$row['eid'].')'?></td>
<td><?php echo $row['leave_from']?></td>
<td><?php echo $row['leave_to']?></td>
<td><?php echo $row['leave_description']?></td>
<td>
<?php
if($row['leave_status']==1){
echo "Applied";
}if($row['leave_status']==2){
echo "Approved";
}if($row['leave_status']==3){
echo "Rejected";
}
?>
<?php if($_SESSION['ROLE']==1){ ?>
<select class="form-control" onchange="update_leave_status('<?php echo $row['id']?>',this.options[this.selectedIndex].value)">
<option value="">Update Status</option>
<option value="2">Approved</option>
<option value="3">Rejected</option>
</select>
<?php } ?>
</td>
<td>
<?php
if($row['leave_status']==1){ ?>
<a href="leave.php?id=<?php echo $row['id']?>&type=delete">Delete</a>
<?php } ?>
</td>
</tr>
<?php
$i++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function update_leave_status(id,select_value){
window.location.href='leave.php?id='+id+'&type=update&status='+select_value;
}
</script>
<?php
require('footer.inc.php');
?>