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>