v.1.1 changes 16-04-2026:

- Minor changes to interface.
- Fixed different missing includes.
- Access now denied to api calls that are related to disabled modules.
- Fixed sorting of CPU and memory in server overview.
This commit is contained in:
2026-04-16 15:01:40 +02:00
parent 36b0ebd10c
commit eec1d13cf5
40 changed files with 26451 additions and 26428 deletions

View File

@@ -1,15 +1,15 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
}

View File

@@ -1,125 +1,126 @@
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
$stmt->bind_param('s', $company_uuid);
$stmt->execute();
$result = $stmt->get_result();
$company_data = $result->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('companies'), 'href' => '/companies/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $company_data['company_name'], 'href' => ''));
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$_GET['company_uuid'] = $company_uuid;
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
$API_servers->postedData = $_GET;
$API_servers->validateData($requiredFields);
$servers_data = $API_servers->getServers(true);
if (count($servers_data) > 0) {
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
$serverOverview->showDelBtn = false;
$serverOverview->showCompanies = false;
}
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>company_uuid:</td>
<td><?php echo $company_data['company_uuid'] ?></td>
</tr>
<tr>
<td>source_uuid:</td>
<td><?php echo $company_data['source_uuid'] ?></td>
</tr>
<tr>
<td>company_source_id:</td>
<td><?php echo $company_data['company_source_id'] ?></td>
</tr>
<tr>
<td>company_source_id2:</td>
<td><?php echo $company_data['company_source_id2'] ?></td>
</tr>
<tr>
<td>company_name:</td>
<td><?php echo $company_data['company_name'] ?></td>
</tr>
<tr>
<td>company_state:</td>
<td><?php echo $company_data['company_state'] ?></td>
</tr>
<tr>
<td>company_create_timestamp:</td>
<td><?php echo $company_data['company_create_timestamp'] ?></td>
</tr>
<tr>
<td>company_modified_timestamp:</td>
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<?php
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
if (count($servers_data) > 0) {
$serverOverview->serverOverviewOutPut();
}
}
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
$stmt->bind_param('s', $company_uuid);
$stmt->execute();
$result = $stmt->get_result();
$company_data = $result->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('companies'), 'href' => '/companies/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $company_data['company_name'], 'href' => ''));
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$_GET['company_uuid'] = $company_uuid;
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
$API_servers->postedData = $_GET;
$API_servers->validateData($requiredFields);
$servers_data = $API_servers->getServers(true);
if (count($servers_data) > 0) {
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
$serverOverview->showDelBtn = false;
$serverOverview->showCompanies = false;
}
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>company_uuid:</td>
<td><?php echo $company_data['company_uuid'] ?></td>
</tr>
<tr>
<td>source_uuid:</td>
<td><?php echo $company_data['source_uuid'] ?></td>
</tr>
<tr>
<td>company_source_id:</td>
<td><?php echo $company_data['company_source_id'] ?></td>
</tr>
<tr>
<td>company_source_id2:</td>
<td><?php echo $company_data['company_source_id2'] ?></td>
</tr>
<tr>
<td>company_name:</td>
<td><?php echo $company_data['company_name'] ?></td>
</tr>
<tr>
<td>company_state:</td>
<td><?php echo $company_data['company_state'] ?></td>
</tr>
<tr>
<td>company_create_timestamp:</td>
<td><?php echo $company_data['company_create_timestamp'] ?></td>
</tr>
<tr>
<td>company_modified_timestamp:</td>
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<?php
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
if (count($servers_data) > 0) {
$serverOverview->serverOverviewOutPut();
}
}
?>

View File

