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
|
<?php require_once(__DIR__ . '/../checkuser.php'); function index() { global $dbh, $sqlsrv_dbh; // Check permission if (!Util::isAdmin()) { redirectAndExit(Util::link(__DIR__ . '/../main.php')); }
$sql = " SELECT job.* FROM sup_job job WHERE job.actived = ? AND job.deleted = ? AND job.`date` < ? AND (job.actual_start_time IS NULL OR job.actual_end_time IS NULL) AND job.status = ? ORDER BY job.id "; $parameters = array( 1, 0, date('Y-m-d'), 1, // job status: open ); $pagination = new MySqlPagination($sql, $parameters); $sql .= $pagination->getSqlLimitAndOffset(); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $jobs = $sth->fetchAll(); $sql = "SELECT * FROM v_cm_customer_support V_CM_CUSTOMER_SUPPORT ORDER BY company_name"; if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute()) { throw new Exception("sql execute statement failure: $sql"); } $customers = $sth->fetchAll(); $sql = "SELECT * FROM sys_login WHERE deleted = ? ORDER BY username"; $parameters = array(0); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $staffs = $sth->fetchAll(); $tmp_customer_map = array(); foreach ($customers as &$tmp_customer) { $tmp_customer_id = $tmp_customer['cust_id']; $tmp_customer_map[$tmp_customer_id] = $tmp_customer; } $tmp_staff_map = array(); foreach ($staffs as &$tmp_staff) { $tmp_staff_id = $tmp_staff['id']; $tmp_staff_map[$tmp_staff_id] = $tmp_staff; } foreach ($jobs as $tmp_key => &$tmp_job) { $tmp_customer_id = $tmp_job['customer_id']; $tmp_job['customer'] = $tmp_customer_map[$tmp_customer_id]; $tmp_staff_id = $tmp_job['staff_id']; $tmp_job['staff'] = $tmp_staff_map[$tmp_staff_id]; } return array( 'jobs' => $jobs, 'message' => $_GET['message'], 'statusOptions' => Job::statusOptions(), 'typeOptions' => Job::typeOptions(), 'pagination' => $pagination->toString(), ); } extract(index()); ?><!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php require(__DIR__ . '/../inc/_head_meta.php'); ?> <?php require(__DIR__ . '/../inc/_head_css.php'); ?> <style type="text/css"> body { padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ padding-bottom: 40px; } </style> <?php require(__DIR__ . '/../inc/_head_script.php'); ?> </head> <body> <?php require(__DIR__ . '/../inc/_navbar.php'); ?> <div class="container"> <?php if (isset($message) && !empty($message)): ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <h5 class="alert-heading">Note:</h5> <p><?=$message?></p> </div> <?php endif; ?>
<h2>Late Report Jobs</h2> <?=$pagination?>
<table class="table table-striped"> <caption class="text-left hide"><h2>Late Report Jobs</h2></caption> <thead> <tr> <th> </th> <th>Number</th> <th>Customer</th> <th>Date</th> <th>Time</th> <th>Staff</th> <th>Type</th> <th>Status</th> </tr> </thead> <tbody> <?php foreach ($jobs as $job): ?> <tr> <td><a href="../job/modifyform.php?id=<?=$job['id']?>" class="btn"><i class="icon-pencil"></i></a></td> <td><?=$job['id']?></td> <td><?=h($job['customer']['company_name'])?></td> <td><?=$job['date']?></td> <td> <?php ob_start(); ?> Time: <?=h(Util::value_to_time_string($job['start_time']))?> - <?=h(Util::value_to_time_string($job['end_time']))?> <br /> Actual Time: <?=h(Util::value_to_time_string($job['actual_start_time']))?> - <?=h(Util::value_to_time_string($job['actual_end_time']))?> <?php $tmp_title = ob_get_contents(); ob_end_clean(); ?> <a href="javascript:void(0)" class="job-time" data-toggle="tooltip" title="<?= htmlentities($tmp_title)?>"> <?=h(Util::value_to_time_string($job['start_time']))?> - <?=h(Util::value_to_time_string($job['end_time']))?> </a> </td> <td><?=h($job['staff']['username'])?></td> <td><?=h($typeOptions[$job['type']])?></td> <td> <?php ob_start(); ?> Open: <?=$job['detail_open_count']?> <br /> Completed: <?=$job['detail_completed_count']?> <br /> Follow up: <?=$job['detail_follow_up_count']?> <br /> Cancel: <?=$job['detail_cancel_count']?> <?php $tmp_title = ob_get_contents(); ob_end_clean(); ?> <a href="javascript:void(0)" class="job-status" data-toggle="tooltip" title="<?=htmlentities($tmp_title)?>"> <i class="<?=in_array($job['status'], array(1, 2)) ? 'icon-ok' : 'icon-remove'?>"></i> <?=h($statusOptions[$job['status']])?> </a> </td> </tr> <?php endforeach; ?> </tbody> </table> <?=$pagination?> <div class="scroll_to_top"> <a href="#" class="btn btn-link btn-mini scroll-to-top">Scroll to Top</a> </div> <script type="text/javascript"> $(function() { $('.scroll-to-top').click(function(event) { event.preventDefault(); scrollToTop(); }); }); </script> <?php require(__DIR__ . '/../inc/_footer.php'); ?>
</div> <!-- /container --> </body> </html>
|