191 lines
8.3 KiB
PHP
191 lines
8.3 KiB
PHP
<?php
|
|
|
|
use api\classes\API;
|
|
|
|
if (!defined('APP_INIT')) {
|
|
exit;
|
|
}
|
|
# IDE Section
|
|
|
|
# Includes Section
|
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
|
|
|
# Check permissions
|
|
$API = new API();
|
|
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
|
|
echo 'error 401 unauthorized';
|
|
exit;
|
|
}
|
|
|
|
# Page functions
|
|
|
|
# JS Scripts to load for this page
|
|
$jsScriptLoadData['delete_confirmation'] = true;
|
|
$jsScriptLoadData['stompjes'] = true;
|
|
$jsScriptLoadData['datatables'] = true;
|
|
$jsScriptLoadData['multiFilterSelect'] = true;
|
|
$jsScriptLoadData['datepicker'] = true;
|
|
|
|
# PageClasses Setup
|
|
|
|
|
|
# Retrieve Information for the page
|
|
$stmt = $GLOBALS['conn']->query("SELECT user_uuid, user_full_name, user_first_name, user_profile_picture_thumbnail, user_stompable, user_email FROM vc_users WHERE user_stompable = '1'");
|
|
$administrators = [];
|
|
while ($row = $stmt->fetch_assoc()) {
|
|
$administrators[$row['user_uuid']] = $row;
|
|
$administrators[$row['user_uuid']]['amount'] = 0;
|
|
}
|
|
|
|
if (!isset($_GET['fd'])) {
|
|
$SelectFromDate = strtotime(date('Y-m-01'));
|
|
} else {
|
|
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
|
|
$SelectFromDate = strtotime($date . ' 00:00:00');
|
|
}
|
|
if (!isset($_GET['td'])) {
|
|
$SelectTillDate = time();
|
|
} else {
|
|
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
|
|
$SelectTillDate = strtotime($date . ' 23:59:59');
|
|
}
|
|
|
|
$stompjes = array();
|
|
$stmt = $GLOBALS['conn']->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp FROM office_stompjes
|
|
INNER JOIN vc_users ON office_stompjes.user_uuid = vc_users.user_uuid
|
|
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
|
|
AND user_stompable = '1'
|
|
ORDER BY stomp_timestamp DESC");
|
|
while ($row = $stmt->fetch_assoc()) {
|
|
array_push($stompjes, $row);
|
|
$administrators[$row['user_uuid']]['amount']++;
|
|
}
|
|
|
|
# Start page output
|
|
?>
|
|
<script>
|
|
const stompData = <?php echo json_encode($stompjes); ?>;
|
|
</script>
|
|
|
|
<div class="form-group form-show-validation row mb-3">
|
|
<div class="col-5">
|
|
<h2>
|
|
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> <?php echo __('stompjeslist') ?>
|
|
</h2>
|
|
</div>
|
|
<div class="col d-flex justify-content-end px-1">
|
|
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-1">
|
|
<label>
|
|
<h5><?php echo __('from') ?>: </h5>
|
|
</label>
|
|
</div>
|
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
|
<div class="input-group">
|
|
<input type="text" id="fd" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectFromDate) ?>"/>
|
|
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
|
|
<label>
|
|
<h5><?php echo __('to') ?>: </h5>
|
|
</label>
|
|
</div>
|
|
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
|
|
<div class="input-group">
|
|
<input type="text" id="td" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectTillDate) ?>"/>
|
|
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
|
<a id="datePicker" class="btn btn-primary"><i class="fa-solid fa-arrow-rotate-right"></i></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<canvas id="stompjesChart" height="50"></canvas>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row align-content-center">
|
|
<?php foreach ($administrators as $administrator) {
|
|
if ($administrator['user_email'] != 'superuser') { ?>
|
|
<div class="col-sm-6 col-md-3 flex-shrink-0">
|
|
<div class="card card-stats card-round">
|
|
<div class="card-body">
|
|
<div class="row align-items-center">
|
|
<div class="col-icon">
|
|
<div class="avatar-l">
|
|
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrator['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
|
|
</div>
|
|
</div>
|
|
<div class="col col-stats ms-3 ms-sm-0">
|
|
<div class="numbers">
|
|
<p class="card-category"><?php echo $administrator['user_first_name'] ?></p>
|
|
<h4 class="card-title" id="count-<?php echo $administrator['user_uuid'] ?>"><?php echo $administrator['amount'] ?></h4>
|
|
</div>
|
|
</div>
|
|
<div class="col col-stats ms-3 ms-sm-0">
|
|
<a href="#" class="btn btn-warning btn-lg btn-rounded stomp-btn w-100 <?php echo (!$API->checkPermissions('ofice-stompjes-canstomp', 'RW', true)) ? 'disabled' : '' ?>" data-item-uuid="<?php echo $administrator['user_uuid'] ?>" data-item-name="user_uuid" data-api-url="/api/v1/office/stompjes/"><i class="fa-solid fa-hand-fist"></i></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php }
|
|
} ?>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,2,3" data-page-length="50">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th><?php echo __('first_name') ?></th>
|
|
<th><?php echo __('time') ?></th>
|
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
|
<th><?php echo __('actions') ?></th>
|
|
<?php } ?>
|
|
</tr>
|
|
</thead>
|
|
<tfoot>
|
|
<tr>
|
|
<th></th>
|
|
<th><?php echo __('first_name') ?></th>
|
|
<th><?php echo __('time') ?></th>
|
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
|
<th><?php echo __('actions') ?></th>
|
|
<?php } ?>
|
|
</tr>
|
|
</tfoot>
|
|
<tbody>
|
|
<?php foreach ($stompjes as $stompje) {
|
|
if ($administrators[$stompje['user_uuid']]['user_email'] != 'superuser') { ?>
|
|
<tr data-item-id="<?php echo $stompje['stomp_uuid']; ?>" data-user-uuid=<?php echo $stompje['user_uuid']; ?>>
|
|
<td class="text-nowrap">
|
|
<div class="avatar-sm ">
|
|
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrators[$stompje['user_uuid']]['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
|
|
</div>
|
|
</td>
|
|
<td class="text-nowrap"><?php echo $administrators[$stompje['user_uuid']]['user_first_name'] ?></td>
|
|
<td class="text-nowrap"><?php echo date('d-m-y H:i:s', $stompje['stomp_timestamp']) ?></td>
|
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
|
<td>
|
|
<a href="#" class="btn btn-danger btn-sm btn-rounded stomp-delete-btn" data-item-uuid="<?php echo $stompje['stomp_uuid'] ?>" data-api-url="/api/v1/office/stompjes/" data-item-name="stomp_uuid"><i class="fas fa-trash-alt"></i></a>
|
|
</td>
|
|
<?php } ?>
|
|
</tr>
|
|
<?php }
|
|
} ?>
|
|
</tbody>
|
|
</table>
|
|
<br>
|
|
</div>
|
|
</div>
|
|
</div>
|