| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/onesolution.com.hk/onesupport/task/ |
Upload File : |
<?php
require_once(__DIR__ . '/../checkuser.php');
function index() {
global $dbh, $sqlsrv_dbh;
$get_keys = array('sort_by');
$get = array();
foreach ($get_keys as $get_key) {
$$get_key = isset($_GET[$get_key]) ? $_GET[$get_key] : null;
$get[$get_key] = &$$get_key;
}
//sorting
/*
1.Customer Name (A-Z)
2.Customer Name (Z-A)
3.Staff Name (A-Z)
3.Staff Name (Z-A)
*/
$sort_by_array = array(1 => "Customer Name (A-Z)", 2 => "Customer Name (Z-A)", 3 => "Staff Name (A-Z)", 4 => "Staff Name (Z-A)");
$sort_by = $_GET["sort_by"];
$sql_sort_by = "";
if($sort_by == 1){
$sql_sort_by = "ORDER BY customer.company_name ASC";
}else if($sort_by == 2){
$sql_sort_by = "ORDER BY customer.company_name DESC";
}else if($sort_by == 3){
$sql_sort_by = "ORDER BY staff.username ASC";
}else if($sort_by == 4){
$sql_sort_by = "ORDER BY staff.username DESC";
}else{
$sql_sort_by = "ORDER BY job.id DESC";
}
$sql = "
SELECT pending.*, job.staff_id, job.customer_id, job.date
FROM sup_job_pending pending
INNER JOIN sup_job job ON job.id = pending.job_id
INNER JOIN v_cm_customer_support customer ON job.customer_id = customer.cust_id
INNER JOIN sys_login staff ON job.staff_id = staff.id
WHERE pending.actived = ? AND pending.deleted = ?
".$sql_sort_by;
$parameters = array(
1, 0
);
$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,
'sort_by_array' => $sort_by_array,
'message' => $_GET['message'],
'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>Follow up Tasks</h2>
<!-- follow up task filter -->
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="hero-unit" style="padding:10px">
<a href="#" id="search_btn" class="btn btn-link"><h4><i class="icon-list-alt"></i> Search Form</h4>
</a>
<script type="text/javascript">
$(function () {
$('#search_btn').click(function (event) {
event.preventDefault();
$('#search_form').toggle();
});
$('.date-picker').datetimepicker({pickTime: false});
$('.time-picker').datetimepicker({pickDate: false, pickSeconds: false});
$('.select2').select2();
$('#search_form').validate();
});
</script>
<form id="search_form" class="form-horizontal" method="get">
<div class="control-group">
<?php $attribute = 'sort_by';
$label = 'Sort By'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select name="<?= $attribute ?>">
<option value="">Default</option>
<?php
foreach($sort_by_array as $key => $sort_by){
if($key == $_GET["sort_by"])
$selected = "selected";
else
$selected = "";
echo '<option value="'.$key.'" '.$selected.'>'.$sort_by.'</option>';
}
?>
</select>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary"><i class="icon-search icon-white"></i>
Search
</button>
<a href="test.php?show_all=1" class="btn">Show All</a>
</div>
</div>
</form>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
</div>
<!-- end of filter -->
<?=$pagination?>
<table class="table table-striped">
<caption class="text-left hide"><h2>Follow up Tasks</h2></caption>
<thead>
<tr>
<th> </th>
<th>Number</th>
<th>Customer</th>
<th style="width: 100px;">Staff</th>
<th style="width: 80px;">Job Date</th>
<th>Title</th>
<th style="width: 400px;">Remarks</th>
</tr>
</thead>
<tbody>
<?php foreach ($jobs as $job): ?>
<tr>
<td><a href="../job/modifyform.php?id=<?=$job['job_id']?>" target="_blank" class="btn"><i class="icon-pencil"></i></a></td>
<td><?=$job['job_id']?></td>
<td><?=h($job['customer']['company_name'])?></td>
<td><?=h($job['staff']['username'])?></td>
<td><?=h($job['date'])?></td>
<td><?=h($job['title'])?></td>
<td><?=nl2br(h($job['remarks']))?></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>