-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposition.php
More file actions
125 lines (111 loc) · 3.25 KB
/
position.php
File metadata and controls
125 lines (111 loc) · 3.25 KB
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
<?php include('db_connect.php');?>
<div class="container-fluid">
<div class="col-lg-12">
<div class="row mb-4 mt-4">
<div class="col-md-12">
</div>
</div>
<div class="row">
<!-- FORM Panel -->
<!-- Table Panel -->
<div class="col-md-12">
<div class="card">
<div class="card-header">
<b>Position List</b>
<span class="float:right"><button class="btn btn-primary btn-block btn-sm col-sm-2 float-right" type="button" id="new_leave">
<i class="fa fa-plus"></i> Add Position
</button></span>
</div>
<div class="card-body">
<table class="table table-condensed table-bordered table-hover">
<thead>
<tr>
<th class="text-center">#</th>
<th class="">Name</th>
<th class="">Department</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$dname[0] = "Unset";
$department = $conn->query("SELECT * FROM department");
while($row=$department->fetch_assoc()):
$dname[$row['id']] = ucwords($row['name']);
endwhile;
$position = $conn->query("SELECT * FROM position order by id asc");
while($row=$position->fetch_assoc()):
$department = isset($dname[$row['department_id']]) ? $dname[$row['department_id']] : "Department has been deleted.";
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td class="">
<p><b><?php echo ucwords($row['name']) ?></b></p>
</td>
<td>
<?php echo $department ?>
</td>
<td class="text-center">
<button class="btn btn-sm btn-outline-primary edit_position" type="button" data-id="<?php echo $row['id'] ?>" >Edit</button>
<button class="btn btn-sm btn-outline-danger delete_position" type="button" data-id="<?php echo $row['id'] ?>">Delete</button>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Table Panel -->
</div>
</div>
</div>
<style>
td{
vertical-align: middle !important;
}
td p{
margin: unset
}
img{
max-width:100px;
max-height: :150px;
}
</style>
<script>
$(document).ready(function(){
$('table').dataTable()
})
$('#new_leave').click(function(){
uni_modal("New position","manage_position.php")
})
$('.edit_position').click(function(){
uni_modal("Edit position","manage_position.php?id="+$(this).attr('data-id'))
})
$('.delete_position').click(function(){
_conf("Are you sure to delete this position?","delete_position",[$(this).attr('data-id')])
})
function delete_position($id){
start_load()
$.ajax({
url:'ajax.php?action=delete_position',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp){
resp = JSON.parse(resp);
if(resp.status == 1){
alert_toast("Data successfully saved",'success')
setTimeout(function(){
location.reload()
},1500)
}else{
$('#msg').html('<div class="alert alert-danger">'+resp.msg+'</div>')
end_load()
}
}
}
})
}
</script>