v1.0 Initial commit of project
This commit is contained in:
13
pub/bin/pages/autop/pageDevices.php
Normal file
13
pub/bin/pages/autop/pageDevices.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_add.php');
|
||||
} elseif (isset($_GET['edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_edit.php');
|
||||
} elseif (isset($_GET['view'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_view.php');
|
||||
} else {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_list.php');
|
||||
}
|
||||
1
pub/bin/pages/autop/pageDevicesSettings.php
Normal file
1
pub/bin/pages/autop/pageDevicesSettings.php
Normal file
@@ -0,0 +1 @@
|
||||
to be made
|
||||
195
pub/bin/pages/autop/pageDevices_add.php
Normal file
195
pub/bin/pages/autop/pageDevices_add.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-devices', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['datepicker'] = true;
|
||||
$jsScriptLoadData['multiple_select'] = true;
|
||||
$jsScriptLoadData['validateJson'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<div class="btn-group dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-plus text-success"></i>' . __('add_device') . '</button>
|
||||
<ul class="dropdown-menu bg-black2" role="menu">
|
||||
<li>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=phone">Phone</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=module">Module</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=base">Base</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=handset">Handset</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>');
|
||||
$add_get = htmlspecialchars($_GET['add'], ENT_QUOTES, 'UTF-8');
|
||||
$formBuilder = new formBuilder('add_' . $add_get . '_device', '<i class="fas fa-plus"></i>', '/devices/');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$formInputs = ['device_type', 'device_vendor_uuid', 'device_name', 'device_slugify', 'device_enabled', 'device_image', 'device_notes'];
|
||||
if ($_GET['add'] == 'phone' || $_GET['add'] == 'base') {
|
||||
$formInputs[] = 'device_eol';
|
||||
$formInputs[] = 'device_extensions';
|
||||
}
|
||||
$formInputs[] = 'device_extra';
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_device'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/devices">
|
||||
<input type="hidden" name="_return" value="/devices/">
|
||||
<div class="card-body">
|
||||
<?php foreach ($formInputs as $input) {
|
||||
if ($input == 'device_type') { ?>
|
||||
<input type="hidden" name="device_type" value="<?php echo htmlspecialchars($_GET['add'], ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php }
|
||||
if ($input == 'device_vendor_uuid') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_vendor_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_vendor') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_vendor_uuid" name="device_vendor_uuid" class="form-control" required>
|
||||
<?php
|
||||
$data = $GLOBALS['conn']->query("SELECT vendor_uuid, vendor_name FROM vc_vendors WHERE vendor_enabled = 1");
|
||||
if ($data->num_rows == 0) { ?>
|
||||
<option value=""><?php echo __('no_vendor_found') ?></option>
|
||||
<?php } else {
|
||||
while ($row = $data->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $row['vendor_uuid'] ?>"><?php echo $row['vendor_name'] ?></option>
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_name') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="device_name" name="device_name" data-slugify="device_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_slugify') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="device_slugify" name="device_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_enabled') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_enabled" name="device_enabled" class="form-control" required>
|
||||
<option value="1" selected><?php echo __('enabled') ?></option>
|
||||
<option value="0"><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_notes') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_notes" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_notes') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="device_notes" name="device_notes" rows="5"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_eol') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_eol" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('eol') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="device_eol" name="device_eol" data-datepicker="true" placeholder=""/>
|
||||
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_image') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="/src/images/placeholder500x500.png" alt="preview">
|
||||
<input type="file" class="form-control form-control-file" id="device_image" name="device_image" accept="image/png">
|
||||
<label for="device_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_extensions') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_extensions" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_extensions') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_extensions" name="device_extensions[]" class="form-control" multiple="multiple" data-multiple-select="true">
|
||||
<?php
|
||||
$data = $GLOBALS['conn']->query("SELECT device_uuid, device_name, device_vendor_uuid FROM vc_devices WHERE device_type = 'module'");
|
||||
if ($data->num_rows == 0) { ?>
|
||||
<option value=""><?php echo __('no_device_found') ?></option>
|
||||
<?php } else {
|
||||
while ($row = $data->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $row['device_uuid'] ?>" data-vendor="<?php echo $row['device_vendor_uuid'] ?>">
|
||||
<?php echo $row['device_name'] ?>
|
||||
</option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_extra') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_extra" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_extra') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="device_extra" name="device_extra" rows="5" data-validate-json="true"></textarea>
|
||||
<small id="device_extra_help" class="form-text text-muted">
|
||||
<?php echo __('json_enter') ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
220
pub/bin/pages/autop/pageDevices_edit.php
Normal file
220
pub/bin/pages/autop/pageDevices_edit.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-devices', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'][] = true;
|
||||
$jsScriptLoadData['datepicker'] = true;
|
||||
$jsScriptLoadData['multiple_select'] = true;
|
||||
$jsScriptLoadData['validateJson'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<div class="btn-group dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-plus text-success"></i>' . __('add_device') . '</button>
|
||||
<ul class="dropdown-menu bg-black2" role="menu">
|
||||
<li>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=phone">Phone</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=module">Module</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=base">Base</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=handset">Handset</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>');
|
||||
$formBuilder = new formBuilder('edit_device', '<i class="fas fa-edit"></i>', '/devices/');
|
||||
$get_edit = htmlspecialchars($_GET['edit'], ENT_QUOTES, 'UTF-8');
|
||||
$formBuilder->addExtraButtons(array(0 => array('buttonText' => __('view'), 'buttonIcon' => '<i class="far fa-eye"></i>', 'buttonHref' => '?view=' . $get_edit, 'buttonColor' => 'info')));
|
||||
|
||||
# Retrieve Information for the page
|
||||
$device_found = false;
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_devices INNER JOIN vc_vendors ON vc_devices.device_vendor_uuid = vc_vendors.vendor_uuid WHERE device_uuid = ?");
|
||||
$stmt->bind_param("s", $_GET['edit']);
|
||||
$stmt->execute();
|
||||
$device_data_result = $stmt->get_result();
|
||||
$device_data = $device_data_result->fetch_assoc();
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => $device_data['vendor_name'] . ' ' . $device_data['device_name'], 'href' => '?view=' . $device_data['device_uuid']));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit'), 'href' => '?view=' . $device_data['device_uuid']));
|
||||
if ($device_data_result->num_rows > 0) {
|
||||
$device_found = true;
|
||||
}
|
||||
|
||||
$formInputs = ['device_vendor_uuid', 'device_name', 'device_slugify', 'device_enabled', 'device_image', 'device_notes'];
|
||||
if ($device_data['device_type'] == 'phone' || $device_data['device_type'] == 'base') {
|
||||
$formInputs[] = 'device_eol';
|
||||
$formInputs[] = 'device_extensions';
|
||||
}
|
||||
$formInputs[] = 'device_extra';
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('devices'), 'href' => '/devices/'));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($device_found) {
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/devices">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="_return" value="/devices/?edit=<?php echo $device_data['device_uuid']; ?>">
|
||||
<input type="hidden" name="device_uuid" value="<?php echo $device_data['device_uuid'] ?>">
|
||||
<div class="card-body">
|
||||
<?php foreach ($formInputs as $input) {
|
||||
if ($input == 'device_vendor_uuid') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_vendor_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_vendor') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_vendor_uuid" name="device_vendor_uuid" class="form-control" required>
|
||||
<?php
|
||||
$data = $GLOBALS['conn']->query("SELECT vendor_uuid, vendor_name FROM vc_vendors WHERE vendor_enabled = 1");
|
||||
if ($data->num_rows == 0) { ?>
|
||||
<option value=""><?php echo __('no_vendor_found') ?></option>
|
||||
<?php } else {
|
||||
while ($row = $data->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $row['vendor_uuid'] ?>" <?php echo(($row['vendor_uuid'] == $device_data['device_vendor_uuid']) ? 'selected' : '') ?>><?php echo $row['vendor_name'] ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_name') {
|
||||
?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="device_name" name="device_name" value="<?php echo $device_data['device_name'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_slugify') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="device_slugify" name="device_slugify" value="<?php echo $device_data['device_slugify'] ?>" placeholder="" disabled/>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_enabled') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_enabled" name="device_enabled" class="form-control" required>
|
||||
<option value="1" <?php echo(($device_data['device_enabled'] == 1) ? 'selected' : '') ?>><?php echo __('enabled') ?></option>
|
||||
<option value="0" <?php echo(($device_data['device_enabled'] == 0) ? 'selected' : '') ?>><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_notes') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_notes" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_notes') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="device_notes" name="device_notes" rows="5"><?php echo $device_data['device_notes'] ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_eol') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_eol" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('eol') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="device_eol" value="<?php echo !empty($device_data['device_eol']) ? date('d/m/Y', $device_data['device_eol']) : ''; ?>" name="device_eol" placeholder="" data-datepicker="true"/>
|
||||
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_image') { ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="<?php echo(($device_data['device_image'] != null) ? 'data:image/png;base64, ' . $device_data['device_image'] : '/src/images/placeholder500x500.png') ?>" alt="device_image">
|
||||
<input type="file" class="form-control form-control-file" id="device_image" name="device_image" accept="image/png">
|
||||
<label for="device_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_extensions') {
|
||||
$device_extensions = json_decode($device_data['device_extensions']);
|
||||
?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_extensions" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_extensions') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="device_extensions" name="device_extensions[]" class="form-control" multiple="multiple" data-multiple-select="true">
|
||||
<?php
|
||||
if ($device_data['device_type'] == 'base') {
|
||||
$data = $GLOBALS['conn']->query("SELECT device_uuid, device_name, device_vendor_uuid FROM vc_devices WHERE device_type = 'module' OR device_type = 'handset'");
|
||||
} else {
|
||||
$data = $GLOBALS['conn']->query("SELECT device_uuid, device_name, device_vendor_uuid FROM vc_devices WHERE device_type = 'module'");
|
||||
}
|
||||
|
||||
if ($data->num_rows == 0) { ?>
|
||||
<option value=""><?php echo __('no_device_found') ?></option>
|
||||
<?php } else {
|
||||
while ($row = $data->fetch_assoc()) { ?>
|
||||
<option <?php echo(in_array($row['device_uuid'], $device_extensions) ? 'selected' : '') ?> value="<?php echo $row['device_uuid'] ?>" data-vendor="<?php echo $row['device_vendor_uuid'] ?>">
|
||||
<?php echo $row['device_name'] ?>
|
||||
</option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($input == 'device_extra') {
|
||||
$json_device_extra = json_encode(json_decode($device_data['device_extra']), JSON_PRETTY_PRINT); ?>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="device_extra" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('device_extra') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="device_extra" name="device_extra" rows="5" data-validate-json="true"><?php echo $json_device_extra ?></textarea>
|
||||
<small id="device_extra_help" class="form-text text-muted">
|
||||
<?php echo __('json_enter') ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm();
|
||||
} else {
|
||||
echo "No Vendor found with uuid " . $_GET['edit'];
|
||||
|
||||
}
|
||||
105
pub/bin/pages/autop/pageDevices_list.php
Normal file
105
pub/bin/pages/autop/pageDevices_list.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?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');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-devices', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['multiFilterSelect'] = true;
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['datatables'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(false, '<i class="fas fa-fax"></i> ' . __('devices'));
|
||||
if ($API->checkPermissions('admin-devices', 'RW', true)) {
|
||||
$pageNavbar->AddHTMLButton('<div class="btn-group dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-plus text-success"></i>' . __('add_device') . '</button>
|
||||
<ul class="dropdown-menu bg-black2" role="menu">
|
||||
<li>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=phone">Phone</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=module">Module</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=base">Base</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=handset">Handset</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>');
|
||||
}
|
||||
# Retrieve Information for the page
|
||||
$data = $GLOBALS['conn']->query("SELECT * FROM vc_devices INNER JOIN vc_vendors ON vc_devices.device_vendor_uuid = vc_vendors.vendor_uuid");
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('devices'), 'href' => '/devices/'));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
?>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="multi-filter-select table table-hover" data-skip-columns="0,5" data-datatables-order='[ [1, "desc"], [3, "asc"] ]' data-page-length="25">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<th>Type</th>
|
||||
<th>Vendor</th>
|
||||
<th>Name</th>
|
||||
<th>Enabled</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<th>Type</th>
|
||||
<th>Vendor</th>
|
||||
<th>Name</th>
|
||||
<th>Enabled</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php while ($row = $data->fetch_assoc()) { ?>
|
||||
<tr data-item-id="<?php echo $row['device_uuid']; ?>">
|
||||
<td style="padding-top: 0px!important;padding-bottom: 0px!important;">
|
||||
<img class="img-upload-preview" src="data:image/png;base64, <?php echo $row['device_image_thumbnail'] ?>" alt="">
|
||||
</td>
|
||||
<td><?php echo ucfirst($row['device_type']) ?></td>
|
||||
<td><?php echo $row['vendor_name'] ?></td>
|
||||
<td><?php echo $row['device_name'] ?></td>
|
||||
<td>
|
||||
<?php echo(($row['device_enabled'] == 1) ? __('yes') : __('no')) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($API->checkPermissions('admin-devices', 'RW', true)) { ?>
|
||||
<a href="?edit=<?php echo $row['device_uuid'] ?>" class="btn btn-primary btn-sm btn-rounded"><i class="fas fa-edit"></i></a>
|
||||
<?php } ?>
|
||||
<a href="?view=<?php echo $row['device_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="far fa-eye"></i></a>
|
||||
<?php if ($API->checkPermissions('admin-devices', 'RW', true)) { ?>
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $row['device_uuid'] ?>" data-api-url="/api/v1/devices/" data-item-name="device_uuid"><i class="fas fa-trash-alt"></i></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
420
pub/bin/pages/autop/pageDevices_view.php
Normal file
420
pub/bin/pages/autop/pageDevices_view.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?php
|
||||
|
||||
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');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-devices', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
function showExtension($devicesLinked, $filter = false)
|
||||
{
|
||||
if (count($devicesLinked) > 0) {
|
||||
foreach ($devicesLinked as $extension) {
|
||||
if ($filter === false || $extension['device_type'] == $filter) { ?>
|
||||
<div class="col-sm-3 d-flex flex-column align-items-center">
|
||||
<img src="data:image/png;base64, <?php echo $extension['device_image']; ?>" class="img-fluid pb-4" style="max-width: 100%; height: auto;" alt="...">
|
||||
<a href="?view=<?php echo $extension['device_uuid'] ?>" class="btn btn-info btn-rounded align-items-center"><?php echo $extension['device_name'] ?></a>
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
} else { ?>
|
||||
<p><?php echo __('no_device_found') ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
function makeFileTables($API, $dataFolder, $device_slugify)
|
||||
{
|
||||
$device_data_dir = $_SERVER['DOCUMENT_ROOT'] . '/data/devices/' . $device_slugify . '/' . $dataFolder . '/';
|
||||
$documents = array_diff(scandir($device_data_dir), array('..', '.'));
|
||||
|
||||
foreach ($documents as $document) {
|
||||
$full_path = $device_data_dir . $document;
|
||||
$fileSize = human_filesize(fileSize($full_path));
|
||||
$fileModified = date("Y-m-d H:i:s", filemtime($full_path));
|
||||
$urlPath = '/data/devices/' . $device_slugify . '/' . $dataFolder . '/' . $document;
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a target="_blank" href="<?php echo $urlPath ?>"><i class="fas fa-external-link-alt"></i> <?php echo $document; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $fileSize ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $fileModified ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($API->checkPermissions('admin-devices-files', 'RW', true)) { ?>
|
||||
<form action="/api/v1/devices/files" method="post">
|
||||
<input type="hidden" name="filePath" value="">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $urlPath ?>" data-api-url="/api/v1/devices/files/" data-item-name="file_name"><i class="fas fa-trash-alt"></i></a>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
function render_template_controls($template_uuid, $device_uuid, $default_template, $platform_uuid)
|
||||
{
|
||||
?>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<form id="add_<?php echo $default_template ?>_template" action="/api/v2/templates/add/" method="post" <?= $template_uuid ? 'style="display: none"' : '' ?>>
|
||||
<input type="hidden" name="template_device_uuid" value="<?= htmlspecialchars($device_uuid) ?>">
|
||||
<input type="hidden" name="template_name" value="<?php echo $default_template ?>">
|
||||
<input type="hidden" name="template_slugify" value="<?php echo $default_template ?>">
|
||||
<?php if ($platform_uuid) { ?>
|
||||
<input type="hidden" name="platform_uuid" value="<?php echo $platform_uuid ?>">
|
||||
<?php } ?>
|
||||
<button type="submit" class="btn btn-success btn-rounded mt-2" disabled>
|
||||
<i class="fas fa-magic"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<a id="edit_<?php echo $default_template ?>_template" class="btn btn-primary btn-rounded" href="/devices/?template=<?= htmlspecialchars($template_uuid) ?>" <?= !$template_uuid ? 'style="display: none"' : '' ?>><i class="fas fa-edit" disabled=""></i></a>
|
||||
|
||||
<form id="del_<?php echo $default_template ?>_template" action="/api/v1/templates/del/" method="post" <?= !$template_uuid ? 'style="display: none"' : '' ?>>
|
||||
<input type="hidden" name="template_uuid" value="<?= htmlspecialchars($template_uuid) ?>">
|
||||
<a href="#" class="btn btn-danger btn-rounded delete-btn" data-item-uuid="<?= htmlspecialchars($template_uuid) ?>" data-api-url="/api/v2/templates/del/" data-delete-action='{"add_<?php echo $default_template ?>_template":"show", "edit_<?php echo $default_template ?>_template":"hide", "del_<?php echo $default_template ?>_template":"hide"}'><i class="fas fa-trash-alt"></i></a>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['delete_confirmation'][] = true;
|
||||
$jsScriptLoadData['load_dropzone'] = true;
|
||||
$jsScriptLoadData['form'][] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
if ($API->checkPermissions('admin-devices', 'RW', true)) {
|
||||
$pageNavbar->AddHTMLButton('<button class="btn btn-danger" type="button" disabled><i class="fas fa-trash-alt"></i> ' . __('delete') . '</button>');
|
||||
$get_view = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
||||
$pageNavbar->AddHTMLButton('<a class="btn btn-primary mx-3" type="button" href="?edit=' . $get_view . '"><i class="fas fa-edit"></i> ' . __('edit') . '</a>');
|
||||
$pageNavbar->AddHTMLButton('<div class="btn-group dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-plus text-success"></i> ' . __('add_device') . '</button>
|
||||
<ul class="dropdown-menu bg-black2" role="menu">
|
||||
<li>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=phone">Phone</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=module">Module</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=base">Base</a>
|
||||
<a class="dropdown-item text-white-50 bg-black2" href="?add=handset">Handset</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>');
|
||||
}
|
||||
|
||||
# Retrieve Information for the page
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_devices INNER JOIN vc_vendors ON vc_devices.device_vendor_uuid = vc_vendors.vendor_uuid WHERE device_uuid = ?");
|
||||
$stmt->bind_param("s", $_GET['view']);
|
||||
$stmt->execute();
|
||||
$device_data_result = $stmt->get_result();
|
||||
if ($device_data_result->num_rows == 0) {
|
||||
echo "No Vendor found with uuid " . htmlspecialchars($_GET['edit'], ENT_QUOTES, 'UTF-8');
|
||||
exit;
|
||||
} else {
|
||||
$device_data = $device_data_result->fetch_assoc();
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('devices'), 'href' => '/devices/'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => $device_data['vendor_name'] . ' ' . $device_data['device_name'], 'href' => '?view=' . $device_data['device_uuid']));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
?>
|
||||
|
||||
<div class="row d-flex align-items-stretch pb-2">
|
||||
<div class="col-md-4 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<h1 class="text-center"><?php echo $device_data['vendor_name'] . ' ' . $device_data['device_name'] ?></h1>
|
||||
<img src="data:image/png;base64, <?php echo $device_data['device_image']; ?>" class="img-fluid" style="max-width: 100%; height: auto;" alt="...">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tr>
|
||||
<td>vendor_name:</td>
|
||||
<td><?php echo $device_data['vendor_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_uuid:</td>
|
||||
<td><?php echo $device_data['device_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_type:</td>
|
||||
<td><?php echo $device_data['device_type'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_name:</td>
|
||||
<td><?php echo $device_data['device_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_slugify:</td>
|
||||
<td><?php echo $device_data['device_slugify'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_enabled:</td>
|
||||
<td><?php echo $device_data['device_enabled'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_eol:</td>
|
||||
<td><?php echo showTime($device_data['device_eol']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_create_timestamp:</td>
|
||||
<td><?php echo showTime($device_data['device_create_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>device_modified_timestamp: </td>
|
||||
<td><?php echo showTime($device_data['device_modified_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-top">device_notes:</td>
|
||||
<td><?php echo $device_data['device_notes'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-top">device_extra:</td>
|
||||
<td class="w-100">
|
||||
<textarea class="form-control" id="device_extra" name="device_extra" rows="5" disabled><?php echo json_encode(json_decode($device_data['device_extra']), JSON_PRETTY_PRINT) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4>Uses</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
To be made. Its going to be visible where the device is used (organisation/site).
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
# Retrieve device extension data from the device
|
||||
$devicesLinked = array();
|
||||
if ($device_data['device_type'] == 'phone' || $device_data['device_type'] == 'base') {
|
||||
$device_extensions = json_decode($device_data['device_extensions']);
|
||||
} elseif ($device_data['device_type'] == 'module' || $device_data['device_type'] == 'handset') {
|
||||
$query = "SELECT device_extensions, device_uuid FROM vc_devices WHERE device_extensions LIKE ?";
|
||||
$stmt = $GLOBALS['conn']->prepare($query);
|
||||
if ($stmt) {
|
||||
$searchTerm = "%" . $device_data['device_uuid'] . "%"; // Add wildcards manually
|
||||
$stmt->bind_param('s', $searchTerm);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$device_extensions = array();
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
array_push($device_extensions, $row['device_uuid']);
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($device_extensions)) {
|
||||
$placeholders = implode(' OR device_uuid = ', array_fill(0, count($device_extensions), '?'));
|
||||
$query = "SELECT * FROM vc_devices WHERE device_uuid = " . $placeholders;
|
||||
$stmt = $GLOBALS['conn']->prepare($query);
|
||||
if ($stmt) {
|
||||
$types = str_repeat('s', count($device_extensions));
|
||||
$stmt->bind_param($types, ...$device_extensions);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
array_push($devicesLinked, $row);
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
}
|
||||
|
||||
$connectedDeviceCards = [];
|
||||
if (in_array($device_data['device_type'], ['phone', 'base'])) {
|
||||
$connectedDeviceCards[] = [
|
||||
'title' => __('extensions_available'),
|
||||
'filter' => 'module'
|
||||
];
|
||||
}
|
||||
|
||||
if ($device_data['device_type'] == 'base') {
|
||||
$connectedDeviceCards[] = [
|
||||
'title' => __('handsets_available'),
|
||||
'filter' => 'handset'
|
||||
];
|
||||
}
|
||||
|
||||
if (in_array($device_data['device_type'], ['module', 'handset'])) {
|
||||
$connectedDeviceCards[] = [
|
||||
'title' => __('parent_device'),
|
||||
'filter' => false
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($connectedDeviceCards as $card) { ?>
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4><?php echo $card['title']; ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<?php showExtension($devicesLinked, $card['filter']); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body pt-0">
|
||||
<ul class="nav nav-tabs nav-line nav-color-secondary" id="line-tab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="line-home-tab" data-bs-toggle="pill" href="#line-home" role="tab" aria-controls="pills-home" aria-selected="true">Documents</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="line-profile-tab" data-bs-toggle="pill" href="#line-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Firmware</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content mt-3 mb-3" id="line-tabContent">
|
||||
<div class="tab-pane fade show active" id="line-home" role="tabpanel" aria-labelledby="line-home-tab">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless " data-table-type="documents">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('document') ?></th>
|
||||
<th><?php echo __('filesize') ?></th>
|
||||
<th><?php echo __('file_last_modified') ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php makeFileTables($API, 'documents', $device_data['device_slugify']); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php if ($API->checkPermissions('admin-devices-files', 'RW', true)) { ?>
|
||||
<form action="/api/v1/devices/files" class="dropzone p-0" data-form-type="documents">
|
||||
<input type="hidden" name="device_slugify" value="<?php echo $device_data['device_slugify'] ?>">
|
||||
<input type="hidden" name="filetype" value="documents">
|
||||
<div class="dz-message mt-1 mb-0" data-dz-message>
|
||||
<div class="icon">
|
||||
<i class="icon-doc"></i>
|
||||
</div>
|
||||
<h4 class="message"><?php echo __('drag_and_drop_files_here') ?> </h4>
|
||||
</div>
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" multiple/>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="line-profile" role="tabpanel" aria-labelledby="line-profile-tab">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless" data-table-type="firmware">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('filename') ?></th>
|
||||
<th><?php echo __('filesize') ?></th>
|
||||
<th><?php echo __('file_last_modified') ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php makeFileTables($API, 'firmware', $device_data['device_slugify']); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<form action="/api/v1/devices/files" class="dropzone p-0" data-form-type="firmware">
|
||||
<input type="hidden" name="device_slugify" value="<?php echo $device_data['device_slugify'] ?>">
|
||||
<input type="hidden" name="filetype" value="firmware">
|
||||
<div class="dz-message mt-1 mb-0" data-dz-message>
|
||||
<div class="icon">
|
||||
<i class="icon-doc"></i>
|
||||
</div>
|
||||
<h4 class="message"><?php echo __('drag_and_drop_files_here') ?> </h4>
|
||||
</div>
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" multiple/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
||||
$device_uuid = $device_data['device_uuid'] ?? null;
|
||||
$platforms_enabled = get_enabled_platforms($GLOBALS['conn']);
|
||||
$default_template_uuid = 0 // to be made
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4><?= __('templates') ?></h4>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="row">
|
||||
<!-- Default Template -->
|
||||
<div class="col-sm-3 d-flex">
|
||||
<div class="card flex-fill d-flex flex-column">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h4><?= __('default') ?></h4>
|
||||
<img src="/src/images/default-template-icon.png" alt="" class="img-fluid pb-3 flex-grow-1" style="object-fit: contain;">
|
||||
<?php render_template_controls($default_template_uuid, $device_uuid, 'default', false); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Platform Templates -->
|
||||
<?php foreach ($platforms_enabled as $platform) { ?>
|
||||
<div class="col-sm-3 d-flex">
|
||||
<div class="card flex-fill d-flex flex-column">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h4><?= htmlspecialchars($platform['data']['platform_name']) ?></h4>
|
||||
<img src="data:image/jpeg;base64, <?= htmlspecialchars($platform['data']['platform_image']) ?>" alt="" class="img-fluid pb-3 flex-grow-1" style="object-fit: contain;">
|
||||
<?php render_template_controls($platform['default_template_uuid'], $device_uuid, $platform['data']['platform_slugify'], $platform['data']['platform_uuid']); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
4
pub/bin/pages/autop/pagePhonebooks.php
Normal file
4
pub/bin/pages/autop/pagePhonebooks.php
Normal file
@@ -0,0 +1,4 @@
|
||||
to be made
|
||||
<div class="alert alert-gruvbox">Gruvbox styled alert</div>
|
||||
<pre>
|
||||
<?php
|
||||
11
pub/bin/pages/autop/pagePlatforms.php
Normal file
11
pub/bin/pages/autop/pagePlatforms.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pagePlatforms_add.php');
|
||||
} elseif (isset($_GET['edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pagePlatforms_edit.php');
|
||||
} else {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pagePlatforms_list.php');
|
||||
}
|
||||
96
pub/bin/pages/autop/pagePlatforms_add.php
Normal file
96
pub/bin/pages/autop/pagePlatforms_add.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-control-permissions', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_platform') . '</button></a>');
|
||||
$formBuilder = new formBuilder('add_platform', '<i class="fas fa-edit"></i>', '/platforms/',);
|
||||
$formBuilder->submitButtonText = __('save');
|
||||
$formBuilder->submitButtonIcon = '<i class="fas fa-save"></i>';
|
||||
|
||||
# Retrieve Information for the page
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('platforms'), 'href' => '/platforms/'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_platform'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/platforms">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="platform_name" name="platform_name" placeholder="" data-slugify="platform_slugify" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="platform_slugify" name="platform_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="platform_enabled" name="platform_enabled" class="form-control" required>
|
||||
<option value="1" selected><?php echo __('enabled') ?></option>
|
||||
<option value="0"><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="platform_description" name="platform_description" rows="5"> </textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="/src/images/placeholder200x200.png" alt="preview">
|
||||
<input type="file" class="form-control form-control-file" id="platform_image" name="platform_image" accept="image/png">
|
||||
<label for="platform_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
119
pub/bin/pages/autop/pagePlatforms_edit.php
Normal file
119
pub/bin/pages/autop/pagePlatforms_edit.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_platforms;
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_platforms.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-platforms', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_platform') . '</button></a>');
|
||||
|
||||
$formBuilder = new formBuilder('edit_platform', '<i class="fas fa-edit"></i>', '/platforms/',);
|
||||
$formBuilder->submitButtonText = __('save');
|
||||
$formBuilder->submitButtonIcon = '<i class="fas fa-save"></i>';
|
||||
|
||||
# Retrieve Information for the page
|
||||
$platform_uuid = $_GET['edit'];
|
||||
$_GET['platform_uuid'] = $platform_uuid;
|
||||
$API_platforms = new API_platforms();
|
||||
$_GET['builder'] = [1 => ['where' => [0 => 'platform_uuid', 1 => $platform_uuid]]];
|
||||
$requiredFields = ['platform_uuid' => ['type' => 'uuid']];
|
||||
$API_platforms->validateData($requiredFields);
|
||||
$platform_data = $API_platforms->getPlatforms()[0];
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('platforms'), 'href' => '/platforms/'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit_platform'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
if ($platform_data) {
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/platforms">
|
||||
<input type="hidden" name="platform_uuid" value="<?php echo $platform_data["platform_uuid"] ?>">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="platform_name" name="platform_name" placeholder="" value="<?php echo $platform_data['platform_name'] ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="platform_slugify" name="platform_slugify" placeholder="" value="<?php echo $platform_data['platform_slugify'] ?>" required disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="platform_enabled" name="platform_enabled" class="form-control" required>
|
||||
<option value="1" <?php echo(($platform_data['platform_enabled'] == 1) ? 'selected' : '') ?>><?php echo __('enabled') ?></option>
|
||||
<option value="0" <?php echo(($platform_data['platform_enabled'] == 0) ? 'selected' : '') ?>><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="platform_description" name="platform_description" rows="5"><?php echo $platform_data['platform_description'] ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="platform_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('platform_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="data:image/png;base64, <?php echo $platform_data['platform_image'] ?>" alt="preview">
|
||||
<input type="file" class="form-control form-control-file" id="platform_image" name="platform_image" accept="image/png">
|
||||
<label for="platform_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$formBuilder->formFooter();
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
$formBuilder->endForm();
|
||||
} else {
|
||||
|
||||
echo "No Platform found with uuid " . htmlspecialchars($_GET['edit'], ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
101
pub/bin/pages/autop/pagePlatforms_list.php
Normal file
101
pub/bin/pages/autop/pagePlatforms_list.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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();
|
||||
if (!$API->checkPermissions('admin-platforms', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(false, '<i class="fas fa-layer-group"></i> Platforms');
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_platform') . '</button></a>');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$data = $GLOBALS['conn']->query("SELECT * FROM vc_platforms");
|
||||
|
||||
# Set breadcrumb data
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
?>
|
||||
<div class="row g-3 align-items-stretch">
|
||||
<?php while ($row = $data->fetch_assoc()) { ?>
|
||||
<div class="col-md-4 px-2">
|
||||
<div class="card card-post card-round h-100">
|
||||
<img class="card-img-top img-fluid px-3" src="data:image/png;base64, <?php echo $row['platform_image'] ?>" alt="Card image cap" style="height: 200px; object-fit: scale-down;">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">
|
||||
<?php
|
||||
echo $row['platform_name'];
|
||||
if ($row['platform_enabled']) {
|
||||
echo ' <i class="fas fa-toggle-on text-success"></i>';
|
||||
} else {
|
||||
echo ' <i class="fas fa-toggle-off text-danger"></i>';
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<p class="card-text"><?php echo $row['platform_description'] ?></p>
|
||||
</div>
|
||||
<div class="card-footer pb-3 end-0 justify-content-end">
|
||||
<?php if ($API->checkPermissions('admin-platforms', 'RW', true)) { ?>
|
||||
<a href="?edit=<?php echo $row['platform_uuid'] ?>" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-platforms', 'RO', true)) { ?>
|
||||
<a href="#" class="btn btn-info btn-sm" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $row['platform_name'] ?>">
|
||||
<i class="fas fa-info-circle"></i> <?php echo __('info') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="infoModal<?php echo $row['platform_name'] ?>" 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">
|
||||
<br>
|
||||
<table class="table table-sm table-striped-bg-black">
|
||||
<tr>
|
||||
<td><?php echo __('uuid') ?>:</td>
|
||||
<td><?php echo $row['platform_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('create_date') ?>:</td>
|
||||
<td><?php echo showTime($row['platform_create_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('last_modified_date') ?>:</td>
|
||||
<td><?php showTime($row['platform_modified_timestamp']) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
1
pub/bin/pages/autop/pageProvisioning.php
Normal file
1
pub/bin/pages/autop/pageProvisioning.php
Normal file
@@ -0,0 +1 @@
|
||||
to be made
|
||||
11
pub/bin/pages/autop/pageVendors.php
Normal file
11
pub/bin/pages/autop/pageVendors.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageVendors_add.php');
|
||||
} elseif (isset($_GET['edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageVendors_edit.php');
|
||||
} else {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageVendors_list.php');
|
||||
}
|
||||
101
pub/bin/pages/autop/pageVendors_add.php
Normal file
101
pub/bin/pages/autop/pageVendors_add.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_vendors.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-vendors', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_vendor') . '</button></a>');
|
||||
|
||||
$formBuilder = new formBuilder('add_vendor', '<i class="fas fa-plus"></i>', '/vendors/');
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_vendor'), 'href' => '/vendors/'));
|
||||
|
||||
# Retrieve Information for the page
|
||||
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/vendors">
|
||||
<input type="hidden" name="_return" value="/vendors/">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="vendor_name" name="vendor_name" placeholder="" required data-slugify="vendor_slugify"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="vendor_slugify" name="vendor_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="vendor_enabled" name="vendor_enabled" class="form-control" required>
|
||||
<option value="1" selected><?php echo __('enabled') ?></option>
|
||||
<option value="0"><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="vendor_description" name="vendor_description" rows="5"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="/src/images/placeholder200x200.png" alt="preview">
|
||||
<input type="file" class="form-control form-control-file" id="vendor_image" name="vendor_image" accept="image/png">
|
||||
<label for="vendor_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$formBuilder->formFooter();
|
||||
?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
115
pub/bin/pages/autop/pageVendors_edit.php
Normal file
115
pub/bin/pages/autop/pageVendors_edit.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_vendors;
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_vendors.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-vendors', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_vendor') . '</button></a>');
|
||||
|
||||
$formBuilder = new formBuilder('edit_vendor', '<i class="fas fa-edit"></i>', '/vendors/',);
|
||||
$formBuilder->submitButtonText = __('save');
|
||||
$formBuilder->submitButtonIcon = '<i class="fas fa-save"></i>';
|
||||
|
||||
# Retrieve Information for the page
|
||||
$vendor_uuid = htmlspecialchars($_GET['edit'], ENT_QUOTES, 'UTF-8');
|
||||
$_GET['vendor_uuid'] = $vendor_uuid;
|
||||
$API_vendors = new API_vendors();
|
||||
$_GET['builder'] = [1 => ['where' => [0 => 'vendor_uuid', 1 => $vendor_uuid]]];
|
||||
$requiredFields = ['vendor_uuid' => ['type' => 'uuid']];
|
||||
$API_vendors->validateData($requiredFields);
|
||||
$vendor_data = $API_vendors->getVendors()[0];
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit_vendor'), 'href' => '/vendors/'));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
if ($vendor_data) { ?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/vendors">
|
||||
<input type="hidden" name="vendor_uuid" value="<?php echo $vendor_data["vendor_uuid"] ?>">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="vendor_name_edit" name="vendor_name" placeholder="" value="<?php echo $vendor_data['vendor_name'] ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="vendor_slugify_edit" name="vendor_slugify" placeholder="" value="<?php echo $vendor_data['vendor_slugify'] ?>" required disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_enabled" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_enabled') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="vendor_enabled" name="vendor_enabled" class="form-control" required>
|
||||
<option value="1" <?php echo(($vendor_data['vendor_enabled'] == 1) ? 'selected' : '') ?>><?php echo __('enabled') ?></option>
|
||||
<option value="0" <?php echo(($vendor_data['vendor_enabled'] == 0) ? 'selected' : '') ?>><?php echo __('disabled') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea class="form-control" id="vendor_description" name="vendor_description" rows="5"><?php echo $vendor_data['vendor_description'] ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="vendor_image" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('vendor_image') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview" width="200" src="data:image/png;base64, <?php echo $vendor_data['vendor_image'] ?>" alt="preview">
|
||||
<input type="file" class="form-control form-control-file" id="vendor_image" name="vendor_image" accept="image/png">
|
||||
<label for="vendor_image" class="label-input-file btn btn-black btn-round">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$formBuilder->formFooter();
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
$formBuilder->endForm();
|
||||
} else {
|
||||
echo "No Vendor found with uuid " . htmlspecialchars($_GET['edit'], ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
107
pub/bin/pages/autop/pageVendors_list.php
Normal file
107
pub/bin/pages/autop/pageVendors_list.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_vendors;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
// N/A
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_vendors.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-vendors', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions;
|
||||
|
||||
# JS Scripts to load for this page
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(false, '<i class="fas fa-microchip"></i> ' . __('vendors'));
|
||||
$pageNavbar->AddHTMLButton('<a href="?add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_vendor') . '</button></a>');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$API_vendors = new API_vendors();
|
||||
$vendors_data = $API_vendors->getVendors();
|
||||
|
||||
# Set breadcrumb data
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
?>
|
||||
<div class="row g-3 align-items-stretch">
|
||||
<?php
|
||||
foreach ($vendors_data as $vendor_data) { ?>
|
||||
<div class="col-md-4 px-2">
|
||||
<div class="card card-post card-round h-100">
|
||||
<img class="card-img-top img-fluid px-3" src="data:image/png;base64, <?php echo $vendor_data['vendor_image'] ?>" alt="Card image cap" style="height: 200px; object-fit: scale-down;">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">
|
||||
<?php
|
||||
echo $vendor_data['vendor_name'];
|
||||
if ($vendor_data['vendor_enabled']) {
|
||||
echo ' <i class="fas fa-toggle-on text-success"></i>';
|
||||
} else {
|
||||
echo ' <i class="fas fa-toggle-off text-danger"></i>';
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<p class="card-text"><?php echo $vendor_data['vendor_description'] ?></p>
|
||||
</div>
|
||||
<div class="card-footer pb-3 end-0 justify-content-end">
|
||||
<?php if ($API->checkPermissions('admin-vendors', 'RW', true)) { ?>
|
||||
<a href="?edit=<?php echo $vendor_data['vendor_uuid'] ?>" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-vendors', 'RO', true)) { ?>
|
||||
<a href="#" class="btn btn-info btn-sm" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $vendor_data['vendor_name'] ?>">
|
||||
<i class="fas fa-info-circle"></i> <?php echo __('info') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="infoModal<?php echo $vendor_data['vendor_name'] ?>" 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">
|
||||
<br>
|
||||
<table class="table table-sm table-striped-bg-black">
|
||||
<tr>
|
||||
<td><?php echo __('uuid') ?>:</td>
|
||||
<td><?php echo $vendor_data['vendor_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('create_date') ?>:</td>
|
||||
<td><?php showTime($vendor_data['vendor_create_timestamp']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('last_modified_date') ?>:</td>
|
||||
<td><?php showTime($vendor_data['vendor_modified_timestamp']); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
9
pub/bin/pages/customers/pageCompanies.php
Normal file
9
pub/bin/pages/customers/pageCompanies.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
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');
|
||||
}
|
||||
93
pub/bin/pages/customers/pageCompanies_company_view.php
Normal file
93
pub/bin/pages/customers/pageCompanies_company_view.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
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('customer-companies', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['datepicker'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
|
||||
# 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' => ''));
|
||||
|
||||
# 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>
|
||||
128
pub/bin/pages/customers/pageCompanies_view.php
Normal file
128
pub/bin/pages/customers/pageCompanies_view.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
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> <?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> <?php echo __('show_all') ?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a class="btn btn-secondary" href="?">
|
||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_active') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<form method="post" action="/api/v1/customers/companies/sync/">
|
||||
<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> <?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>
|
||||
<th><?php echo __('server_count') ?></th>
|
||||
<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>
|
||||
<th><?php echo __('server_count') ?></th>
|
||||
<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>
|
||||
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
|
||||
<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>
|
||||
190
pub/bin/pages/office/pageStompjes.php
Normal file
190
pub/bin/pages/office/pageStompjes.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['stompjes'] = true;
|
||||
$jsScriptLoadData['datatables'] = true;
|
||||
$jsScriptLoadData['multiFilterSelect'] = true;
|
||||
$jsScriptLoadData['datepicker'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
|
||||
|
||||
# Retrieve Information for the page
|
||||
$stmt = $GLOBALS['conn']->query("SELECT user_uuid, user_full_name, user_first_name, user_profile_picture_thumbnail, user_stompable, user_email FROM vc_users WHERE user_stompable = '1'");
|
||||
$administrators = [];
|
||||
while ($row = $stmt->fetch_assoc()) {
|
||||
$administrators[$row['user_uuid']] = $row;
|
||||
$administrators[$row['user_uuid']]['amount'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($_GET['fd'])) {
|
||||
$SelectFromDate = strtotime(date('Y-m-01'));
|
||||
} else {
|
||||
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
|
||||
$SelectFromDate = strtotime($date . ' 00:00:00');
|
||||
}
|
||||
if (!isset($_GET['td'])) {
|
||||
$SelectTillDate = time();
|
||||
} else {
|
||||
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
|
||||
$SelectTillDate = strtotime($date . ' 23:59:59');
|
||||
}
|
||||
|
||||
$stompjes = array();
|
||||
$stmt = $GLOBALS['conn']->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp FROM office_stompjes
|
||||
INNER JOIN vc_users ON office_stompjes.user_uuid = vc_users.user_uuid
|
||||
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
|
||||
AND user_stompable = '1'
|
||||
ORDER BY stomp_timestamp DESC");
|
||||
while ($row = $stmt->fetch_assoc()) {
|
||||
array_push($stompjes, $row);
|
||||
$administrators[$row['user_uuid']]['amount']++;
|
||||
}
|
||||
|
||||
# Start page output
|
||||
?>
|
||||
<script>
|
||||
const stompData = <?php echo json_encode($stompjes); ?>;
|
||||
</script>
|
||||
|
||||
<div class="form-group form-show-validation row mb-3">
|
||||
<div class="col-5">
|
||||
<h2>
|
||||
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> <?php echo __('stompjeslist') ?>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="col d-flex justify-content-end px-1">
|
||||
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-1">
|
||||
<label>
|
||||
<h5><?php echo __('from') ?>: </h5>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||
<div class="input-group">
|
||||
<input type="text" id="fd" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectFromDate) ?>"/>
|
||||
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
|
||||
<label>
|
||||
<h5><?php echo __('to') ?>: </h5>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
|
||||
<div class="input-group">
|
||||
<input type="text" id="td" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectTillDate) ?>"/>
|
||||
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||
<a id="datePicker" class="btn btn-primary"><i class="fa-solid fa-arrow-rotate-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<canvas id="stompjesChart" height="50"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-content-center">
|
||||
<?php foreach ($administrators as $administrator) {
|
||||
if ($administrator['user_email'] != 'superuser') { ?>
|
||||
<div class="col-sm-6 col-md-3 flex-shrink-0">
|
||||
<div class="card card-stats card-round">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-icon">
|
||||
<div class="avatar-l">
|
||||
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrator['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-stats ms-3 ms-sm-0">
|
||||
<div class="numbers">
|
||||
<p class="card-category"><?php echo $administrator['user_first_name'] ?></p>
|
||||
<h4 class="card-title" id="count-<?php echo $administrator['user_uuid'] ?>"><?php echo $administrator['amount'] ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-stats ms-3 ms-sm-0">
|
||||
<a href="#" class="btn btn-warning btn-lg btn-rounded stomp-btn w-100 <?php echo (!$API->checkPermissions('ofice-stompjes-canstomp', 'RW', true)) ? 'disabled' : '' ?>" data-item-uuid="<?php echo $administrator['user_uuid'] ?>" data-item-name="user_uuid" data-api-url="/api/v1/office/stompjes/"><i class="fa-solid fa-hand-fist"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,2,3" data-page-length="50">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php echo __('first_name') ?></th>
|
||||
<th><?php echo __('time') ?></th>
|
||||
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php echo __('first_name') ?></th>
|
||||
<th><?php echo __('time') ?></th>
|
||||
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($stompjes as $stompje) {
|
||||
if ($administrators[$stompje['user_uuid']]['user_email'] != 'superuser') { ?>
|
||||
<tr data-item-id="<?php echo $stompje['stomp_uuid']; ?>" data-user-uuid=<?php echo $stompje['user_uuid']; ?>>
|
||||
<td class="text-nowrap">
|
||||
<div class="avatar-sm ">
|
||||
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrators[$stompje['user_uuid']]['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-nowrap"><?php echo $administrators[$stompje['user_uuid']]['user_first_name'] ?></td>
|
||||
<td class="text-nowrap"><?php echo date('d-m-y H:i:s', $stompje['stomp_timestamp']) ?></td>
|
||||
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||
<td>
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded stomp-delete-btn" data-item-uuid="<?php echo $stompje['stomp_uuid'] ?>" data-api-url="/api/v1/office/stompjes/" data-item-name="stomp_uuid"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
77
pub/bin/pages/pageChangelog.php
Normal file
77
pub/bin/pages/pageChangelog.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<div class="card my-0">
|
||||
<div class="card-body py-0 border">
|
||||
<h5>
|
||||
Sentri<br> Made by:
|
||||
<a class="text-decoration-none" href="https://marcomooij.net" target="_blank">Marco Mooij</a><br> Version 1.0
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h3>Version 1.0</h3>
|
||||
<b>21-12-2025</b>
|
||||
<h4>First release version</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<b>First final release</b><br>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Version 0.1</h3>
|
||||
<b>23-12-2024</b>
|
||||
<h4>Initial release</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<b>The start of this project</b><br>
|
||||
</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<h1>Roadmap</h1>
|
||||
<ul>
|
||||
<li>
|
||||
View permissions in group view.
|
||||
</li>
|
||||
<li>
|
||||
Translation in server view/overview.
|
||||
</li>
|
||||
<li>
|
||||
Improvements into the server view.
|
||||
</li>
|
||||
<li>
|
||||
Make the /login page the same style as the rest of Sentri.
|
||||
</li>
|
||||
<li>
|
||||
Create a knowledge base.
|
||||
</li>
|
||||
<li>
|
||||
SSO/SAML/User provisioning.
|
||||
</li>
|
||||
<li>
|
||||
VM hosts overview.
|
||||
</li>
|
||||
<li>
|
||||
Loggin of actions to local storage or to things such as graylog.
|
||||
</li>
|
||||
<li>
|
||||
Light mode theme.
|
||||
</li>
|
||||
<li>
|
||||
View companies with connected servers.
|
||||
</li>
|
||||
<li>
|
||||
User email preferences.
|
||||
</li>
|
||||
<li>
|
||||
Travel cost page.
|
||||
</li>
|
||||
<li>
|
||||
Dashboard card display improvements.
|
||||
</li>
|
||||
<li>
|
||||
Add descriptions to servers.
|
||||
</li>
|
||||
<li>
|
||||
Add name to API tokens.
|
||||
</li>
|
||||
<li>
|
||||
If a server has the "new" state and it is deleted, it will be permanent.
|
||||
</li>
|
||||
</ul>
|
||||
132
pub/bin/pages/pageDashboard.php
Normal file
132
pub/bin/pages/pageDashboard.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
use api\classes\API;
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||
$API = new API();
|
||||
|
||||
function showCard($module_name, $page_name, $width = 3)
|
||||
{
|
||||
$page = $GLOBALS['pages'][$module_name][$page_name];
|
||||
?>
|
||||
<div class="col-md-<?php echo $width ?> col-sm-6 ps-md-0 pb-3">
|
||||
<a href="<?php echo $page['page_url'] ?>">
|
||||
<div class="card-pricing2 card-<?php echo $page['page_color'] ?> text-center h-100">
|
||||
<div class="pricing-header">
|
||||
<h3 class="fw-bold mb-3 text-center"><?php echo __($page['page_name']) ?></h3>
|
||||
</div>
|
||||
<div class="price-value">
|
||||
<div class="value ">
|
||||
<span class="amount"><i class="text-<?php echo $page['page_color'] ?> <?php echo $page['page_icon'] ?> mt-4"></i><span></span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<small>
|
||||
<br>
|
||||
<?php echo __($page['page_description']) ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="row mt-3">
|
||||
<?php
|
||||
if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RO', true)) { ?>
|
||||
<div class="col-md-6">
|
||||
<div class="row ">
|
||||
<div class="col-auto">
|
||||
<h3><?php echo __('customers') ?></h3>
|
||||
</div>
|
||||
<div class="col mt-1">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
showCard('customers', 'companies', '6');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RO', true)) { ?>
|
||||
<div class="col-md-6">
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<h3><?php echo __('servers') ?></h3>
|
||||
</div>
|
||||
<div class="col mt-1">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
showCard('servers', 'server_overview', '6');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php if ($GLOBALS['modules_enabled']['office'] && $API->checkPermissions('ofice-stompjes', 'RO', true)) { ?>
|
||||
<div class="row mt-3">
|
||||
<div class="col-auto">
|
||||
<h3><?php echo __('office') ?></h3>
|
||||
</div>
|
||||
<div class="col mt-1">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
showCard('office', 'stompjeslist');
|
||||
?>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
if ($GLOBALS['modules_enabled']['autop']) { ?>
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<h3><?php echo __('autoproviosioning') ?></h3>
|
||||
</div>
|
||||
<div class="col mt-1">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-stretch">
|
||||
<?php
|
||||
showCard('autop', 'platforms');
|
||||
showCard('autop', 'vendors');
|
||||
showCard('autop', 'devices');
|
||||
showCard('autop', 'device_settings');
|
||||
showCard('autop', 'provisioning');
|
||||
showCard('autop', 'phonebooks');
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($GLOBALS['modules_enabled']['system']) { ?>
|
||||
<div class="row mt-3">
|
||||
<div class="col-auto">
|
||||
<h3><?php echo __('portal_management') ?></h3>
|
||||
</div>
|
||||
<div class="col mt-1">
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
showCard('system', 'access_control');
|
||||
showCard('system', 'systemconfig');
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
2
pub/bin/pages/pageNotFound.php
Normal file
2
pub/bin/pages/pageNotFound.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
echo '404 not found';
|
||||
9
pub/bin/pages/pageUserProfile.php
Normal file
9
pub/bin/pages/pageUserProfile.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/pageUserProfile_edit.php');
|
||||
} else {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/pageUserProfile_view.php');
|
||||
}
|
||||
108
pub/bin/pages/pageUserProfile_edit.php
Normal file
108
pub/bin/pages/pageUserProfile_edit.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use bin\php\Classes\formBuilder;
|
||||
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'] . '/bin/php/Classes/formBuilder.php');
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['Generatepassword'] = true;
|
||||
$jsScriptLoadData['passwordShowHide'] = true;
|
||||
$jsScriptLoadData['passwordRegen'] = true;
|
||||
$jsScriptLoadData['enableButtonOnImageUpload'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$formBuilder = new formBuilder('Edit profile', '<i class="fas fa-plus"></i>', '/userprofile/');
|
||||
|
||||
# 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");
|
||||
$user_groups = array();
|
||||
$user_data = false;
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
$user_uuid = $_SESSION['user']['user_uuid'];
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_users INNER JOIN vc_user_groups ON vc_users.user_group_uuid = vc_user_groups.user_group_uuid WHERE user_uuid = ?");
|
||||
$stmt->bind_param("s", $user_uuid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows == 1) {
|
||||
$user_data = $result->fetch_assoc();
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_profile'), 'href' => '/userprofile/'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($user_data) {
|
||||
$formBuilder->startForm(); ?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/users/">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_uuid; ?>"/>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_email" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_email') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="email" class="form-control" id="user_email" name="user_email" value="<?php echo $user_data['user_email'] ?>" placeholder="user@example.xxx" required autofill="off" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_first_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('first_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_first_name" name="user_first_name" value="<?php echo $user_data['user_first_name'] ?>" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Last Name -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_last_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('last_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_last_name" name="user_last_name" value="<?php echo $user_data['user_last_name'] ?>" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Phone Number -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_phone_number" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('phone_number') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_phone_number" name="user_phone_number" placeholder="+1234542069" value="<?php echo $user_data['user_phone_number'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Preferred Language -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_pref_language" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('preferred_language') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_pref_language" name="user_pref_language" class="form-control">
|
||||
<?php foreach (scandir($_SERVER['DOCUMENT_ROOT'] . '/bin/locales/') as $file) {
|
||||
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
|
||||
$language = str_replace('.php', '', $file); ?>
|
||||
<option <?php echo(($user_data['user_pref_language'] == $language) ? 'selected' : '') ?> value="<?php echo $language ?>"><?php echo __($language) ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?><?php } else { ?>
|
||||
<p>no admin with this uuid found.</p>
|
||||
<?php } ?>
|
||||
332
pub/bin/pages/pageUserProfile_view.php
Normal file
332
pub/bin/pages/pageUserProfile_view.php
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API_apitoken;
|
||||
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_apitoken.php');
|
||||
|
||||
# Check permissions
|
||||
|
||||
# Page functions
|
||||
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['enableButtonOnImageUpload'] = true;
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['CopyTargetData'] = true;
|
||||
$jsScriptLoadData['updateToggle'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(false, '<i class="fa-solid fa-address-card"></i> ' . $_SESSION['user']['user_full_name'] . ' ' . strtolower(__('user_profile')));
|
||||
|
||||
# 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");
|
||||
$user_groups = array();
|
||||
$admin_data = false;
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
$user_uuid = $_SESSION['user']['user_uuid'];
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_users INNER JOIN vc_user_groups ON vc_users.user_group_uuid = vc_user_groups.user_group_uuid WHERE user_uuid = ?");
|
||||
$stmt->bind_param("s", $user_uuid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows == 1) {
|
||||
$user_data = $result->fetch_assoc();
|
||||
}
|
||||
|
||||
$_GET['user_uuid'] = $user_uuid;
|
||||
|
||||
$requiredFields = ['user_uuid' => ['type' => 'uuid']];
|
||||
$API_token = new API_apitoken();
|
||||
$API_token->validateData($requiredFields);
|
||||
$apitokens = $API_token->getTokens();
|
||||
|
||||
$new_api_token = false;
|
||||
if (isset($_SESSION['tmp_api_token'])) {
|
||||
$new_api_token = $_SESSION['tmp_api_token'];
|
||||
unset($_SESSION['tmp_api_token']);
|
||||
}
|
||||
|
||||
if ($API_token->checkPermissions('admin-access-admins', 'RW', true)) {
|
||||
$pageNavbar->AddHTMLButton('<a class="btn btn-primary mx-3" type="button" href="?edit=' . $_SESSION['user']['user_uuid'] . '"><i class="fas fa-edit"></i> ' . __('edit') . '</a>');
|
||||
};
|
||||
|
||||
# Set breadcrumb data
|
||||
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($user_data) { ?>
|
||||
<div class="row d-flex align-items-stretch pb-2">
|
||||
<div class="col-md-4 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="/api/v1/users/avatar/" enctype="multipart/form-data">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_data['user_uuid'] ?>">
|
||||
<h1 class="text-center"><?php echo $user_data['user_full_name'] ?></h1>
|
||||
<div class="form-group form-show-validation row align-items-center justify-content-center">
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview w-100" src="<?php echo(($user_data['user_profile_picture'] != null) ? 'data:image/png;base64, ' . $user_data['user_profile_picture'] : '/src/images/user-avatar-default-small.png') ?>" alt="user_profile_picture">
|
||||
<input type="file" class="form-control form-control-file" id="user_profile_picture" name="user_profile_picture" accept="image/png" data-enable-button="user_profile_change">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row justify-content-center">
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<label for="user_profile_picture" class="label-input-file btn btn-black btn-round mb-4">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
<button id="user_profile_change" type="submit" class="btn btn-primary opacity-0 transition-opacity" disabled>
|
||||
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tr>
|
||||
<td>user_uuid:</td>
|
||||
<td><?php echo $user_data['user_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_uuid:</td>
|
||||
<td><?php echo $user_data['user_group_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_name:</td>
|
||||
<td><?php echo $user_data['user_group_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_slugify:</td>
|
||||
<td><?php echo $user_data['user_group_slugify'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_email:</td>
|
||||
<td><?php echo $user_data['user_email'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_first_name:</td>
|
||||
<td><?php echo $user_data['user_first_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_last_name:</td>
|
||||
<td><?php echo $user_data['user_last_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_full_name:</td>
|
||||
<td><?php echo $user_data['user_full_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_phone_number: </td>
|
||||
<td><?php echo $user_data['user_phone_number'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_status: </td>
|
||||
<td><?php echo $user_data['user_status'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_password_reset_expires: </td>
|
||||
<td><?php echo $user_data['user_password_reset_expires'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_two_factor_enabled: </td>
|
||||
<td><?php echo $user_data['user_two_factor_enabled'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_verified_email: </td>
|
||||
<td><?php echo $user_data['user_verified_email'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_verified_phone: </td>
|
||||
<td><?php echo $user_data['user_verified_phone'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_create_timestamp: </td>
|
||||
<td><?php showTime($user_data['user_create_timestamp']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_modified_timestamp: </td>
|
||||
<td><?php showTime($user_data['user_modified_timestamp']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_last_login_timestamp: </td>
|
||||
<td><?php showTime($user_data['user_last_login_timestamp']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_login_attempts: </td>
|
||||
<td><?php echo $user_data['user_login_attempts'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_pref_language: </td>
|
||||
<td><?php echo $user_data['user_pref_language'] ?></td>
|
||||
</tr>
|
||||
<?php if ($GLOBALS['modules_enabled']['office']) { ?>
|
||||
<tr>
|
||||
<td>user_stompable: </td>
|
||||
<td><?php echo $user_data['user_stompable'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4>Email setttings</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
to be made later
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4><?php echo __('user_management') ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="mfa-enabled-row" class="row" style="display: <?php echo(($_SESSION['user']['user_two_factor_enabled'] == 1) ? '' : 'none') ?>">
|
||||
<div class="col-auto">
|
||||
<a href="#" class="btn btn-danger delete-btn" data-item-uuid="<?php echo $user_uuid ?>" data-api-url="/api/v1/users/mfa/" data-delete-action='{"mfa-enabled-row":"hide", "mfa-disabled-row":"show"}' data-item-name='user_uuid'>
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('reset_mfa') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mfa-disabled-row" class="row" style="display: <?php echo(($_SESSION['user']['user_two_factor_enabled'] == 1) ? 'none' : '') ?>">
|
||||
<div class="col-auto">
|
||||
<a class="btn btn-primary" href="/login/mfaSetup.php">
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('set_mfa') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<a class="btn btn-primary mt-2" href="/login/resetPassword.php" disabled="">
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('reset_password') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4 class="mb-0">User history</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
To be made. Its going show the history of the user.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-self', 'RO', true)) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php if ($new_api_token) { ?>
|
||||
<div class="card bg-primary text-center">
|
||||
<div class="card-body">
|
||||
<h4><?php echo __('api_token_created') ?>!</h4>
|
||||
<p>This token will be visible only now, please copy it now if you ever want to use it: </p>
|
||||
<div class="d-flex justify-content-center align-items-center gap-2">
|
||||
<div id="new-api-token" class="text-break" data-copy-data="<?php echo $new_api_token ?>">
|
||||
<?php echo $new_api_token ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-dark" data-copy-target="new-api-token" title="Copy Token">
|
||||
<i class="fa-solid fa-copy"></i> Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center pt-2 pb-1">
|
||||
<h4 class="mb-0"><?php echo __('api_tokens') ?></h4>
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-self', 'RW', true)) { ?>
|
||||
<form method="POST" action="/api/v1/users/apitoken/">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_uuid ?>">
|
||||
<input type="hidden" name="_return" value="/userprofile/">
|
||||
<button type="submit" href="#" class="btn btn-primary">
|
||||
<i class="fa-solid fa-plus"></i> <?php echo __('generate_new_api_token') ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Token id</th>
|
||||
<th>Expiration</th>
|
||||
<th>Created</th>
|
||||
<th>Last used</th>
|
||||
<th>Revoked</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($apitokens as $token_data) { ?>
|
||||
<tr>
|
||||
<td class="text-nowrap" style="max-width: 100%;">
|
||||
<div class="d-flex align-items-center gap-2" style="max-width: 100%;">
|
||||
<div class="text-truncate" style="max-width: 200px;" id="<?php echo $token_data['api_token_uuid'] ?>" data-copy-data="<?php echo $token_data['api_token_uuid']; ?>">
|
||||
<?php echo $token_data['api_token_uuid']; ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-copy-target="<?php echo $token_data['api_token_uuid'] ?>" title="Copy Token">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php showTime($token_data['api_token_expiration_timestamp']) ?></td>
|
||||
<td><?php showTime($token_data['api_token_created_timestamp']) ?></td>
|
||||
<td><?php showTime($token_data['api_token_last_used_timestamp']) ?></td>
|
||||
<td>
|
||||
<label class="switch">
|
||||
<input type="checkbox" class="checkbox" data-api-data='<?php echo json_encode(['api_token_uuid' => $token_data['api_token_uuid'], 'api_token_revoked' => $token_data['api_token_revoked'] ? 1 : 0]) ?>' data-api-changevalue="api_token_revoked" data-api-url="/api/v1/users/apitoken/" <?php echo((($token_data['api_token_revoked'])) ? 'checked' : '') ?>>
|
||||
<div class="slider"></div>
|
||||
</label>
|
||||
</td>
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-self', 'RW', true)) { ?>
|
||||
<td class="text-nowrap">
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $token_data['api_token_uuid'] ?>" data-item-name="api_token_uuid" data-api-url="/api/v1/users/apitoken/"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?><?php } else {
|
||||
echo 'user not found';
|
||||
}
|
||||
9
pub/bin/pages/servers/pageServerOverview.php
Normal file
9
pub/bin/pages/servers/pageServerOverview.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
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');
|
||||
}
|
||||
415
pub/bin/pages/servers/pageServerOverview_server_view.php
Normal file
415
pub/bin/pages/servers/pageServerOverview_server_view.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?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');
|
||||
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;
|
||||
|
||||
# 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();
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
# 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'] ?>
|
||||
</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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<i class="fa-solid fa-hard-drive"></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 text-success">
|
||||
<i class="fa-solid fa-hard-drive"></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">
|
||||
<?php echo __('disk_space') ?>: <?php echo $disk['disk_space'] ?>
|
||||
<br> <?php echo __('disk_used') ?>: <?php echo $disk['disk_used'] ?>
|
||||
<br> <?php echo __('disk_location') ?>: <?php echo $disk['disk_location'] ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
|
||||
if (is_array($licenses) && count($licenses) > 0) { ?>
|
||||
<h2>
|
||||
<i class="fa-solid fa-file-invoice-dollar"></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 text-success">
|
||||
<i class="fa-solid fa-file-invoice-dollar"></i> <?php echo 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-6 col-lg-6">
|
||||
<table>
|
||||
<tr>
|
||||
<td>server_uuid:</td>
|
||||
<td><?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_power_state:</td>
|
||||
<td><?php echo $server_data['server_power_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><?php echo $server_data['server_disks'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>server_ipv4:</td>
|
||||
<td><?php echo $server_data['server_ipv4'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>server_ipv6:</td>
|
||||
<td><?php echo $server_data['server_ipv6'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>server_licenses:</td>
|
||||
<td><?php echo $server_data['server_licenses'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>server_backup:</td>
|
||||
<td><?php echo $server_data['server_backup'] ?></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'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>server_modified_timestamp:</td>
|
||||
<td><?php echo $server_data['server_modified_timestamp'] ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
503
pub/bin/pages/servers/pageServerOverview_view.php
Normal file
503
pub/bin/pages/servers/pageServerOverview_view.php
Normal file
@@ -0,0 +1,503 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
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['datatables'] = true;
|
||||
$jsScriptLoadData['multiFilterSelectServers'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
|
||||
# Retrieve Information for the page
|
||||
if (!isset($_GET['del'])) {
|
||||
$query = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted' ORDER BY server_vm_host_name";
|
||||
} else {
|
||||
$query = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid ORDER BY server_vm_host_name";
|
||||
}
|
||||
|
||||
$stmt = $GLOBALS['conn']->query($query);
|
||||
$servers = [];
|
||||
while ($row = $stmt->fetch_assoc()) {
|
||||
array_push($servers, $row);
|
||||
}
|
||||
|
||||
$allBackupTypes = [];
|
||||
$allLicenseTypes = [];
|
||||
foreach ($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) {
|
||||
$allBackupTypes[$key] = true; // use keys as unique types
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
$allLicenseTypes[$key] = true; // keys are license types
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$allBackupTypes = array_keys($allBackupTypes);
|
||||
sort($allBackupTypes);
|
||||
|
||||
$allLicenseTypes = array_keys($allLicenseTypes);
|
||||
sort($allLicenseTypes);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
if (isset($_COOKIE['serverTableColumns'])) {
|
||||
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
|
||||
foreach ($CheckedColumns as $CheckedColumn) {
|
||||
$showColumns[$CheckedColumn] = true;
|
||||
}
|
||||
} else {
|
||||
$showColumns['server_hostname'] = true;
|
||||
$showColumns['company_name'] = true;
|
||||
$showColumns['server_os'] = true;
|
||||
$showColumns['server_cpu'] = true;
|
||||
$showColumns['server_memory'] = true;
|
||||
$showColumns['server_memory_demand'] = true;
|
||||
$showColumns['server_disks'] = true;
|
||||
$showColumns['server_state'] = true;
|
||||
}
|
||||
|
||||
|
||||
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'), '.');
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
?>
|
||||
|
||||
<div class="form-group form-show-validation row mb-3">
|
||||
<div class="col-auto">
|
||||
<h2>
|
||||
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> <?php echo __('server_overview') ?>
|
||||
</h2>
|
||||
</div>
|
||||
<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($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($showColumns['server_hostname'] ? 'checked=""' : '') ?>>
|
||||
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($showColumns['company_name'] ? 'checked=""' : '') ?>>
|
||||
<span class="selectgroup-button"><?php echo __('company') ?></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($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($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($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($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($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($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($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($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($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($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($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($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($showColumns['server_description'] ? 'checked=""' : '') ?>>
|
||||
<span class="selectgroup-button"><?php echo __('description') ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<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> <?php echo __('show_del') ?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a class="btn btn-danger " href="/servers">
|
||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_del') ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
</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="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>
|
||||
<th data-column="company_name"><?php echo __('company') ?></th>
|
||||
<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 ($allLicenseTypes as $licenseType) { ?>
|
||||
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
||||
<?php }
|
||||
foreach ($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>
|
||||
<th data-column="company_name"><?php echo __('company') ?></th>
|
||||
<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 ($allLicenseTypes as $licenseType) { ?>
|
||||
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
||||
<?php }
|
||||
foreach ($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 ($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 = 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 ($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 ($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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$company_name = '';
|
||||
if (strlen($server['company_name']) > 0) {
|
||||
$company_name = $server['company_name'];
|
||||
}
|
||||
|
||||
$server_state_color = 'secondary';
|
||||
if (strlen($server['server_state']) > 0) {
|
||||
$server_state = ucfirst($server['server_state']);
|
||||
switch ($server_state) {
|
||||
case 'New':
|
||||
$server_state_color = 'secondary';
|
||||
break;
|
||||
case 'Deleted':
|
||||
$server_state_color = 'danger';
|
||||
break;
|
||||
case 'Trial':
|
||||
$server_state_color = 'primary';
|
||||
break;
|
||||
case 'Disabled':
|
||||
$server_state_color = 'gray';
|
||||
break;
|
||||
case 'Active':
|
||||
$server_state_color = 'success';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
|
||||
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server_state); ?>" data-sort="<?php echo htmlspecialchars($server_state); ?>">
|
||||
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $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>
|
||||
<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>
|
||||
<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 ($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 ($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>
|
||||
23
pub/bin/pages/system/pageAccessControl.php
Normal file
23
pub/bin/pages/system/pageAccessControl.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['user_group_add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_user_group_add.php');
|
||||
} elseif (isset($_GET['user_group_edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_user_group_edit.php');
|
||||
} elseif (isset($_GET['permission_add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_permission_add.php');
|
||||
} elseif (isset($_GET['permission_edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_permission_edit.php');
|
||||
} elseif (isset($_GET['permission_view'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_permission_view.php');
|
||||
} elseif (isset($_GET['admin_add'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_admin_add.php');
|
||||
} elseif (isset($_GET['admin_edit'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_admin_edit.php');
|
||||
} elseif (isset($_GET['admin_view'])) {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_admin_view.php');
|
||||
} else {
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/system/pageAccessControl_view.php');
|
||||
}
|
||||
122
pub/bin/pages/system/pageAccessControl_admin_add.php
Normal file
122
pub/bin/pages/system/pageAccessControl_admin_add.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-admins', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['Generatepassword'] = true;
|
||||
$jsScriptLoadData['passwordGenOnLoad'] = true;
|
||||
$jsScriptLoadData['passwordShowHide'] = true;
|
||||
$jsScriptLoadData['passwordRegen'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<button class="btn btn-danger mx-3" type="button" disabled><i class="fas fa-trash-alt"></i>' . __('delete') . '</button>');
|
||||
$pageNavbar->AddHTMLButton('<a href="?admin_add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_admin') . '</button></a>');
|
||||
$formBuilder = new formBuilder('add_admin', '<i class="fas fa-plus"></i>', '/accesscontrol/#user-groups');
|
||||
|
||||
# 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");
|
||||
$user_groups = array();
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('administrators'), 'href' => '/accesscontrol/#administrators'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_admin'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="POST" action="/api/v1/users/">
|
||||
<div class="card-body">
|
||||
<div class="col">
|
||||
<p><?php echo __('admin_creation_instruction') ?></p>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group') ?></label>
|
||||
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_group_uuid" name="user_group_uuid" class="form-control" required>
|
||||
<?php foreach ($user_groups as $user_group) {
|
||||
if ($user_group['user_group_weight'] >= $_SESSION['user']['user_group_weight']) { ?>
|
||||
<option value="<?php echo $user_group['user_group_uuid'] ?>"><?php echo $user_group['user_group_name'] ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
<!-- Options should be dynamically generated from the database -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_email" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_email') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="email" class="form-control" id="user_email" name="user_email" placeholder="user@example.xxx" required autofill="off" autofocus autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_first_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('first_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_first_name" name="user_first_name" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Last Name -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_last_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('last_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_last_name" name="user_last_name" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Phone Number -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_phone_number" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('phone_number') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_phone_number" name="user_phone_number" placeholder="+1234542069"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Status -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_status" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_status') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_status" name="user_status" class="form-control" required>
|
||||
<option value="inactive"><?php echo __('inactive') ?></option>
|
||||
<option value="banned"><?php echo __('banned') ?></option>
|
||||
<option value="pending" selected><?php echo __('pending') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
158
pub/bin/pages/system/pageAccessControl_admin_edit.php
Normal file
158
pub/bin/pages/system/pageAccessControl_admin_edit.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-admins', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$pageNavbar->AddHTMLButton('<button class="btn btn-danger mx-3" type="button" disabled><i class="fas fa-trash-alt"></i>' . __('delete') . '</button>');
|
||||
$pageNavbar->AddHTMLButton('<a href="?admin_add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i>' . __('add_admin') . '</button></a>');
|
||||
$formBuilder = new formBuilder('edit_admin', '<i class="fas fa-plus"></i>', '/accesscontrol/#user-groups');
|
||||
|
||||
# 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");
|
||||
$user_groups = array();
|
||||
$admin_data = false;
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
$user_uuid = $_GET['admin_edit'];
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_users INNER JOIN vc_user_groups ON vc_users.user_group_uuid = vc_user_groups.user_group_uuid WHERE user_uuid = ?");
|
||||
$stmt->bind_param("s", $user_uuid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows == 1) {
|
||||
$admin_data = $result->fetch_assoc();
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('administrators'), 'href' => '/accesscontrol/#administrators'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit_admin'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
if ($admin_data) {
|
||||
$formBuilder->startForm(); ?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/users/">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="_return" value="/accesscontrol/?admin_view=<?php echo $user_uuid ?>">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_uuid; ?>"/>
|
||||
<div class="card-body">
|
||||
<!-- User Group -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group') ?></label>
|
||||
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_group_uuid" name="user_group_uuid" class="form-control" required>
|
||||
<?php foreach ($user_groups as $user_group) {
|
||||
if ($user_group['user_group_weight'] >= $_SESSION['user']['user_group_weight']) { ?>?>
|
||||
<option <?php echo(($admin_data['user_group_uuid'] == $user_group['user_group_uuid']) ? 'selected' : '') ?> value="<?php echo $user_group['user_group_uuid'] ?>"><?php echo $user_group['user_group_name'] ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_email" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_email') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="email" class="form-control" id="user_email" name="user_email" value="<?php echo $admin_data['user_email'] ?>" placeholder="user@example.xxx" required autofill="off" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_first_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('first_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_first_name" name="user_first_name" value="<?php echo $admin_data['user_first_name'] ?>" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Last Name -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_last_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('last_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_last_name" name="user_last_name" value="<?php echo $admin_data['user_last_name'] ?>" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Phone Number -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_phone_number" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('phone_number') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_phone_number" name="user_phone_number" placeholder="+1234542069" value="<?php echo $admin_data['user_phone_number'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Status -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_status" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_status') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_status" name="user_status" class="form-control" required>
|
||||
<option value="active" <?php echo(($admin_data['user_status'] == 'active') ? 'selected' : '') ?> ><?php echo __('active') ?></option>
|
||||
<option value="inactive" <?php echo(($admin_data['user_status'] == 'inactive') ? 'selected' : '') ?>><?php echo __('inactive') ?></option>
|
||||
<option value="banned" <?php echo(($admin_data['user_status'] == 'banned') ? 'selected' : '') ?>><?php echo __('banned') ?></option>
|
||||
<option value="pending" <?php echo(($admin_data['user_status'] == 'pending') ? 'selected' : '') ?>><?php echo __('pending') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Preferred Language -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_pref_language" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('preferred_language') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_pref_language" name="user_pref_language" class="form-control">
|
||||
<option value="none" selected>Browser language</option>
|
||||
<?php foreach (scandir($_SERVER['DOCUMENT_ROOT'] . '/bin/locales/') as $file) {
|
||||
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
|
||||
$language = str_replace('.php', '', $file); ?>
|
||||
<option <?php echo(($admin_data['user_pref_language'] == $language) ? 'selected' : '') ?> value="<?php echo $language ?>"><?php echo __($language) ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($GLOBALS['modules_enabled']['office']) { ?>
|
||||
<!-- Stompbable -->
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_stompable" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('stompable') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="user_stompable" name="user_stompable" class="form-control">
|
||||
<option <?php echo(($admin_data['user_stompable'] == 0) ? 'selected' : '') ?> value="0">Disabled</option>
|
||||
<option <?php echo(($admin_data['user_stompable'] == 1) ? 'selected' : '') ?> value="1">Enabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?><?php } else { ?>
|
||||
<p>no admin with this uuid found.</p>
|
||||
<?php } ?>
|
||||
328
pub/bin/pages/system/pageAccessControl_admin_view.php
Normal file
328
pub/bin/pages/system/pageAccessControl_admin_view.php
Normal file
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_apitoken;
|
||||
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_apitoken.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-admins', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['Generatepassword'] = true;
|
||||
$jsScriptLoadData['passwordShowHide'] = true;
|
||||
$jsScriptLoadData['passwordRegen'] = true;
|
||||
$jsScriptLoadData['enableButtonOnImageUpload'] = true;
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
$jsScriptLoadData['updateToggle'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
if ($API->checkPermissions('admin-access-admins', 'RW', true)) {
|
||||
$pageNavbar->AddHTMLButton('<button class="btn btn-danger" type="button" disabled><i class="fas fa-trash-alt"></i> ' . __('delete') . '</button>');
|
||||
$admin_view = htmlspecialchars($_GET['admin_view'], ENT_QUOTES, 'UTF-8');
|
||||
$pageNavbar->AddHTMLButton('<a class="btn btn-primary mx-3" type="button" href="?admin_edit=' . $admin_view . '"><i class="fas fa-edit text-warning"></i> ' . __('edit') . '</a>');
|
||||
$pageNavbar->AddHTMLButton('<a href="?admin_add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i> ' . __('add_admin') . '</button></a>');
|
||||
}
|
||||
|
||||
# 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");
|
||||
$user_groups = array();
|
||||
$admin_data = false;
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
$user_uuid = $_GET['admin_view'];
|
||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM vc_users INNER JOIN vc_user_groups ON vc_users.user_group_uuid = vc_user_groups.user_group_uuid WHERE user_uuid = ?");
|
||||
$stmt->bind_param("s", $user_uuid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows == 1) {
|
||||
$admin_data = $result->fetch_assoc();
|
||||
}
|
||||
|
||||
$_GET['user_uuid'] = $user_uuid;
|
||||
|
||||
$API_token = new API_apitoken();
|
||||
$requiredFields = ['user_uuid' => ['type' => 'uuid']];
|
||||
$API_token->validateData($requiredFields);
|
||||
$apitokens = $API_token->getTokens();
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('administrators'), 'href' => '/accesscontrol/#administrators'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
|
||||
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($admin_data) { ?>
|
||||
<div class="row d-flex align-items-stretch pb-2">
|
||||
<div class="col-md-4 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="/api/v1/users/avatar/" enctype="multipart/form-data">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $admin_data['user_uuid'] ?>">
|
||||
<h1 class="text-center"><?php echo $admin_data['user_full_name'] ?></h1>
|
||||
<div class="form-group form-show-validation row align-items-center justify-content-center">
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-file input-file-image">
|
||||
<img class="img-upload-preview w-100" src="<?php echo(($admin_data['user_profile_picture'] != null) ? 'data:image/png;base64, ' . $admin_data['user_profile_picture'] : '/src/images/user-avatar-default-small.png') ?>" alt="user_profile_picture">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RW', true)) { ?>
|
||||
<input type="file" class="form-control form-control-file" id="user_profile_picture" name="user_profile_picture" accept="image/png" data-enable-button="user_profile_change">
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row justify-content-center">
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RW', true)) { ?>
|
||||
<label for="user_profile_picture" class="label-input-file btn btn-black btn-round mb-4">
|
||||
<span class="btn-label"><i class="fa fa-file-image"></i></span>
|
||||
<?php echo __('upload_image') ?>
|
||||
</label>
|
||||
<button id="user_profile_change" type="submit" class="btn btn-primary opacity-0 transition-opacity" disabled>
|
||||
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8 pb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tr>
|
||||
<td>user_uuid:</td>
|
||||
<td><?php echo $admin_data['user_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_uuid:</td>
|
||||
<td><?php echo $admin_data['user_group_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_name:</td>
|
||||
<td><?php echo $admin_data['user_group_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_group_slugify:</td>
|
||||
<td><?php echo $admin_data['user_group_slugify'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_email:</td>
|
||||
<td><?php echo $admin_data['user_email'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_first_name:</td>
|
||||
<td><?php echo $admin_data['user_first_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_last_name:</td>
|
||||
<td><?php echo $admin_data['user_last_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_full_name:</td>
|
||||
<td><?php echo $admin_data['user_full_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_phone_number: </td>
|
||||
<td><?php echo $admin_data['user_phone_number'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_status: </td>
|
||||
<td><?php echo $admin_data['user_status'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_password_reset_expires: </td>
|
||||
<td><?php echo $admin_data['user_password_reset_expires'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_two_factor_enabled: </td>
|
||||
<td><?php echo $admin_data['user_two_factor_enabled'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_verified_email: </td>
|
||||
<td><?php echo $admin_data['user_verified_email'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_verified_phone: </td>
|
||||
<td><?php echo $admin_data['user_verified_phone'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_create_timestamp: </td>
|
||||
<td><?php showTime($admin_data['user_create_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_modified_timestamp: </td>
|
||||
<td><?php showTime($admin_data['user_modified_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_last_login_timestamp: </td>
|
||||
<td><?php showTime($admin_data['user_last_login_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_login_attempts: </td>
|
||||
<td><?php echo $admin_data['user_login_attempts'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user_pref_language: </td>
|
||||
<td><?php echo $admin_data['user_pref_language'] ?></td>
|
||||
</tr>
|
||||
<?php if ($GLOBALS['modules_enabled']['office']) { ?>
|
||||
<tr>
|
||||
<td>user_stompable: </td>
|
||||
<td><?php echo $admin_data['user_stompable'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4>email-preferences</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
to be made
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4><?php echo __('user_management') ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if ($API->checkPermissions('admin-access-admins-mfa', 'RW', true)) { ?>
|
||||
<div id="mfa-enabled-row" class="row" style="display: <?php echo(($admin_data['user_two_factor_enabled']) ? '' : 'none') ?>">
|
||||
<div class="col-auto">
|
||||
<a href="#" class="btn btn-danger delete-btn" data-item-uuid="<?php echo $admin_data['user_uuid'] ?>" data-api-url="/api/v1/users/mfa/" data-item-name='user_uuid' data-delete-action='{"mfa-enabled-row":"hide", "mfa-disabled-row":"show"}'>
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('reset_mfa') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mfa-disabled-row" class="row" style="display: <?php echo(($admin_data['user_two_factor_enabled'] == 1) ? 'none' : '') ?>">
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-danger delete-btn" href="#" disabled>
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('reset_mfa') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-admins-resetpassword', 'RW', true)) { ?>
|
||||
<form method="post" action="/api/v1/users/resetpassword/">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_uuid ?>">
|
||||
<button class="btn btn-primary mt-2">
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('send_password_reset') ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
reset the verified email (to be made)<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-others', 'RO', true)) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header d-flex justify-content-between align-items-center pt-2 pb-1">
|
||||
<h4 class="mb-0">API Tokens</h4>
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-others', 'RW', true)) { ?>
|
||||
<form method="POST" action="/api/v1/users/apitoken/">
|
||||
<input type="hidden" name="user_uuid" value="<?php echo $user_uuid ?>">
|
||||
<input type="hidden" name="_return" value="/accesscontrol/?admin_view=<?php echo $user_uuid ?>">
|
||||
<button type="submit" href="#" class="btn btn-primary">
|
||||
<i class="fa-solid fa-plus"></i> Generate new token
|
||||
</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>token</th>
|
||||
<th>Expiration</th>
|
||||
<th>Created</th>
|
||||
<th>Last used</th>
|
||||
<th>Revoked</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($apitokens as $token_data) { ?>
|
||||
<tr>
|
||||
<td class="text-nowrap" style="max-width: 100%;">
|
||||
<div class="d-flex align-items-center gap-2" style="max-width: 100%;">
|
||||
<div class="text-truncate" style="max-width: 200px;">
|
||||
<?php echo substr($token_data['api_token'], 0, 15) . '...'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php showTime($token_data['api_token_expiration_timestamp']) ?></td>
|
||||
<td><?php showTime($token_data['api_token_created_timestamp']) ?></td>
|
||||
<td><?php showTime($token_data['api_token_last_used_timestamp']) ?></td>
|
||||
<td>
|
||||
<label class="switch">
|
||||
<input type="checkbox" class="checkbox" data-api-data='<?php echo json_encode(['api_token_uuid' => $token_data['api_token_uuid'], 'api_token_revoked' => $token_data['api_token_revoked'] ? 1 : 0]) ?>' data-api-changevalue="api_token_revoked" data-api-url="/api/v1/users/apitoken/" <?php echo((($token_data['api_token_revoked'])) ? 'checked' : '') ?>>
|
||||
<div class="slider"></div>
|
||||
</label>
|
||||
</td>
|
||||
<?php if ($API_token->checkPermissions('user-apitoken-others', 'RW', true)) { ?>
|
||||
<td class="text-nowrap">
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $token_data['api_token_uuid'] ?>" data-item-name="api_token_uuid" data-api-url="/api/v1/users/apitoken/"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header pt-2 pb-1">
|
||||
<h4>User history</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
To be made. Its going show the history of the administrator.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } else {
|
||||
echo 'admin not found';
|
||||
}
|
||||
93
pub/bin/pages/system/pageAccessControl_permission_add.php
Normal file
93
pub/bin/pages/system/pageAccessControl_permission_add.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
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->isSuperuser()) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'][] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$formBuilder = new formBuilder('add_permission', '<i class="fas fa-plus"></i>', '/accesscontrol/#permissions');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$system_modules_data = $GLOBALS['conn']->query("SELECT * FROM system_modules WHERE module_enabled = 1");
|
||||
$system_modules = array();
|
||||
while ($module = $system_modules_data->fetch_assoc()) {
|
||||
array_push($system_modules, $module);
|
||||
}
|
||||
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_permission'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" method="POST" action="/api/v1/permissions/">
|
||||
<input type="hidden" name="_return" value="/accesscontrol/#permission">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="permission_name" name="permission_name" placeholder="" data-slugify="permission_slugify" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="permission_slugify" name="permission_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="module_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('module') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="module_uuid" name="module_uuid" class="form-control" required>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
foreach ($system_modules as $module) { ?>
|
||||
<option value="<?php echo $module['module_uuid'] ?>"> <?php echo $module['module_name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea type="text" class="form-control" id="permission_description" name="permission_description" placeholder="" required rows="5"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
106
pub/bin/pages/system/pageAccessControl_permission_edit.php
Normal file
106
pub/bin/pages/system/pageAccessControl_permission_edit.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_permissions;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php';
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-control-permissions', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'][] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$formBuilder = new formBuilder('edit_permission', '<i class="fas fa-plus"></i>', '/accesscontrol/#permission');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$permission_uuid = $_GET['permission_edit'];
|
||||
$_GET['permission_uuid'] = $permission_uuid;
|
||||
$API_permissions = new API_permissions();
|
||||
$_GET['builder'] = [1 => ['where' => [0 => 'permission_uuid', 1 => $permission_uuid]]];
|
||||
$requiredFields = ['permission_uuid' => ['type' => 'uuid']];
|
||||
$API_permissions->validateData($requiredFields);
|
||||
$permission_data = $API_permissions->getPermission()[0];
|
||||
|
||||
# Retrieve Information for the page
|
||||
$system_modules_data = $GLOBALS['conn']->query("SELECT * FROM system_modules WHERE module_enabled = 1");
|
||||
$system_modules = array();
|
||||
while ($module = $system_modules_data->fetch_assoc()) {
|
||||
array_push($system_modules, $module);
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit_permission'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($permission_data) {
|
||||
$formBuilder->startForm(); ?>
|
||||
<form id="FormValidation" method="post" action="/api/v1/permissions/">
|
||||
<input type="hidden" name="_return" value="/accesscontrol/?permission_view=<?php echo $permission_uuid ?>">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="permission_uuid" value="<?php echo $permission_uuid ?>">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="permission_name" name="permission_name" value="<?php echo $permission_data['permission_name'] ?>" placeholder="" data-slugify="permission_slugify" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="permission_slugify" name="permission_slugify" value="<?php echo $permission_data['permission_slugify'] ?>" placeholder="" disabled/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="module_uuid" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('module') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="module_uuid" name="module_uuid" class="form-control" required>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
foreach ($system_modules as $module) { ?>
|
||||
<option value="<?php echo $module['module_uuid'] ?>" <?php echo ($module['module_uuid'] == $permission_data['module_uuid']) ? 'selected' : '' ?>> <?php echo $module['module_name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="permission_description" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('permission_description') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<textarea type="text" class="form-control" id="permission_description" name="permission_description" placeholder="" required rows="5"><?php echo $permission_data['permission_description'] ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?><?php } else {
|
||||
echo 'permission not found';
|
||||
} ?>
|
||||
153
pub/bin/pages/system/pageAccessControl_permission_view.php
Normal file
153
pub/bin/pages/system/pageAccessControl_permission_view.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_permissions;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php';
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-control-permissions', 'RO', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['datatables'] = true;
|
||||
$jsScriptLoadData['updatePermissions'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
if ($API->isSuperuser()) {
|
||||
$pageNavbar->AddHTMLButton('<button class="btn btn-danger" type="button" disabled><i class="fas fa-trash-alt"></i> ' . __('delete') . '</button>');
|
||||
}
|
||||
if ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) {
|
||||
$permission_view = htmlspecialchars($_GET['permission_view'], ENT_QUOTES, 'UTF-8');
|
||||
$pageNavbar->AddHTMLButton('<a class="btn btn-primary mx-3" type="button" href="?permission_edit=' . $permission_view . '"><i class="fas fa-edit text-warning"></i> ' . __('edit') . '</a>');
|
||||
}
|
||||
if ($API->isSuperuser()) {
|
||||
$pageNavbar->AddHTMLButton('<a href="?permission_add="><button class="btn btn-primary"><i class="fas fa-plus text-success"></i> ' . __('add_permission') . '</button></a>');
|
||||
}
|
||||
|
||||
|
||||
# Retrieve Information for the page
|
||||
$permission_uuid = $_GET['permission_view'];
|
||||
$_GET['permission_uuid'] = $permission_uuid;
|
||||
$API_permissions = new API_permissions();
|
||||
$requiredFields = ['permission_uuid' => ['type' => 'uuid']];
|
||||
$API_permissions->validateData($requiredFields);
|
||||
$permission_data = $API_permissions->getPermissionRights();
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
|
||||
if ($permission_data) { ?>
|
||||
<h2>
|
||||
<i class="fa-solid fa-lock"></i> <?php echo $permission_data[0]['permission_name'] ?>
|
||||
</h2>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tr>
|
||||
<td>permission_uuid:</td>
|
||||
<td><?php echo $permission_data[0]['permission_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>permission_name:</td>
|
||||
<td><?php echo $permission_data[0]['permission_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>permission_slugify:</td>
|
||||
<td><?php echo $permission_data[0]['permission_slugify'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>permission_description:</td>
|
||||
<td><?php echo $permission_data[0]['permission_description'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>module_uuid:</td>
|
||||
<td><?php echo $permission_data[0]['module_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>permission_create_timestamp:</td>
|
||||
<td><?php showTime($permission_data[0]['permission_create_timestamp']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>permission_modified_datetime:</td>
|
||||
<td><?php showTime($permission_data[0]['permission_modified_timestamp']); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<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>
|
||||
</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>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($permission_data as $permission_data_group) {
|
||||
if ($permission_data_group['user_group_slugify'] != 'superuser') { ?>
|
||||
<tr>
|
||||
<td><?php echo $permission_data_group['user_group_slugify'] ?> </td>
|
||||
<td>
|
||||
<label class="switch">
|
||||
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $permission_data_group['permission_uuid'] ?>" data-user-group-uuid="<?= $permission_data_group['user_group_uuid'] ?>" data-value="NA" data-api-url="/api/v1/access-rights/" <?php echo(($permission_data_group['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="<?= $permission_data_group['permission_uuid'] ?>" data-user-group-uuid="<?= $permission_data_group['user_group_uuid'] ?>" data-value="RO" data-api-url="/api/v1/access-rights/" <?php echo(($permission_data_group['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="<?= $permission_data_group['permission_uuid'] ?>" data-user-group-uuid="<?= $permission_data_group['user_group_uuid'] ?>" data-value="RW" data-api-url="/api/v1/access-rights/" <?php echo(($permission_data_group['permission_value'] == 'RW') ? 'checked' : '') ?>
|
||||
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
|
||||
<div class="slider"></div>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?><?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php } else {
|
||||
echo '404 not found';
|
||||
}
|
||||
90
pub/bin/pages/system/pageAccessControl_user_group_add.php
Normal file
90
pub/bin/pages/system/pageAccessControl_user_group_add.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
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('admin-access-control-user-groups', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'][] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$formBuilder = new formBuilder('add_user_groups', '<i class="fas fa-plus"></i>', '/accesscontrol/#user-groups');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups ORDER BY user_group_weight ASC");
|
||||
$user_groups = array();
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_groups'), 'href' => '/accesscontrol/#user-groups'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('add_user_groups'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/user-groups/">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_group_name" name="user_group_name" placeholder="" data-slugify="user_group_slugify" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_group_slugify" name="user_group_slugify" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_type" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_type') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="user_group_type" name="user_group_type" class="form-control" required>
|
||||
<option value="user" selected><?php echo __('users') ?></option>
|
||||
<option value="admin"><?php echo __('administrators') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('weight') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="mb-3">
|
||||
<input type="number" class="form-control" name="user_group_weight" min="1" max="900" step="1" value="<?php echo $last_weight + 10 ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
97
pub/bin/pages/system/pageAccessControl_user_group_edit.php
Normal file
97
pub/bin/pages/system/pageAccessControl_user_group_edit.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
use api\classes\API_usergroups;
|
||||
use bin\php\Classes\formBuilder;
|
||||
use bin\php\Classes\pageNavbar;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
if (!$API->checkPermissions('admin-access-control-user-groups', 'RW', true)) {
|
||||
echo 'error 401 unauthorized';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['form'] = true;
|
||||
$jsScriptLoadData['slugify'] = true;
|
||||
$jsScriptLoadData['breadCrumbs'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
$pageNavbar = new pageNavbar(true);
|
||||
$formBuilder = new formBuilder('edit_user_groups', '<i class="fas fa-plus"></i>', '/accesscontrol/#user-groups');
|
||||
|
||||
# Retrieve Information for the page
|
||||
$user_group_uuid = $_GET['user_group_edit'];
|
||||
$_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];
|
||||
|
||||
# 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' => '/accesscontrol/#user-groups'));
|
||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('edit'), 'href' => ''));
|
||||
|
||||
# Start page output
|
||||
$pageNavbar->outPutNavbar();
|
||||
$formBuilder->startForm();
|
||||
?>
|
||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/user-groups/">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="user_group_uuid" value="<?php echo $user_group['user_group_uuid'] ?>"/>
|
||||
<input type="hidden" name="user_group_slugify" value="<?php echo $user_group['user_group_slugify'] ?>"/>
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_group_name" name="user_group_name" value="<?php echo $user_group['user_group_name'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="user_group_slugify" name="user_group_slugify" value="<?php echo $user_group['user_group_slugify'] ?>" placeholder="" required disabled/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_type" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('user_group_type') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="select2-input">
|
||||
<select id="user_group_type" name="user_group_type" class="form-control" disabled>
|
||||
<option value="user" selected><?php echo __('users') ?></option>
|
||||
<option value="admin"><?php echo __('administrators') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="user_group_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('weight') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="mb-3">
|
||||
<input type="number" class="form-control" name="user_group_weight" min="1" max="900" step="1" value="<?php echo $user_group['user_group_weight'] ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $formBuilder->formFooter(); ?>
|
||||
</form>
|
||||
<?php $formBuilder->endForm(); ?>
|
||||
328
pub/bin/pages/system/pageAccessControl_view.php
Normal file
328
pub/bin/pages/system/pageAccessControl_view.php
Normal file
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
|
||||
# Page functions
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['activeTabOnRefresh'] = true;;
|
||||
$jsScriptLoadData['multiFilterSelect'] = true;
|
||||
$jsScriptLoadData['delete_confirmation'] = true;
|
||||
$jsScriptLoadData['datatables'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
|
||||
# Retrieve Information for the page
|
||||
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups ORDER BY user_group_weight ASC");
|
||||
$user_groups = array();
|
||||
while ($user_group = $user_groups_data->fetch_assoc()) {
|
||||
array_push($user_groups, $user_group);
|
||||
$last_weight = $user_group['user_group_weight'];
|
||||
}
|
||||
|
||||
# get all the admins
|
||||
$stmt = $GLOBALS['conn']->query("SELECT * FROM vc_users INNER JOIN vc_user_groups ON vc_users.user_group_uuid = vc_user_groups.user_group_uuid WHERE user_group_type = 'admin'");
|
||||
$administrators = array();
|
||||
while ($row = $stmt->fetch_assoc()) {
|
||||
array_push($administrators, $row);
|
||||
}
|
||||
|
||||
|
||||
$stmt = $GLOBALS['conn']->query("SELECT * FROM vc_permissions INNER JOIN system_modules ON vc_permissions.module_uuid = system_modules.module_uuid WHERE system_modules.module_enabled = 1");
|
||||
$permissions = array();
|
||||
while ($row = $stmt->fetch_assoc()) {
|
||||
array_push($permissions, $row);
|
||||
}
|
||||
|
||||
# Set breadcrumb data
|
||||
|
||||
# Start page output
|
||||
?>
|
||||
<div class="card-body activeTabOnRefresh" style="opacity: 0; transition: opacity 10ms;">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<div class="nav flex-column nav-pills nav-secondary nav-pills-no-bd nav-pills-icons" id="v-pills-tab-with-icon" role="tablist" aria-orientation="vertical">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RO', true)) { ?>
|
||||
<a class="nav-link active" id="administrators-tab" data-bs-toggle="pill" href="#administrators" role="tab" aria-controls="administrators" aria-selected="true">
|
||||
<i class="fa-solid fa-user-tie"></i><?php echo __('administrators'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-permissions', 'RO', true)) { ?>
|
||||
<a class="nav-link" id="permissions-tab" data-bs-toggle="pill" href="#permissions" role="tab" aria-controls="permissions">
|
||||
<i class="fa-solid fa-lock"></i><?php echo __('permission'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RO', true)) { ?>
|
||||
<a class="nav-link" id="user-groups-tab" data-bs-toggle="pill" href="#user-groups" role="tab" aria-controls="user-groups">
|
||||
<i class="fa-solid fa-user-group"></i><?php echo __('user_groups'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-11">
|
||||
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show active" id="administrators" role="tabpanel" aria-labelledby="administrators-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-5">
|
||||
<h2>
|
||||
<i class="fa-solid fa-user-tie"></i> <?php echo __('administrators') ?>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="col d-flex justify-content-end">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RW', true)) { ?>
|
||||
<a href="?admin_add=">
|
||||
<button class="btn btn-primary">
|
||||
<i class="fas fa-plus text-success"></i> <?php echo __('add_admin') ?>
|
||||
</button>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('avatar') ?></th>
|
||||
<th><?php echo __('full_name') ?></th>
|
||||
<th><?php echo __('user_email') ?></th>
|
||||
<th><?php echo __('user_state') ?></th>
|
||||
<th><?php echo __('last_login') ?></th>
|
||||
<th><?php echo __('user_group_name') ?></th>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th><?php echo __('avatar') ?></th>
|
||||
<th><?php echo __('full_name') ?></th>
|
||||
<th><?php echo __('user_email') ?></th>
|
||||
<th><?php echo __('user_state') ?></th>
|
||||
<th><?php echo __('last_login') ?></th>
|
||||
<th><?php echo __('user_group_name') ?></th>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($administrators as $administrator) {
|
||||
if ($administrator['user_email'] != 'superuser') { ?>
|
||||
<tr data-item-id="<?php echo $administrator['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("'", '', $administrator['user_profile_picture']) ?>" height="50px" alt="">
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-nowrap"><?php echo $administrator['user_full_name'] ?></td>
|
||||
<td class="text-nowrap"><?php echo $administrator['user_email'] ?></td>
|
||||
<td class="text-nowrap"><?php echo $administrator['user_status'] ?></td>
|
||||
<td class="text-nowrap"><?php showTime($administrator['user_last_login_timestamp']); ?></td>
|
||||
<td class="text-nowrap"><?php echo $administrator['user_group_name'] ?></td>
|
||||
<td class="text-nowrap">
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RW', true)) { ?>
|
||||
<a href="?admin_edit=<?php echo $administrator['user_uuid'] ?>" class="btn btn-primary btn-sm btn-rounded"><i class="fas fa-edit"></i></a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RO', true)) { ?>
|
||||
<a href="?admin_view=<?php echo $administrator['user_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="far fa-eye"></i></a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-admins', 'RW', true)) { ?>
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $administrator['user_uuid'] ?>" data-api-url="/api/v1/users/" data-item-name="user_uuid"><i class="fas fa-trash-alt"></i></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-permissions', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show active" id="permissions" role="tabpanel" aria-labelledby="permissions-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
<h2>
|
||||
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="col d-flex justify-content-end">
|
||||
<?php if ($API->isSuperuser()) { ?>
|
||||
<a href="?permission_add=">
|
||||
<button class="btn btn-primary">
|
||||
<i class="fas fa-plus text-success"></i> <?php echo __('add_permission') ?>
|
||||
</button>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</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="2,3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('name') ?></th>
|
||||
<th><?php echo __('module') ?></th>
|
||||
<th><?php echo __('description') ?></th>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th><?php echo __('name') ?></th>
|
||||
<th><?php echo __('module') ?></th>
|
||||
<th><?php echo __('description') ?></th>
|
||||
<th><?php echo __('actions') ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($permissions as $key => $permission) { ?>
|
||||
<tr data-item-id="<?php echo $permission['permission_uuid']; ?>">
|
||||
<td class="text-nowrap"><?php echo $permission['permission_name'] ?></td>
|
||||
<td class="text-nowrap"><?php echo __($permission['module_slugify']) ?></td>
|
||||
<td class=""><?php echo $permission['permission_description'] ?></td>
|
||||
<td class="text-nowrap">
|
||||
|
||||
<?php if ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) { ?>
|
||||
<a href="?permission_edit=<?php echo $permission['permission_uuid'] ?>" class="btn btn-primary btn-sm btn-rounded"><i class="fas fa-edit"></i></a>
|
||||
<?php } ?>
|
||||
|
||||
<a href="?permission_view=<?php echo $permission['permission_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="far fa-eye"></i></a>
|
||||
<?php if ($API->isSuperuser()) { ?>
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $permission['permission_uuid'] ?>" data-item-name="permission_uuid" data-api-url="/api/v1/permissions/"><i class="fas fa-trash-alt"></i></a>
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade" id="user-groups" role="tabpanel" aria-labelledby="user-groups-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
<h2>
|
||||
<i class="fa-solid fa-user-group"></i> <?php echo __('user_groups') ?>
|
||||
</h2>
|
||||
</div>
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RW', true)) { ?>
|
||||
<div class="col d-flex justify-content-end">
|
||||
<a href="?user_group_add=">
|
||||
<button class="btn btn-primary">
|
||||
<i class="fas fa-plus text-success"></i> <?php echo __('add_user_groups') ?>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php
|
||||
if (count($user_groups) == 0) {
|
||||
echo __('no_user_groups_found');
|
||||
} else { ?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('user_group_name') ?></th>
|
||||
<th><?php echo __('user_group_slugify') ?></th>
|
||||
<th><?php echo __('user_group_type') ?></th>
|
||||
<th class="text-nowrap text-end"><?php echo __('actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ($user_groups as $user_group) { ?>
|
||||
<tr>
|
||||
<td><?php echo $user_group['user_group_name']; ?></td>
|
||||
<td><?php echo $user_group['user_group_slugify']; ?></td>
|
||||
<td><?php echo __($user_group['user_group_type']); ?></td>
|
||||
<td class="text-nowrap text-end">
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RW', true)) { ?>
|
||||
<a href="?user_group_edit=<?php echo $user_group['user_group_uuid'] ?>" class="btn btn-primary btn-sm btn-rounded"><i class="fas fa-edit"></i></a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RO', true)) { ?>
|
||||
<a href="#" class="btn btn-info btn-sm btn-rounded" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $user_group['user_group_slugify'] ?>"><i class="far fa-eye"></i></a>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-access-control-user-groups', 'RW', true)) { ?>
|
||||
<a href="#" class="btn btn-danger btn-sm btn-rounded delete-btn" data-item-uuid="<?php echo $user_group['user_group_uuid'] ?>" data-api-url="/api/v1/user-groups/" data-item-name="user_group_uuid"><i class="fas fa-trash-alt"></i></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<?php foreach ($user_groups as $user_group) {
|
||||
if ($API->checkPermissions('admin-access-control-user-groups', 'RO', true)) { ?>
|
||||
<div class="modal fade" id="infoModal<?php echo $user_group['user_group_slugify'] ?>" 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">
|
||||
<br>
|
||||
<table class="table table-sm table-striped-bg-black">
|
||||
<tr>
|
||||
<td><?php echo __('uuid') ?>:</td>
|
||||
<td><?php echo $user_group['user_group_uuid'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('user_group_name') ?>:</td>
|
||||
<td><?php echo $user_group['user_group_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('user_group_slugify') ?>:</td>
|
||||
<td><?php echo $user_group['user_group_slugify'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('weight') ?>:</td>
|
||||
<td><?php echo $user_group['user_group_weight'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('create_date') ?>:</td>
|
||||
<td><?php showTime($user_group['user_group_create_timestamp']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('last_modified_date') ?>:</td>
|
||||
<td><?php showTime($user_group['user_group_modified_timestamp']); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
55
pub/bin/pages/system/pageMonitoring.php
Normal file
55
pub/bin/pages/system/pageMonitoring.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$jsScriptLoadData['activeTabOnRefresh'] = true;
|
||||
|
||||
?>
|
||||
<div class="card-body activeTabOnRefresh" style="opacity: 0; transition: opacity 10ms;">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<div class="nav flex-column nav-pills nav-secondary nav-pills-no-bd nav-pills-icons" id="v-pills-tab-with-icon" role="tablist" aria-orientation="vertical">
|
||||
|
||||
<a class="nav-link active" id="overview-tab" data-bs-toggle="pill" href="#overview" role="tab" aria-controls="overview" aria-selected="true">
|
||||
<i class="fa-solid fa-ear-listen"></i></i><?php echo __('overview'); ?>
|
||||
</a>
|
||||
<a class="nav-link" id="monitoring-tab" data-bs-toggle="pill" href="#monitoring" role="tab" aria-controls="monitoring">
|
||||
<i class="fa-solid fa-magnifying-glass"></i><?php echo __('monitoring'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-11">
|
||||
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
||||
<div class="tab-pane fade show active" id="overview" role="tabpanel" aria-labelledby="overview-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
<h2>
|
||||
<i class="fa-solid fa-ear-listen"></i></i> <?php echo __('overview') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
to be made
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="monitoring" role="tabpanel" aria-labelledby="monitoring-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
<h2>
|
||||
<i class="fa-solid fa-magnifying-glass"></i> <?php echo __('monitoring') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
to be made
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
343
pub/bin/pages/system/pageSystemConfig.php
Normal file
343
pub/bin/pages/system/pageSystemConfig.php
Normal file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API;
|
||||
|
||||
if (!defined('APP_INIT')) {
|
||||
exit;
|
||||
}
|
||||
# IDE Section
|
||||
|
||||
|
||||
# Includes Section
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||
|
||||
# Check permissions
|
||||
$API = new API();
|
||||
|
||||
# Page functions
|
||||
|
||||
|
||||
# JS Scripts to load for this page
|
||||
$jsScriptLoadData['activeTabOnRefresh'] = true;
|
||||
$jsScriptLoadData['copyInputValue'] = true;
|
||||
$jsScriptLoadData['updateToggle'] = true;
|
||||
|
||||
# PageClasses Setup
|
||||
|
||||
# Retrieve Information for the page
|
||||
$portal_settings = $GLOBALS['conn']->query("SELECT * FROM vc_portal_settings")->fetch_assoc();
|
||||
|
||||
$system_modules_data = $GLOBALS['conn']->query("SELECT * FROM system_modules");
|
||||
$system_modules = array();
|
||||
while ($module = $system_modules_data->fetch_assoc()) {
|
||||
array_push($system_modules, $module);
|
||||
}
|
||||
|
||||
|
||||
# Set breadcrumb data
|
||||
|
||||
# Start page output
|
||||
|
||||
?>
|
||||
<div class="card-body activeTabOnRefresh" style="opacity: 0; transition: opacity 10ms;">
|
||||
<div class="row">
|
||||
<div class="col-md-1 col-lg-1">
|
||||
<div class="nav flex-column nav-pills nav-secondary nav-pills-no-bd nav-pills-icons" id="v-pills-tab-with-icon" role="tablist" aria-orientation="vertical">
|
||||
<?php if ($API->checkPermissions('admin-portalsettings', 'RO', true)) { ?>
|
||||
<a class="nav-link" id="global-settings-tab" data-bs-toggle="pill" href="#global-settings" role="tab" aria-controls="global-settings" aria-selected="true">
|
||||
<i class="fas fa-globe-americas"></i><?php echo __('global_settings'); ?>
|
||||
</a>
|
||||
<?php
|
||||
} ?>
|
||||
<?php if ($API->checkPermissions('admin-mailsettings', 'RO', true)) {
|
||||
|
||||
?>
|
||||
<a class="nav-link" id="mail-settings-tab" data-bs-toggle="pill" href="#mail-settings" role="tab" aria-controls="mail-settings">
|
||||
<i class="fa-solid fa-envelope"></i><?php echo __('mail_settings'); ?>
|
||||
</a>
|
||||
<?php
|
||||
} ?>
|
||||
<?php if ($API->checkPermissions('admin-modules', 'RO', true)) {
|
||||
$first_nav_active = true; ?>
|
||||
<a class="nav-link" id="mail-settings-tab" data-bs-toggle="pill" href="#modules" role="tab" aria-controls=modules">
|
||||
<i class="fa-solid fa-cubes"></i><?php echo __('modules'); ?>
|
||||
</a>
|
||||
<?php $first_nav_active = true;
|
||||
} ?>
|
||||
<?php if ($API->checkPermissions('admin-sources', 'RO', true)) {
|
||||
$first_nav_active = true; ?>
|
||||
<a class="nav-link" id="sources-tab" data-bs-toggle="pill" href="#sources" role="tab" aria-controls=sources">
|
||||
<i class="fa-solid fa-cloud"></i><?php echo __('sources'); ?>
|
||||
</a>
|
||||
<?php $first_nav_active = true;
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-11 col-lg-11">
|
||||
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
||||
<?php if ($API->checkPermissions('admin-portalsettings', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show active" id="global-settings" role="tabpanel" aria-labelledby="global-settings-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<h2>
|
||||
<i class="fas fa-globe-americas"></i> <?php echo __('global_settings') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<form id="FormValidation" method="post" action="/api/v1/portalsettings/">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="_return" value="/systemconfig/#global-settings">
|
||||
<input type="hidden" name="portal_uuid" value="<?php echo $portal_settings['portal_uuid']; ?>">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="portal_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('portal_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="portal_name" name="portal_name" value="<?php echo $portal_settings['portal_name'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="portal_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('portal_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="portal_slugify" name="portal_slugify" value="<?php echo $portal_settings['portal_slugify'] ?>" placeholder="" required disabled/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="portal_provider_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('portal_provider_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="portal_provider_name" name="portal_provider_name" value="<?php echo $portal_settings['portal_provider_name'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="portal_provider_slugify" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('portal_provider_slugify') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="portal_provider_slugify" name="portal_provider_slugify" value="<?php echo $portal_settings['portal_provider_slugify'] ?>" placeholder="" disabled/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="admin_auth_methods" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('admin_auth_methods') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="admin_auth_methods" name="admin_auth_methods" value="<?php echo $portal_settings['admin_auth_methods'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="cacert_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2">
|
||||
<?php echo __('cacert_url') ?>
|
||||
</label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="cacert_url" name="cacert_url" value="<?php echo $portal_settings['cacert_url'] ?>" placeholder="" disabled/>
|
||||
<button class="btn btn-outline-secondary" type="button" onclick="copyToClipboard('cacert_url')">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="autop_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2">
|
||||
<?php echo __('autop_url') ?>
|
||||
</label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="autop_url" name="autop_url" value="<?php echo $portal_settings['autop_url'] ?>" placeholder="" disabled/>
|
||||
<button class="btn btn-outline-secondary" type="button" onclick="copyToClipboard('autop_url')">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-4">
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-end">
|
||||
<?php if ($API->checkPermissions('admin-portalsettings', 'RW', true)) { ?>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-mailsettings', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show active" id="mail-settings" role="tabpanel" aria-labelledby="mail-settings-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<h2>
|
||||
<i class="fa-solid fa-envelope"></i> <?php echo __('mail_settings') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<form id="FormValidation" method="post" action="/api/v1/mailsettings/">
|
||||
<input type="hidden" name="portal_uuid" value="<?php echo $portal_settings['portal_uuid']; ?>">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="_return" value="/systemconfig/#mail-settings">
|
||||
<div class="card-body">
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_from_name" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_from_name') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="mail_from_name" name="mail_from_name" value="<?php echo $portal_settings['mail_from_name'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_from_address" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_from_address') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="email" class="form-control" name="mail_from_address" value="<?php echo $portal_settings['mail_from_address'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_host" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_host') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" name="mail_smtp_host" value="<?php echo $portal_settings['mail_smtp_host'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_secure" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_secure') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<select id="mail_smtp_secure" name="mail_smtp_secure" class="form-control" required>
|
||||
<option value="tls" <?php echo ($portal_settings['mail_smtp_secure'] == 'tls') ? 'selected' : '' ?>>TLS (standard port 587)</option>
|
||||
<option value="ssl" <?php echo ($portal_settings['mail_smtp_secure'] == 'ssl') ? 'selected' : '' ?>>SSL (standard port 465)</option>
|
||||
<option value="no" <?php echo ($portal_settings['mail_smtp_secure'] == 'no') ? 'selected' : '' ?>>No Encryption (standard port 25)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_port" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_port') ?></label>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<input type="number" class="form-control" id="mail_smtp_port" name="mail_smtp_port" value="<?php echo $portal_settings['mail_smtp_port'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_auth" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_auth') ?></label>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<select id="mail_smtp_auth" name="mail_smtp_auth" class="form-control" required>
|
||||
<option value="1" <?php echo ($portal_settings['mail_smtp_auth'] == 1) ? 'selected' : '' ?>>true</option>
|
||||
<option value="0" <?php echo ($portal_settings['mail_smtp_auth'] == 0) ? 'selected' : '' ?>>false</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_user" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_user') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="text" class="form-control" id="mail_smtp_user" name="mail_smtp_user" value="<?php echo $portal_settings['mail_smtp_user'] ?>" placeholder="" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-show-validation row">
|
||||
<label for="mail_smtp_pass" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_smtp_pass') ?></label>
|
||||
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||
<input type="password" class="form-control" id="mail_smtp_pass" name="mail_smtp_pass" value="*******************" placeholder="" autocomplete="new-password" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card-footer py-4">
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-end">
|
||||
<?php if ($API->checkPermissions('admin-mailsettings', 'RW', true)) { ?>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($API->checkPermissions('admin-modules', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show" id="modules" role="tabpanel" aria-labelledby="modules-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<h2>
|
||||
<i class="fa-solid fa-cubes"></i> <?php echo __('modules') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-3">
|
||||
<form id="FormValidation" method="post" action="/api/v1/modules/">
|
||||
<input type="hidden" name="portal_uuid" value="<?php echo $portal_settings['portal_uuid']; ?>">
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
<input type="hidden" name="_return" value="/systemconfig/#modules">
|
||||
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('module_name') ?></th>
|
||||
<th><?php echo __('enabled') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th><?php echo __('module_name') ?></th>
|
||||
<th><?php echo __('enabled') ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($system_modules as $module) { ?>
|
||||
<tr>
|
||||
<td><?php echo $module['module_name'] ?> </td>
|
||||
<td>
|
||||
<label class="switch">
|
||||
|
||||
<input type="checkbox" class="checkbox" data-api-url="/api/v1/system/modules/" data-api-data='<?php echo json_encode(['module_uuid' => $module['module_uuid'], 'module_enabled' => $module['module_enabled'] ? 0 : 1]) ?>' data-api-changevalue="module_enabled"
|
||||
<?php echo(($module['module_enabled']) ? 'checked' : '') ?>
|
||||
<?php echo ($API->checkPermissions('admin-modules', 'RW', true)) ? '' : 'disabled' ?>
|
||||
<?php echo(($module['module_slugify'] == 'system') ? 'disabled' : '') ?>>
|
||||
<div class="slider"></div>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($API->checkPermissions('admin-sources', 'RO', true)) { ?>
|
||||
<div class="tab-pane fade show" id="sources" role="tabpanel" aria-labelledby="sources-tab">
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<h2>
|
||||
<i class="fa-solid fa-cloud"></i> <?php echo __('sources') ?>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-3">
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="col">
|
||||
<div class="card card-post card-round">
|
||||
<img class="card-img-top" src="/src/images/sources/inserve/inserve_logo.webp" alt="Inserve Logo">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">
|
||||
Inserve </h3>
|
||||
<p class="card-text">
|
||||
Inserve is Dutch software that helps MSPs support their customers in a personal and structured way. </p>
|
||||
<a href="/system/sources/inserve" class="btn btn-primary">View</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
97
pub/bin/pages/system/sources/pageSourceInserve.php
Normal file
97
pub/bin/pages/system/sources/pageSourceInserve.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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="card-body activeTabOnRefresh" style="opacity: 0; transition: opacity 10ms;">
|
||||
<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>
|
||||
Reference in New Issue
Block a user