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>
|
||||
Reference in New Issue
Block a user