@@ -1,137 +1,137 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
use api\classes\API;
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('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['activateCompany'] = true;
# PageClasses Setup
# Retrieve Information for the page
if (!isset($_GET['all'])) {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid WHERE company_state = 'active' GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
} else {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
}
$stmt = $GLOBALS['conn']->query($query);
$stompjes = array();
$companies = [];
while ($row = $stmt->fetch_assoc()) {
$companies[$row['company_uuid']] = $row;
}
# Start page output
?>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> &nbsp; <?php echo __('companies') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['all'])) { ?>
<a class="btn btn-secondary" href="?all">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_all') ?>
</a>
<?php } else { ?>
<a class="btn btn-secondary" href="?">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_active') ?>
</a>
<?php } ?>
</div> &nbsp;
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden">
<div class="col-lg-auto col-md-auto col-sm-auto">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;<?php echo __('sync') ?>
</button>
</div>
</form>
</div>
</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,1,2,4" data-page-length="50">
<thead>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</tfoot>
<tbody>
<?php foreach ($companies as $company) { ?>
<tr data-item-id="<?php echo $company['company_uuid'] ?>">
<td class="text-nowrap"><?php echo $company['company_name'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id2'] ?></td>
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
<?php } ?>
<td>
<a href="/companies?view=<?php echo $company['company_uuid'] ?>" class="btn btn-info btn-sm btn-rounded" data-item-uuid="<?php echo $company['company_uuid'] ?>"><i class="fa-solid fa-eye"></i></a>
<?php if ($API->checkPermissions('customer-companies', 'RW', true) && $company['server_count'] == 0) { ?>
<a class="btn btn-<?php echo ($company['company_state'] != 'active') ? 'success' : 'danger' ?> btn-sm btn-rounded" data-item-company-state="" data-item-uuid="<?php echo $company['company_uuid'] ?>" data-item-state="<?php echo $company['company_state'] ?>"><i class="fa-solid <?php echo ($company['company_state'] != 'active') ? 'fa-plus' : 'fa-xmark' ?>"></i></a>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
use api\classes\API;
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('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['activateCompany'] = true;
# PageClasses Setup
# Retrieve Information for the page
if (!isset($_GET['all'])) {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid WHERE company_state = 'active' GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
} else {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
}
$stmt = $GLOBALS['conn']->query($query);
$stompjes = array();
$companies = [];
while ($row = $stmt->fetch_assoc()) {
$companies[$row['company_uuid']] = $row;
}
# Start page output
?>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> &nbsp; <?php echo __('companies') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['all'])) { ?>
<a class="btn btn-secondary" href="?all">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_all') ?>
</a>
<?php } else { ?>
<a class="btn btn-secondary" href="?">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_active') ?>
</a>
<?php } ?>
</div> &nbsp;
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden">
<div class="col-lg-auto col-md-auto col-sm-auto">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;<?php echo __('sync') ?>
</button>
</div>
</form>
</div>
</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,1,2,4" data-page-length="50">
<thead>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</tfoot>
<tbody>
<?php foreach ($companies as $company) { ?>
<tr data-item-id="<?php echo $company['company_uuid'] ?>">
<td class="text-nowrap"><?php echo $company['company_name'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id2'] ?></td>
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
<?php } ?>
<td>
<a href="/companies?view=<?php echo $company['company_uuid'] ?>" class="btn btn-info btn-sm btn-rounded" data-item-uuid="<?php echo $company['company_uuid'] ?>"><i class="fa-solid fa-eye"></i></a>
<?php if ($API->checkPermissions('customer-companies', 'RW', true) && $company['server_count'] == 0) { ?>
<a class="btn btn-<?php echo ($company['company_state'] != 'active') ? 'success' : 'danger' ?> btn-sm btn-rounded" data-item-company-state="" data-item-uuid="<?php echo $company['company_uuid'] ?>" data-item-state="<?php echo $company['company_state'] ?>"><i class="fa-solid <?php echo ($company['company_state'] != 'active') ? 'fa-plus' : 'fa-xmark' ?>"></i></a>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>

View File

@@ -1,196 +1,196 @@
<?php
use api\classes\API;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
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> &nbsp; <?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>
<?php
use api\classes\API;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
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> &nbsp; <?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>

View File

@@ -1,2 +1,2 @@
<?php
<?php
echo '404 not found';

View File

@@ -1,15 +1,15 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
}

View File

@@ -1,459 +1,460 @@
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['codeblocks'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
$stmt->bind_param('s', $server_uuid);
$stmt->execute();
$result = $stmt->get_result();
$server_data = $result->fetch_assoc();
if ($GLOBALS['modules_enabled']['customers']) {
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
$companies = array();
while ($company_data = $companies_data->fetch_assoc()) {
array_push($companies, $company_data);
}
}
# Retrieve Information for the page
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups WHERE user_group_type = 'admin' ORDER BY user_group_weight DESC");
# memory
$mem = isset($server_data['server_memory']) ? (float)$server_data['server_memory'] : 0;
$demand = isset($server_data['server_memory_demand']) ? (float)$server_data['server_memory_demand'] : 0;
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
# disks
$disks = json_decode($server_data['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
}
$server_state_color = returnServerStateColor($server_data['server_state']);
# Licences
$licenses = json_decode($server_data['server_licenses'], true);
#
# OS Logo display
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
$logos = [
'almalinux' => 'almalinux',
'centos' => 'centos',
];
$logo = $logos[$baseos] ?? 'server';
if ($API->checkPermissions('servers', 'RW', true)) {
$pageNavbar->AddHTMLButton(
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=' . $server_data['server_uuid'] . '">
<input type="hidden" name="server_vm_id" value="' . $server_data['server_vm_id'] . '"/>' .
(
$server_data['server_state'] != 'deleted'
? '<input type="hidden" name="server_state" value="deleted">
<button class="btn btn-danger w-100">
<i class="fas fa-trash-alt"></i> Delete
</button>'
: '<input type="hidden" name="server_state" value="disabled">
<button class="btn btn-primary w-100">
<i class="fa-solid fa-clock-rotate-left"></i> Restore
</button>'
) .
'</form>'
);
};
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"> </i> <?php echo $server_data['server_vm_host_name'] ?>
<span class="badge bg-<?php echo $server_state_color ?> fs-4 align-middle"><?php echo ucfirst($server_data['server_state']) ?></span>
</h1>
</div>
<div class="row pb-5">
<div class="col-md-3 col-lg-3">
<h2><?php echo $server_data['server_os'] ?></h2>
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
</div>
<div class="col-lg-auto col-md-auto">
<table class="table table-borderless">
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=<?php echo $server_data['server_uuid'] ?>">
<input type="hidden" name="server_vm_id" value="<?php echo $server_data['server_vm_id'] ?>"/>
<tr>
<td>
<h4>
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</h4>
</td>
<td class="mx-3">
<h4>
<?php
if (is_array($disks) && count($disks) > 0) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
} ?>
</h4>
</td>
</tr>
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
<tr>
<td>
<h4>
<i class="fas fa-building"></i> <?php echo __('company') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<div class="input-group">
<select id="company_uuid" name="company_uuid" class="form-control">
<option></option>
<?php foreach ($companies as $company) { ?>
<option <?php echo ($server_data['company_uuid'] == $company['company_uuid']) ? 'selected' : '' ?> value="<?php echo $company['company_uuid'] ?>"><?php echo $company['company_name'] ?></option>
<?php } ?>
</select>
</div>
<?php } else { ?>
<h4>
<?php
$companyMap = array_column($companies, 'company_name', 'company_uuid');
echo $companyMap[$server_data['company_uuid']] ?? null;
?>
</h4>
<?php } ?>
</td>
</tr>
<?php } ?>
<tr>
<td>
<h4>
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) {
if ($server_data['server_state'] != 'deleted') { ?>
<div class="input-group">
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
<option></option>
<option <?php echo ($server_data['server_state'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
<option <?php echo ($server_data['server_state'] == 'trial') ? 'selected' : '' ?> value="trial">Trial</option>
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
</select>
</div>
<?php } else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php }
} else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php } ?>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
</h4>
</td>
<td>
<h4>
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
</h4>
</td>
</tr>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<tr>
<td></td>
<td>
<button class="btn btn-rounded btn-success w-100">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
</td>
</tr>
<?php } ?>
</form>
</table>
</div>
</div>
<?php if (is_array($disks) && count($disks) > 0) { ?>
<h2 class="">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($disks as $disk) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $disk['disk_name'] ?>">
<div class="card-header py-1" id="heading<?php echo $disk['disk_name'] ?>">
<h4 class="mb-0">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
</h4>
</div>
</a>
<div id="collapse<?php echo $disk['disk_name'] ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<table class="table table-borderless table-sm">
<tr>
<td><?php echo __('disk_space') ?>:</td>
<td><?php echo $disk['disk_space'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_file_used') ?>:</td>
<td><?php echo $disk['disk_used'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_location') ?>:</td>
<td><?php echo $disk['disk_location'] ?></td>
</tr>
</table>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php }
if (is_array($licenses) && count($licenses) > 0) { ?>
<h2>
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($licenses as $key => $licence) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
<h4 class="mb-0">
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
</h4>
</div>
</a>
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<?php echo __('type') . ': ' . end($licence) ?>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php } ?>
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
<div class="col-md-12 col-lg-12">
<table class="table table-borderless table-sm table-responsive">
<tr>
<td>server_uuid:</td>
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
</tr>
<tr>
<td>company_uuid:</td>
<td><?php echo $server_data['company_uuid'] ?></td>
</tr>
<tr>
<td>server_vm_id:</td>
<td><?php echo $server_data['server_vm_id'] ?></td>
</tr>
<tr>
<td>server_vm_host_name:</td>
<td><?php echo $server_data['server_vm_host_name'] ?></td>
</tr>
<tr>
<td>server_vm_snapshot:</td>
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
</tr>
<tr>
<td>server_vm_generation:</td>
<td><?php echo $server_data['server_vm_generation'] ?></td>
</tr>
<tr>
<td>server_power_state:</td>
<td><?php echo $server_data['server_power_state'] ?></td>
</tr>
<tr>
<td>server_state:</td>
<td><?php echo $server_data['server_state'] ?></td>
</tr>
<tr>
<td>server_hostname:</td>
<td><?php echo $server_data['server_hostname'] ?></td>
</tr>
<tr>
<td>server_os:</td>
<td><?php echo $server_data['server_os'] ?></td>
</tr>
<tr>
<td>server_cpu:</td>
<td><?php echo $server_data['server_cpu'] ?></td>
</tr>
<tr>
<td>server_memory:</td>
<td><?php echo $server_data['server_memory'] ?></td>
</tr>
<tr>
<td>server_memory_demand:</td>
<td><?php echo $server_data['server_memory_demand'] ?></td>
</tr>
<tr>
<td>server_disks:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_disks']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv4:</td>
<td>
<pre class="bg-dark border rounded w-100 overflow-auto mb-0"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv4']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv6:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv6']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_licenses:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_licenses']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_backup:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_backup']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_description:</td>
<td><?php echo $server_data['server_description'] ?></td>
</tr>
<tr>
<td>server_create_timestamp:</td>
<td><?php echo $server_data['server_create_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_create_timestamp']) ?>)</td>
</tr>
<tr>
<td>server_modified_timestamp:</td>
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
</tr>
</table>
</div>
</div>
</div>
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['codeblocks'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
$stmt->bind_param('s', $server_uuid);
$stmt->execute();
$result = $stmt->get_result();
$server_data = $result->fetch_assoc();
if ($GLOBALS['modules_enabled']['customers']) {
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
$companies = array();
while ($company_data = $companies_data->fetch_assoc()) {
array_push($companies, $company_data);
}
}
# Retrieve Information for the page
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups WHERE user_group_type = 'admin' ORDER BY user_group_weight DESC");
# memory
$mem = isset($server_data['server_memory']) ? (float)$server_data['server_memory'] : 0;
$demand = isset($server_data['server_memory_demand']) ? (float)$server_data['server_memory_demand'] : 0;
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
# disks
$disks = json_decode($server_data['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
}
$server_state_color = returnServerStateColor($server_data['server_state']);
# Licences
$licenses = json_decode($server_data['server_licenses'], true);
#
# OS Logo display
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
$logos = [
'almalinux' => 'almalinux',
'centos' => 'centos',
];
$logo = $logos[$baseos] ?? 'server';
if ($API->checkPermissions('servers', 'RW', true)) {
$pageNavbar->AddHTMLButton(
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=' . $server_data['server_uuid'] . '">
<input type="hidden" name="server_vm_id" value="' . $server_data['server_vm_id'] . '"/>' .
(
$server_data['server_state'] != 'deleted'
? '<input type="hidden" name="server_state" value="deleted">
<button class="btn btn-danger w-100">
<i class="fas fa-trash-alt"></i> Delete
</button>'
: '<input type="hidden" name="server_state" value="disabled">
<button class="btn btn-primary w-100">
<i class="fa-solid fa-clock-rotate-left"></i> Restore
</button>'
) .
'</form>'
);
};
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"> </i> <?php echo $server_data['server_vm_host_name'] ?>
<span class="badge bg-<?php echo $server_state_color ?> fs-4 align-middle"><?php echo ucfirst($server_data['server_state']) ?></span>
</h1>
</div>
<div class="row pb-5">
<div class="col-md-3 col-lg-3">
<h2><?php echo $server_data['server_os'] ?></h2>
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
</div>
<div class="col-lg-auto col-md-auto">
<table class="table table-borderless">
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=<?php echo $server_data['server_uuid'] ?>">
<input type="hidden" name="server_vm_id" value="<?php echo $server_data['server_vm_id'] ?>"/>
<tr>
<td>
<h4>
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</h4>
</td>
<td class="mx-3">
<h4>
<?php
if (is_array($disks) && count($disks) > 0) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
} ?>
</h4>
</td>
</tr>
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
<tr>
<td>
<h4>
<i class="fas fa-building"></i> <?php echo __('company') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<div class="input-group">
<select id="company_uuid" name="company_uuid" class="form-control">
<option></option>
<?php foreach ($companies as $company) { ?>
<option <?php echo ($server_data['company_uuid'] == $company['company_uuid']) ? 'selected' : '' ?> value="<?php echo $company['company_uuid'] ?>"><?php echo $company['company_name'] ?></option>
<?php } ?>
</select>
</div>
<?php } else { ?>
<h4>
<?php
$companyMap = array_column($companies, 'company_name', 'company_uuid');
echo $companyMap[$server_data['company_uuid']] ?? null;
?>
</h4>
<?php } ?>
</td>
</tr>
<?php } ?>
<tr>
<td>
<h4>
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) {
if ($server_data['server_state'] != 'deleted') { ?>
<div class="input-group">
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
<option></option>
<option <?php echo ($server_data['server_state'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
<option <?php echo ($server_data['server_state'] == 'trial') ? 'selected' : '' ?> value="trial">Trial</option>
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
</select>
</div>
<?php } else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php }
} else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php } ?>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
</h4>
</td>
<td>
<h4>
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
</h4>
</td>
</tr>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<tr>
<td></td>
<td>
<button class="btn btn-rounded btn-success w-100">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
</td>
</tr>
<?php } ?>
</form>
</table>
</div>
</div>
<?php if (is_array($disks) && count($disks) > 0) { ?>
<h2 class="">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($disks as $i => $disk) {
$collapseId = 'collapseDisk' . $i; ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $collapseId ?>">
<div class="card-header py-1" id="heading<?php echo $collapseId ?>">
<h4 class="mb-0">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
</h4>
</div>
</a>
<div id="collapse<?php echo $collapseId ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<table class="table table-borderless table-sm">
<tr>
<td><?php echo __('disk_space') ?>:</td>
<td><?php echo $disk['disk_space'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_file_used') ?>:</td>
<td><?php echo $disk['disk_used'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_location') ?>:</td>
<td><?php echo $disk['disk_location'] ?></td>
</tr>
</table>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php }
if (is_array($licenses) && count($licenses) > 0) { ?>
<h2>
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($licenses as $key => $licence) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
<h4 class="mb-0">
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
</h4>
</div>
</a>
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<?php echo __('type') . ': ' . end($licence) ?>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php } ?>
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
<div class="col-md-12 col-lg-12">
<table class="table table-borderless table-sm table-responsive">
<tr>
<td>server_uuid:</td>
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
</tr>
<tr>
<td>company_uuid:</td>
<td><?php echo $server_data['company_uuid'] ?></td>
</tr>
<tr>
<td>server_vm_id:</td>
<td><?php echo $server_data['server_vm_id'] ?></td>
</tr>
<tr>
<td>server_vm_host_name:</td>
<td><?php echo $server_data['server_vm_host_name'] ?></td>
</tr>
<tr>
<td>server_vm_snapshot:</td>
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
</tr>
<tr>
<td>server_vm_generation:</td>
<td><?php echo $server_data['server_vm_generation'] ?></td>
</tr>
<tr>
<td>server_power_state:</td>
<td><?php echo $server_data['server_power_state'] ?></td>
</tr>
<tr>
<td>server_state:</td>
<td><?php echo $server_data['server_state'] ?></td>
</tr>
<tr>
<td>server_hostname:</td>
<td><?php echo $server_data['server_hostname'] ?></td>
</tr>
<tr>
<td>server_os:</td>
<td><?php echo $server_data['server_os'] ?></td>
</tr>
<tr>
<td>server_cpu:</td>
<td><?php echo $server_data['server_cpu'] ?></td>
</tr>
<tr>
<td>server_memory:</td>
<td><?php echo $server_data['server_memory'] ?></td>
</tr>
<tr>
<td>server_memory_demand:</td>
<td><?php echo $server_data['server_memory_demand'] ?></td>
</tr>
<tr>
<td>server_disks:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_disks']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv4:</td>
<td>
<pre class="bg-dark border rounded w-100 overflow-auto mb-0"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv4']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv6:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv6']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_licenses:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_licenses']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_backup:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_backup']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_description:</td>
<td><?php echo $server_data['server_description'] ?></td>
</tr>
<tr>
<td>server_create_timestamp:</td>
<td><?php echo $server_data['server_create_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_create_timestamp']) ?>)</td>
</tr>
<tr>
<td>server_modified_timestamp:</td>
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
</tr>
</table>
</div>
</div>
</div>

