-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticket_list.php
201 lines (100 loc) · 3.74 KB
/
ticket_list.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
<?php include'db_connect.php' ?>
<div class="col-lg-12">
<div class="card card-outline card-info">
<div class="card-body">
<table class="table table-hover table-bordered" id="list">
<colgroup>
<col width="5%">
<col width="15%">
<col width="20%">
<col width="15%">
<col width="25%">
<col width="10%">
<col width="10%">
</colgroup>
<thead>
<tr>
<th>#</th>
<th>Date Created</th>
<th>Ticket</th>
<th>Subject</th>
<th>Description</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$where = '';
if($_SESSION['login_type'] == 2)
$where .= " where t.department_id = {$_SESSION['login_department_id']} ";
if($_SESSION['login_type'] == 3)
$where .= " where t.customer_id = {$_SESSION['login_id']} ";
$qry = $conn->query("SELECT t.*,concat(c.lastname,', ',c.firstname,' ',c.middlename) as cname FROM tickets t inner join customers c on c.id= t.customer_id $where order by unix_timestamp(t.date_created) desc");
while($row= $qry->fetch_assoc()):
$trans = get_html_translation_table(HTML_ENTITIES,ENT_QUOTES);
unset($trans["\""], $trans["<"], $trans[">"], $trans["<h2"]);
$desc = strtr(html_entity_decode($row['description']),$trans);
$desc=str_replace(array("<li>","</li>"), array("",", "), $desc);
?>
<tr>
<th class="text-center"><?php echo $i++ ?></th>
<td><b><?php echo date("M d, Y",strtotime($row['date_created'])) ?></b></td>
<td><b><?php echo ucwords($row['cname']) ?></b></td>
<td><b><?php echo $row['subject'] ?></b></td>
<td><b class="truncate"><?php echo strip_tags($desc) ?></b></td>
<td>
<?php if($row['status'] == 0): ?>
<span class="badge badge-primary">Pending/Open</span>
<?php elseif($row['status'] == 1): ?>
<span class="badge badge-Info">Processing</span>
<?php elseif($row['status'] == 2): ?>
<span class="badge badge-success">Done</span>
<?php else: ?>
<span class="badge badge-secondary">Closed</span>
<?php endif; ?>
</td>
<td class="text-center">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
Action
</button>
<div class="dropdown-menu" style="">
<a class="dropdown-item view_ticket" href="./index.php?page=view_ticket&id=<?php echo $row['id'] ?>" data-id="<?php echo $row['id'] ?>">View</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="./index.php?page=edit_ticket&id=<?php echo $row['id'] ?>">Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item delete_ticket" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>">Delete</a>
</div>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#list').dataTable()
$('.delete_ticket').click(function(){
_conf("Are you sure to delete this ticket?","delete_ticket",[$(this).attr('data-id')])
})
})
function delete_ticket($id){
start_load()
$.ajax({
url:'ajax.php?action=delete_ticket',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp==1){
alert_toast("Data successfully deleted",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
}
</script>