View File

@@ -1,67 +1,67 @@
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
if (!isset($_GET['del'])) {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted'";
} else {
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
}
} else {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
} else {
$API_servers->baseQuery = "SELECT * FROM servers";
}
}
$servers_data = $API_servers->getServers();
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
if (!$GLOBALS['modules_enabled']['customers']) {
$serverOverview->showCompanies = false;
}
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
# Start page output
$serverOverview->serverOverviewOutPut();
?>
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
if (!isset($_GET['del'])) {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted'";
} else {
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
}
} else {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
} else {
$API_servers->baseQuery = "SELECT * FROM servers";
}
}
$servers_data = $API_servers->getServers();
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
if (!$GLOBALS['modules_enabled']['customers']) {
$serverOverview->showCompanies = false;
}
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
# Start page output
$serverOverview->serverOverviewOutPut();
?>

View File

@@ -1,173 +1,173 @@
<?php
use api\classes\API_usergroups;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
# Check permissions
$API = new API_usergroups();
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['updatePermissions'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
$_GET['user_group_uuid'] = $user_group_uuid;
$API_usergroups = new API_usergroups();
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
$API_usergroups->validateData($requiredFields);
$user_group = $API_usergroups->getUsergroup()[0];
$query = "SELECT * FROM vc_user_group_permissions_portal
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
WHERE user_group_uuid = ?";
$stmt = $GLOBALS['pdo']->prepare($query);
$stmt->execute([$user_group_uuid]);
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_gr1oups'), 'href' => '/accesscontrol/#user-groups'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>user_group_uuid:</td>
<td><?php echo $user_group['user_group_uuid'] ?></td>
</tr>
<tr>
<td>user_group_name:</td>
<td><?php echo $user_group['user_group_name'] ?></td>
</tr>
<tr>
<td>user_group_slugify:</td>
<td><?php echo $user_group['user_group_slugify'] ?></td>
</tr>
<tr>
<td>user_group_type:</td>
<td><?php echo $user_group['user_group_type'] ?></td>
</tr>
<tr>
<td>user_group_weight:</td>
<td><?php echo $user_group['user_group_weight'] ?></td>
</tr>
<tr>
<td>user_group_create_timestamp:</td>
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
</tr>
<tr>
<td>user_group_modified_timestamp:</td>
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h1>
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
</h1>
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
<thead>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($group_permissions as $group_permissions_data) { ?>
<tr>
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="NA" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'NA') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RO" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RO') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RW" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RW') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<a href="#" class="btn btn-info btn-sm btn-rounded" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $group_permissions_data['permission_uuid'] ?>"><i class="fa-solid fa-circle-info"></i></a>
</td>
<div class="modal fade" id="infoModal<?php echo $group_permissions_data['permission_uuid'] ?>" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content bg-black2">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo $group_permissions_data['permission_description'] ?>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php
use api\classes\API_usergroups;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
# Check permissions
$API = new API_usergroups();
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['updatePermissions'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
$_GET['user_group_uuid'] = $user_group_uuid;
$API_usergroups = new API_usergroups();
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
$API_usergroups->validateData($requiredFields);
$user_group = $API_usergroups->getUsergroup()[0];
$query = "SELECT * FROM vc_user_group_permissions_portal
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
WHERE user_group_uuid = ?";
$stmt = $GLOBALS['pdo']->prepare($query);
$stmt->execute([$user_group_uuid]);
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_groups'), 'href' => '/accesscontrol/#user-groups'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>user_group_uuid:</td>
<td><?php echo $user_group['user_group_uuid'] ?></td>
</tr>
<tr>
<td>user_group_name:</td>
<td><?php echo $user_group['user_group_name'] ?></td>
</tr>
<tr>
<td>user_group_slugify:</td>
<td><?php echo $user_group['user_group_slugify'] ?></td>
</tr>
<tr>
<td>user_group_type:</td>
<td><?php echo $user_group['user_group_type'] ?></td>
</tr>
<tr>
<td>user_group_weight:</td>
<td><?php echo $user_group['user_group_weight'] ?></td>
</tr>
<tr>
<td>user_group_create_timestamp:</td>
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
</tr>
<tr>
<td>user_group_modified_timestamp:</td>
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h1>
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
</h1>
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
<thead>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($group_permissions as $group_permissions_data) { ?>
<tr>
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="NA" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'NA') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RO" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RO') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RW" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RW') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<a href="#" class="btn btn-info btn-sm btn-rounded" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $group_permissions_data['permission_uuid'] ?>"><i class="fa-solid fa-circle-info"></i></a>
</td>
<div class="modal fade" id="infoModal<?php echo $group_permissions_data['permission_uuid'] ?>" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content bg-black2">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo $group_permissions_data['permission_description'] ?>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -1,161 +1,167 @@
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
# Check permissions
$API = new API();
$API->checkPermissions('admin-sources', 'RO');
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['activeTabOnRefresh'] = true;
$jsScriptLoadData['copyInputValue'] = true;
$jsScriptLoadData['updateToggle'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['inserve_source'] = true;
$jsScriptLoadData['validateJson'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('portal_management'), 'href' => '/systemconfig'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('sources'), 'href' => '/systemconfig#sources'));
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="mx-2 pb-0 card-body">
<h1 class="">Inserve settings</h1>
<p>
Enter the necessary API details to set up and configure your connection to the Inserve API. This allows Sentri to communicate with Inserve and retrieve the data it needs. </p>
<hr>
</div>
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/system/sources/inserve">
<input type="hidden" name="source_name" value="inserve">
<div class="card-body">
<div class="form-group form-show-validation row">
<label for="source_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('inserve_url') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_url" name="source_url" value="<?php echo ($inserve_settings) ? $inserve_settings['source_url'] : '' ?>" placeholder="" required/>
</div>
</div>
<div class="form-group form-show-validation row">
<label for="source_auth_token" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('api_token') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_auth_token" name="source_auth_token" value="" autocomplete="off" placeholder="<?php echo ($inserve_settings) ? substr($inserve_settings['source_auth_token'], 0, 6) . str_repeat('*', max(0, strlen($inserve_settings['source_auth_token']) - 6)) : ''; ?>" required/>
</div>
</div>
</div>
<div class="card-footer py-4">
<div class="row">
<div class="col d-flex justify-content-end">
<button class="btn btn-success mx-2 test-inserve-connection-btn">
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
</button>
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
<?php } ?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="card-body">
<h1 class="">Inserve actions</h1>
<hr>
<div class="row row-cols-1 row-cols-md-3 g-2">
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call retrieves all companies from Inserve and creates or updates them in Sentri.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync.
</button>
</form>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync cloud distributor companies</h5>
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call synchronizes active companies in Sentri with the corresponding cloud distributor companies in Inserve. These cloud distributor companies are required to associate Sentri server licenses with companies in Inserve.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</form>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync servers licenses</h5>
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call first executes the sync-cloud-distributor action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</form>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
# Check permissions
$API = new API();
$API->checkPermissions('admin-sources', 'RO');
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['activeTabOnRefresh'] = true;
$jsScriptLoadData['copyInputValue'] = true;
$jsScriptLoadData['updateToggle'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['inserve_source'] = true;
$jsScriptLoadData['validateJson'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('portal_management'), 'href' => '/systemconfig'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('sources'), 'href' => '/systemconfig#sources'));
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="mx-2 pb-0 card-body">
<h1 class="">Inserve settings</h1>
<p>
Enter the necessary API details to set up and configure your connection to the Inserve API. This allows Sentri to communicate with Inserve and retrieve the data it needs. </p>
<hr>
</div>
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/system/sources/inserve">
<input type="hidden" name="source_name" value="inserve">
<div class="card-body">
<div class="form-group form-show-validation row">
<label for="source_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('inserve_url') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_url" name="source_url" value="<?php echo ($inserve_settings) ? $inserve_settings['source_url'] : '' ?>" placeholder="" required/>
</div>
</div>
<div class="form-group form-show-validation row">
<label for="source_auth_token" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('api_token') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_auth_token" name="source_auth_token" value="" autocomplete="off" placeholder="<?php echo ($inserve_settings) ? substr($inserve_settings['source_auth_token'], 0, 6) . str_repeat('*', max(0, strlen($inserve_settings['source_auth_token']) - 6)) : ''; ?>" required/>
</div>
</div>
</div>
<div class="card-footer py-4">
<div class="row">
<div class="col d-flex justify-content-end">
<button class="btn btn-success mx-2 test-inserve-connection-btn">
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
</button>
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
<?php } ?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="card-body">
<h1 class="">Inserve actions</h1>
<div class="row row-cols-1 row-cols-md-3 g-2">
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call retrieves all companies from Inserve and creates or updates them in Sentri.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync.
</button>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync cloud distributor companies</h5>
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call synchronizes active companies in Sentri with the corresponding cloud distributor companies in Inserve. These cloud distributor companies are required to associate Sentri server licenses with companies in Inserve.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync servers licenses</h5>
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call first executes the sync-cloud-distributor action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,475 +1,484 @@
<?php
namespace bin\php\Classes;
if (!defined('APP_INIT')) {
exit;
}
class serverOverviewBuilder
{
public array $servers = [];
public array $showColumns = array(
'server_hostname' => false,
'company_name' => false,
'server_power_state' => false,
'server_os' => false,
'server_cpu' => false,
'server_memory' => false,
'server_memory_demand' => false,
'server_disks' => false,
'server_ipv4' => false,
'server_ipv6' => false,
'server_vm_snapshot' => false,
'server_vm_generation' => false,
'server_licenses' => false,
'server_backup' => false,
'server_description' => false,
);
public array $allBackupTypes = [];
public array $allLicenseTypes = [];
public bool $showDelBtn = true;
public bool $showServerOverviewTitle = true;
public bool $showCompanies = true;
public function processServerData()
{
foreach ($this->servers as $server) {
if (!empty($server['server_backup'])) {
$backups = json_decode($server['server_backup'], true);
if (is_array($backups)) {
foreach ($backups as $item) {
foreach ($item as $key => $value) {
$this->allBackupTypes[$key] = true;
}
}
}
}
if (!empty($server['server_licenses'])) {
$licenses = json_decode($server['server_licenses'], true);
if (is_array($licenses)) {
foreach ($licenses as $item) {
foreach ($item as $key => $value) {
$this->allLicenseTypes[$key] = true;
}
}
}
}
}
$this->allBackupTypes = array_keys($this->allBackupTypes);
sort($this->allBackupTypes);
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
sort($this->allLicenseTypes);
if (isset($_COOKIE['serverTableColumns'])) {
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
foreach ($CheckedColumns as $CheckedColumn) {
$this->showColumns[$CheckedColumn] = true;
}
} else {
$this->showColumns['server_hostname'] = true;
$this->showColumns['company_name'] = true;
$this->showColumns['server_os'] = true;
$this->showColumns['server_cpu'] = true;
$this->showColumns['server_memory'] = true;
$this->showColumns['server_memory_demand'] = true;
$this->showColumns['server_disks'] = true;
$this->showColumns['server_state'] = true;
}
}
private function cleanNumber($num)
{
// If integer value, return without formatting
if (floor($num) == $num) {
return (string)$num;
}
// Otherwise return trimmed float
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
}
public function serverOverviewOutPut()
{ ?>
<div class="form-group form-show-validation row mb-3">
<?php if ($this->showServerOverviewTitle) { ?>
<div class="col-auto">
<h2>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> &nbsp; <?php echo __('server_overview') ?>
</h2>
</div>
<?php } ?>
<div class="col d-flex justify-content-end px-1">
<div class="selectgroup selectgroup-pills">
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_state" class="selectgroup-input" <?php echo($this->showColumns['server_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_hostname" class="selectgroup-input" <?php echo($this->showColumns['server_hostname'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
</label>
<?php if ($this->showCompanies) { ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($this->showColumns['company_name'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('company') ?></span>
</label>
<?php } ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($this->showColumns['server_os'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_os') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_cpu" class="selectgroup-input" <?php echo($this->showColumns['server_cpu'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_cpu') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory" class="selectgroup-input" <?php echo($this->showColumns['server_memory'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory_demand" class="selectgroup-input" <?php echo($this->showColumns['server_memory_demand'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory_demand') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_disks" class="selectgroup-input" <?php echo($this->showColumns['server_disks'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_disks') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv4" class="selectgroup-input" <?php echo($this->showColumns['server_ipv4'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv4') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv6" class="selectgroup-input" <?php echo($this->showColumns['server_ipv6'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv6') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_snapshot" class="selectgroup-input" <?php echo($this->showColumns['server_vm_snapshot'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_snapshot') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_generation" class="selectgroup-input" <?php echo($this->showColumns['server_vm_generation'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_generation') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_licenses" class="selectgroup-input" <?php echo($this->showColumns['server_licenses'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_licenses') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_backup" class="selectgroup-input" <?php echo($this->showColumns['server_backup'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_backup') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_power_state" class="selectgroup-input" <?php echo($this->showColumns['server_power_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_power_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_description" class="selectgroup-input" <?php echo($this->showColumns['server_description'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('description') ?></span>
</label>
</div>
</div>
<?php if ($this->showDelBtn) { ?>
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['del'])) { ?>
<a class="btn btn-danger btn-border" href="?del">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } else { ?>
<a class="btn btn-danger " href="/servers">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } ?>
</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="action" data-page-length="50">
<thead>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu">
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</th>
<th data-column="server_memory">
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks">
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</th>
<th data-column="server_ipv4">
<?php echo __('server_ipv4') ?>
</th>
<th data-column="server_ipv6">
<?php echo __('server_ipv6') ?>
</th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action">
<?php echo __('action') ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu"><?php echo __('server_cpu') ?></th>
<th data-column="server_memory"><?php echo __('server_memory') ?></th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks"><?php echo __('server_disks') ?></th>
<th data-column="server_ipv4"><?php echo __('server_ipv4') ?></th>
<th data-column="server_ipv6"><?php echo __('server_ipv6') ?></th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action"><?php echo __('action') ?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->servers as $server) {
$disks = json_decode($server['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_null($server['server_vm_host_name'])) {
$hostname = $server['server_hostname'];
} else {
$hostname = $server['server_vm_host_name'];
}
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
if ($mem == 0 && $demand == 0) {
$mem_assigned = 'N/A';
} else {
$mem_assigned = $this->cleanNumber($mem) . "M";
}
$mem_demand_text_color = '';
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
$ipv4_list = '';
if (!empty($server['server_ipv4'])) {
$ips = json_decode($server['server_ipv4'], true);
if (is_array($ips)) {
$ipv4_list = implode(', ', $ips);
}
}
$ipv6_list = '';
if (!empty($server['server_ipv6'])) {
$ips = json_decode($server['server_ipv6'], true);
if (is_array($ips)) {
$ipv6_list = implode(', ', $ips);
}
}
$thisServerLicenses = [];
foreach ($this->allLicenseTypes as $licenseType) {
$thisServerLicenses[$licenseType] = false;
}
if (!empty($server['server_licenses'])) {
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
if (is_array($allLicenseTypesServer)) {
foreach ($allLicenseTypesServer as $licenseTypeServer) {
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
$thisServerLicenses[$licenseTypeServerKey] = true;
}
}
}
}
$thisServerBackup = [];
foreach ($this->allBackupTypes as $BackupType) {
$thisServerBackup[$BackupType] = false;
}
if (!empty($server['server_backup'])) {
$allBackupTypesServer = json_decode($server['server_backup'], true);
if (is_array($allBackupTypesServer)) {
foreach ($allBackupTypesServer as $BackupTypeServer) {
foreach ($BackupTypeServer as $BackupTypeServerKey => $BackupTypeServerValue) {
$thisServerBackup[$BackupTypeServerKey] = true;
}
}
}
}
if ($this->showCompanies) {
$company_name = '';
if (strlen($server['company_name']) > 0) {
$company_name = $server['company_name'];
}
}
$server_state_color = returnServerStateColor($server['server_state']);
?>
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
</td>
<td data-column="server_hostname" class="text-nowrap" data-filter="<?php echo htmlspecialchars($hostname); ?>" data-sort="<?php echo htmlspecialchars($hostname); ?>">
<i class="fa-solid fa-server"></i> <?php echo $hostname ?>
</td>
<?php if ($this->showCompanies) { ?>
<td data-column="company_name" class="text-nowrap" data-filter="<?php echo $company_name ?>" data-sort="<?php echo $company_name ?>">
<?php echo $company_name ?>
</td>
<?php } ?>
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
<td data-column="server_cpu" class="text-nowrap"><?php echo $server['server_cpu'] ?>
</td>
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo htmlspecialchars($mem); ?>" data-sort="<?php echo htmlspecialchars($mem); ?>">
<?php echo $mem_assigned ?>
</td>
<td data-column="server_memory_demand" class="text-nowrap <?php echo 'text-' . $mem_demand_text_color ?>" data-filter="<?php echo htmlspecialchars($mem_percent_numb); ?>" data-sort="<?php echo htmlspecialchars($mem_percent_sort); ?>">
<?php echo $mem_demand ?>
</td>
<td data-column="server_disks" class="text-nowrap"
<?php
$sortValue = '';
$filterValue = '';
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
if ($totalDiskSpace > 0) {
$sortValue = $totalDiskSpace;
$filterValue = $totalDiskSpace;
}
}
?>
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
<?php
if (!empty($sortValue)) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
}
?>
</td>
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
<?php echo $ipv4_list ?>
</td>
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
<?php echo $ipv6_list ?>
</td>
<td data-column="server_vm_snapshot" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>">
<?php echo $server['server_vm_snapshot']; ?>
</td>
<td data-column="server_vm_generation" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_generation']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_generation']); ?>">
<?php echo $server['server_vm_generation']; ?>
</td>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<td data-column="server_license_<?php echo $licenseType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerLicenses[$licenseType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
foreach ($this->allBackupTypes as $BackupType) { ?>
<td data-column="server_backup_<?php echo $BackupType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerBackup[$BackupType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
?>
<td data-column="server_power_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_power_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_power_state']); ?>">
<?php
if ($server['server_power_state'] == 'Off') {
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
} elseif ($server['server_power_state'] == 'Running') {
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
} ?>
</td>
<td data-column="server_description" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_description']); ?>" data-filter="<?php echo $server['server_description']; ?>">
<?php echo $server['server_description']; ?>
</td>
<td>
<a href="/servers?view=<?php echo $server['server_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="fa-solid fa-eye"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php }
<?php
namespace bin\php\Classes;
if (!defined('APP_INIT')) {
exit;
}
class serverOverviewBuilder
{
public array $servers = [];
public array $showColumns = array(
'server_hostname' => false,
'company_name' => false,
'server_power_state' => false,
'server_os' => false,
'server_cpu' => false,
'server_memory' => false,
'server_memory_demand' => false,
'server_disks' => false,
'server_ipv4' => false,
'server_ipv6' => false,
'server_vm_snapshot' => false,
'server_vm_generation' => false,
'server_licenses' => false,
'server_backup' => false,
'server_description' => false,
);
public array $allBackupTypes = [];
public array $allLicenseTypes = [];
public bool $showDelBtn = true;
public bool $showServerOverviewTitle = true;
public bool $showCompanies = true;
public function processServerData()
{
foreach ($this->servers as $server) {
if (!empty($server['server_backup'])) {
$backups = json_decode($server['server_backup'], true);
if (is_array($backups)) {
foreach ($backups as $item) {
foreach ($item as $key => $value) {
$this->allBackupTypes[$key] = true;
}
}
}
}
if (!empty($server['server_licenses'])) {
$licenses = json_decode($server['server_licenses'], true);
if (is_array($licenses)) {
foreach ($licenses as $item) {
foreach ($item as $key => $value) {
$this->allLicenseTypes[$key] = true;
}
}
}
}
}
$this->allBackupTypes = array_keys($this->allBackupTypes);
sort($this->allBackupTypes);
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
sort($this->allLicenseTypes);
if (isset($_COOKIE['serverTableColumns'])) {
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
foreach ($CheckedColumns as $CheckedColumn) {
$this->showColumns[$CheckedColumn] = true;
}
} else {
$this->showColumns['server_hostname'] = true;
$this->showColumns['company_name'] = true;
$this->showColumns['server_os'] = true;
$this->showColumns['server_cpu'] = true;
$this->showColumns['server_memory'] = true;
$this->showColumns['server_memory_demand'] = true;
$this->showColumns['server_disks'] = true;
$this->showColumns['server_state'] = true;
}
}
private function cleanNumber($num)
{
// If integer value, return without formatting
if (floor($num) == $num) {
return (string)$num;
}
// Otherwise return trimmed float
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
}
public function serverOverviewOutPut()
{ ?>
<div class="form-group form-show-validation row mb-3">
<?php if ($this->showServerOverviewTitle) { ?>
<div class="col-auto">
<h2>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> &nbsp; <?php echo __('server_overview') ?>
</h2>
</div>
<?php } ?>
<div class="col d-flex justify-content-end px-1">
<div class="selectgroup selectgroup-pills">
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_state" class="selectgroup-input" <?php echo($this->showColumns['server_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_hostname" class="selectgroup-input" <?php echo($this->showColumns['server_hostname'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
</label>
<?php if ($this->showCompanies) { ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($this->showColumns['company_name'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('company') ?></span>
</label>
<?php } ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($this->showColumns['server_os'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_os') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_cpu" class="selectgroup-input" <?php echo($this->showColumns['server_cpu'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_cpu') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory" class="selectgroup-input" <?php echo($this->showColumns['server_memory'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory_demand" class="selectgroup-input" <?php echo($this->showColumns['server_memory_demand'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory_demand') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_disks" class="selectgroup-input" <?php echo($this->showColumns['server_disks'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_disks') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv4" class="selectgroup-input" <?php echo($this->showColumns['server_ipv4'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv4') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv6" class="selectgroup-input" <?php echo($this->showColumns['server_ipv6'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv6') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_snapshot" class="selectgroup-input" <?php echo($this->showColumns['server_vm_snapshot'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_snapshot') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_generation" class="selectgroup-input" <?php echo($this->showColumns['server_vm_generation'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_generation') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_licenses" class="selectgroup-input" <?php echo($this->showColumns['server_licenses'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_licenses') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_backup" class="selectgroup-input" <?php echo($this->showColumns['server_backup'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_backup') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_power_state" class="selectgroup-input" <?php echo($this->showColumns['server_power_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_power_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_description" class="selectgroup-input" <?php echo($this->showColumns['server_description'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('description') ?></span>
</label>
</div>
</div>
<?php if ($this->showDelBtn) { ?>
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['del'])) { ?>
<a class="btn btn-danger btn-border" href="?del">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } else { ?>
<a class="btn btn-danger " href="/servers">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } ?>
</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="action" data-page-length="50">
<thead>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu">
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</th>
<th data-column="server_memory">
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks">
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</th>
<th data-column="server_ipv4">
<?php echo __('server_ipv4') ?>
</th>
<th data-column="server_ipv6">
<?php echo __('server_ipv6') ?>
</th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action">
<?php echo __('action') ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu"><?php echo __('server_cpu') ?></th>
<th data-column="server_memory"><?php echo __('server_memory') ?></th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks"><?php echo __('server_disks') ?></th>
<th data-column="server_ipv4"><?php echo __('server_ipv4') ?></th>
<th data-column="server_ipv6"><?php echo __('server_ipv6') ?></th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action"><?php echo __('action') ?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->servers as $server) {
$disks = json_decode($server['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_null($server['server_vm_host_name'])) {
$hostname = $server['server_hostname'];
} else {
$hostname = $server['server_vm_host_name'];
}
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
if ($mem == 0 && $demand == 0) {
$mem_assigned = 'N/A';
$mem_assigned_sort = 0;
} else {
$mem_assigned = $this->cleanNumber($mem) . "M";
$mem_assigned_sort = $this->cleanNumber($mem);
}
$mem_demand_text_color = '';
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = 0;
}
if ($server['server_cpu']) {
$server_cpu = htmlspecialchars($server['server_cpu']);
$server_cpu_sort = (int)$server_cpu;
} else {
$server_cpu = "N/A";
$server_cpu_sort = 0;
}
$ipv4_list = '';
if (!empty($server['server_ipv4'])) {
$ips = json_decode($server['server_ipv4'], true);
if (is_array($ips)) {
$ipv4_list = implode(', ', $ips);
}
}
$ipv6_list = '';
if (!empty($server['server_ipv6'])) {
$ips = json_decode($server['server_ipv6'], true);
if (is_array($ips)) {
$ipv6_list = implode(', ', $ips);
}
}
$thisServerLicenses = [];
foreach ($this->allLicenseTypes as $licenseType) {
$thisServerLicenses[$licenseType] = false;
}
if (!empty($server['server_licenses'])) {
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
if (is_array($allLicenseTypesServer)) {
foreach ($allLicenseTypesServer as $licenseTypeServer) {
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
$thisServerLicenses[$licenseTypeServerKey] = true;
}
}
}
}
$thisServerBackup = [];
foreach ($this->allBackupTypes as $BackupType) {
$thisServerBackup[$BackupType] = false;
}
if (!empty($server['server_backup'])) {
$allBackupTypesServer = json_decode($server['server_backup'], true);
if (is_array($allBackupTypesServer)) {
foreach ($allBackupTypesServer as $BackupTypeServer) {
foreach ($BackupTypeServer as $BackupTypeServerKey => $BackupTypeServerValue) {
$thisServerBackup[$BackupTypeServerKey] = true;
}
}
}
}
if ($this->showCompanies) {
$company_name = '';
if (strlen($server['company_name']) > 0) {
$company_name = $server['company_name'];
}
}
$server_state_color = returnServerStateColor($server['server_state']);
?>
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
</td>
<td data-column="server_hostname" class="text-nowrap" data-filter="<?php echo htmlspecialchars($hostname); ?>" data-sort="<?php echo htmlspecialchars($hostname); ?>">
<i class="fa-solid fa-server"></i> <?php echo $hostname ?>
</td>
<?php if ($this->showCompanies) { ?>
<td data-column="company_name" class="text-nowrap" data-filter="<?php echo $company_name ?>" data-sort="<?php echo $company_name ?>">
<?php echo $company_name ?>
</td>
<?php } ?>
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
<td data-column="server_cpu" class="text-nowrap" data-filter="<?php echo $server_cpu ?>" data-sort="<?php echo $server_cpu_sort ?>"><?php echo $server_cpu ?></td>
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo $mem_assigned; ?>" data-sort="<?php echo $mem_assigned_sort; ?>">
<?php echo $mem_assigned ?>
</td>
<td data-column="server_memory_demand" class="text-nowrap <?php echo 'text-' . $mem_demand_text_color ?>" data-filter="<?php echo htmlspecialchars($mem_percent_numb); ?>" data-sort="<?php echo htmlspecialchars($mem_percent_sort); ?>">
<?php echo $mem_demand ?>
</td>
<td data-column="server_disks" class="text-nowrap"
<?php
$sortValue = '';
$filterValue = '';
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
if ($totalDiskSpace > 0) {
$sortValue = $totalDiskSpace;
$filterValue = $totalDiskSpace;
}
}
?>
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
<?php
if (!empty($sortValue)) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
}
?>
</td>
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
<?php echo $ipv4_list ?>
</td>
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
<?php echo $ipv6_list ?>
</td>
<td data-column="server_vm_snapshot" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>">
<?php echo $server['server_vm_snapshot']; ?>
</td>
<td data-column="server_vm_generation" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_generation']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_generation']); ?>">
<?php echo $server['server_vm_generation']; ?>
</td>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<td data-column="server_license_<?php echo $licenseType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerLicenses[$licenseType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
foreach ($this->allBackupTypes as $BackupType) { ?>
<td data-column="server_backup_<?php echo $BackupType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerBackup[$BackupType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
?>
<td data-column="server_power_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_power_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_power_state']); ?>">
<?php
if ($server['server_power_state'] == 'Off') {
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
} elseif ($server['server_power_state'] == 'Running') {
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
} ?>
</td>
<td data-column="server_description" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_description']); ?>" data-filter="<?php echo $server['server_description']; ?>">
<?php echo $server['server_description']; ?>
</td>
<td>
<a href="/servers?view=<?php echo $server['server_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="fa-solid fa-eye"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php }
}