mirror of
https://github.com/itflow-org/itflow
synced 2026-11-23 21:07:22 +00:00
Add Network Platforms with UniFi device sync from a self-hosted controller, a UniFi console API key or Site Manager, matching assets by MAC address, with database 4.1.5
This commit is contained in:
39
admin/database_updates/4.1.5.php
Normal file
39
admin/database_updates/4.1.5.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.1.5 (from 4.1.4)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Network platforms - UniFi first (Admin > Network Platforms, functions/rmm_unifi.php). They
|
||||
* use the RMM providers' tables: a platform is an rmm_providers row of a network kind, its
|
||||
* sites are rmm_clients rows, and its switches, access points and gateways rmm_devices rows.
|
||||
*
|
||||
* rmm_providers.rmm_provider_insecure 1 to accept the certificate a self-hosted controller
|
||||
* made for itself - 0, checked as usual, for the rest
|
||||
* rmm_devices.rmm_device_mac the device's MAC address, 12 lower-case hex digits -
|
||||
* '' when its kind doesn't say
|
||||
*
|
||||
* Re-runnable: it only adds what isn't there.
|
||||
*/
|
||||
|
||||
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
||||
|
||||
$itflow_has = function ($table, $what, $name) use ($mysqli) {
|
||||
$from = $what === 'column' ? 'COLUMNS' : 'STATISTICS';
|
||||
$field = $what === 'column' ? 'COLUMN_NAME' : 'INDEX_NAME';
|
||||
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.$from
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND $field = '$name' LIMIT 1");
|
||||
return $result && mysqli_num_rows($result) > 0;
|
||||
};
|
||||
|
||||
if (!$itflow_has('rmm_providers', 'column', 'rmm_provider_insecure')) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `rmm_providers` ADD `rmm_provider_insecure` tinyint(1) NOT NULL DEFAULT 0 AFTER `rmm_provider_api_secret`");
|
||||
}
|
||||
if (!$itflow_has('rmm_devices', 'column', 'rmm_device_mac')) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `rmm_devices` ADD `rmm_device_mac` varchar(12) NOT NULL DEFAULT '' AFTER `rmm_device_remote_id`");
|
||||
}
|
||||
if (!$itflow_has('rmm_devices', 'key', 'rmm_device_mac')) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `rmm_devices` ADD KEY `rmm_device_mac` (`rmm_device_mac`)");
|
||||
}
|
||||
|
||||
unset($itflow_has);
|
||||
@@ -139,13 +139,23 @@
|
||||
</li>
|
||||
<?php // Its setup, and the texts sent and received once it's set up (adminNavGroups()) ?>
|
||||
<?= adminNavGroupItemHtml('text') ?>
|
||||
<?php // A provider's clients page is its family's - a network platform's sites are under Network Platforms
|
||||
$nav_rmm_page = basename($_SERVER['PHP_SELF']);
|
||||
$nav_rmm_family = $nav_rmm_page === 'rmm_clients.php' && function_exists('rmmFamily') ? rmmFamily(rmmProviderRow($_GET['provider_id'] ?? 0) ?? '') : ''; ?>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/rmm_providers.php"
|
||||
class="nav-link <?= (in_array(basename($_SERVER['PHP_SELF']), ['rmm_providers.php', 'rmm_clients.php']) ? 'active' : '') ?>">
|
||||
class="nav-link <?= ($nav_rmm_page === 'rmm_providers.php' || ($nav_rmm_page === 'rmm_clients.php' && $nav_rmm_family !== 'network') ? 'active' : '') ?>">
|
||||
<i class="nav-icon fas fa-laptop-medical"></i>
|
||||
<p>RMM Providers</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/network_platforms.php"
|
||||
class="nav-link <?= ($nav_rmm_page === 'network_platforms.php' || ($nav_rmm_page === 'rmm_clients.php' && $nav_rmm_family === 'network') ? 'active' : '') ?>">
|
||||
<i class="nav-icon fas fa-network-wired"></i>
|
||||
<p>Network Platforms</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/admin/phone_systems.php"
|
||||
class="nav-link <?= (in_array(basename($_SERVER['PHP_SELF']), ['phone_systems.php', 'phone_domains.php']) ? 'active' : '') ?>">
|
||||
|
||||
@@ -41,7 +41,7 @@ ob_start();
|
||||
<input type="hidden" name="rmm_client_id" value="<?= $rmm_client_id ?>">
|
||||
|
||||
<div class="modal-body">
|
||||
<p class="small text-body-secondary">Its <?= number_format($devices) ?> device<?= $devices === 1 ? '' : 's' ?> in <?= escapeHtml($name) ?> come in as this client's assets - matched to the ones it has by serial number or name, made where there are none.
|
||||
<p class="small text-body-secondary">Its <?= number_format($devices) ?> device<?= $devices === 1 ? '' : 's' ?> in <?= escapeHtml($name) ?> come in as this client's assets - matched to the ones it has by <?= rmmFamily($row) === 'network' ? 'MAC address' : 'serial number' ?> or name, made where there are none.
|
||||
<?php if ($current) { ?>Linked to another client, they come in there - the assets already brought in for <?= escapeHtml((string) $row['client_name']) ?> stay, no longer kept up.<?php } ?></p>
|
||||
|
||||
<label class="form-label">ITFlow client <strong class="text-danger">*</strong></label>
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
* level picked, in a category. Desktops, laptops, servers and virtual machines each come in as
|
||||
* the asset type picked for them (rmmProviderAssetTypes()). Save asks first (check_rmm_provider, admin/post/rmm.php): what
|
||||
* is wrong shows beside each field and the window stays open; once all is right it saves, and
|
||||
* tries the connection.
|
||||
* tries the connection. A network platform's window (family=network, or one being edited)
|
||||
* offers the network kinds - UniFi - in its words.
|
||||
*/
|
||||
|
||||
require_once '../../includes/modal_header.php';
|
||||
@@ -16,7 +17,7 @@ require_once '../../includes/modal_header.php';
|
||||
$provider_id = intval($_GET['id'] ?? 0);
|
||||
$row = $provider_id ? rmmProviderRow($provider_id) : null;
|
||||
if ($provider_id && !$row) {
|
||||
echo json_encode(['error' => 'That RMM provider no longer exists.']);
|
||||
echo json_encode(['error' => 'That provider or platform no longer exists.']);
|
||||
exit;
|
||||
}
|
||||
if ($row && !rmmKind($row)) {
|
||||
@@ -24,13 +25,15 @@ if ($row && !rmmKind($row)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$kinds = rmmProviderKinds();
|
||||
$family = $row ? rmmFamily($row) : (($_GET['family'] ?? '') === 'network' && rmmNetworkReady() ? 'network' : 'rmm');
|
||||
$words = rmmFamilyWords($family);
|
||||
$kinds = rmmProviderKinds($family);
|
||||
$kind_key = $row ? (string) $row['rmm_provider_kind'] : (string) array_key_first($kinds);
|
||||
$kind = $kinds[$kind_key];
|
||||
|
||||
// What the window's script needs of each kind - its name, to follow the kind picked, and whether it has alerts
|
||||
$kinds_js = array_map(function ($info) {
|
||||
return ['name' => $info['name'], 'alerts' => isset($info['alerts'], $info['alert']), 'alertsHelp' => (string) ($info['alerts_help'] ?? '')];
|
||||
return ['name' => $info['default_name'] ?? $info['name'], 'alerts' => isset($info['alerts'], $info['alert']), 'alertsHelp' => (string) ($info['alerts_help'] ?? '')];
|
||||
}, $kinds);
|
||||
|
||||
// Alerts open tickets - once the 3.6.8 database update is in, with ticketing on
|
||||
@@ -47,12 +50,13 @@ ob_start();
|
||||
|
||||
?>
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class="<?= escapeHtml($kind['icon']) ?> fa-fw me-2" data-rmm-kind-icon></i><?= $row ? '<strong>' . escapeHtml(rmmProviderName($row)) . '</strong>' : 'New RMM Provider' ?></h5>
|
||||
<h5 class="modal-title"><i class="<?= escapeHtml($kind['icon']) ?> fa-fw me-2" data-rmm-kind-icon></i><?= $row ? '<strong>' . escapeHtml(rmmProviderName($row)) . '</strong>' : 'New ' . ucwords($words['full']) ?></h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off" novalidate data-rmm-provider-form data-kinds="<?= escapeHtml(json_encode($kinds_js)) ?>">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="provider_id" value="<?= $provider_id ?>">
|
||||
<input type="hidden" name="family" value="<?= $family ?>">
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
@@ -60,14 +64,14 @@ ob_start();
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="active" value="1" id="rmmProviderActive" <?= intval($row['rmm_provider_active']) ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="rmmProviderActive">On - the linked clients' devices come in</label>
|
||||
<label class="form-check-label" for="rmmProviderActive">On - the linked <?= $words['clients'] ?>' devices come in</label>
|
||||
</div>
|
||||
<div class="form-text ps-5">Off, nothing is brought in, and assets keep what it last said about them.</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="rmmProviderKind">RMM <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
|
||||
<label class="form-label" for="rmmProviderKind"><?= $words['kind'] ?> <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-shapes"></i></span>
|
||||
<select class="form-select select2" name="kind" id="rmmProviderKind" data-rmm-kind <?= $row ? 'disabled' : '' ?>>
|
||||
@@ -77,17 +81,17 @@ ob_start();
|
||||
</select>
|
||||
</div>
|
||||
<?= $error_for('kind') ?>
|
||||
<?php if ($row) { ?><div class="form-text">Which RMM it is stays - add another provider for another one.</div><?php } ?>
|
||||
<?php if ($row) { ?><div class="form-text"><?= $family === 'network' ? 'Which kind it is stays - add another platform for another one.' : 'Which RMM it is stays - add another provider for another one.' ?></div><?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="rmmProviderName">Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
|
||||
<input type="text" class="form-control" name="name" id="rmmProviderName" maxlength="100" value="<?= escapeHtml($row ? $row['rmm_provider_name'] : $kind['name']) ?>" placeholder="What you call it">
|
||||
<input type="text" class="form-control" name="name" id="rmmProviderName" maxlength="100" value="<?= escapeHtml($row ? $row['rmm_provider_name'] : ($kind['default_name'] ?? $kind['name'])) ?>" placeholder="What you call it">
|
||||
</div>
|
||||
<?= $error_for('name') ?>
|
||||
<div class="form-text">What assets and the audit log call it. Two of the same RMM need names of their own.</div>
|
||||
<div class="form-text">What assets and the audit log call it. Two of the same kind need names of their own.</div>
|
||||
</div>
|
||||
|
||||
<?php foreach ($kinds as $key => $info) {
|
||||
@@ -95,8 +99,19 @@ ob_start();
|
||||
<div data-rmm-kind-fields="<?= escapeHtml($key) ?>" class="<?= $shown ? '' : 'd-none' ?>">
|
||||
<?php foreach ($info['fields'] as $field => $about) {
|
||||
$id = 'rmmProvider' . ucfirst($key) . str_replace('_', '', ucwords($field, '_'));
|
||||
$saved = $row && $shown ? (string) $row["rmm_provider_$field"] : '';
|
||||
$saved = $row && $shown ? (string) ($row["rmm_provider_$field"] ?? '') : '';
|
||||
$secret = $about['type'] === 'secret';
|
||||
if ($about['type'] === 'switch') { ?>
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="<?= $field ?>" value="1" id="<?= $id ?>" <?= intval($saved) ? 'checked' : '' ?> <?= $shown ? '' : 'disabled' ?>>
|
||||
<label class="form-check-label" for="<?= $id ?>"><?= escapeHtml($about['label']) ?></label>
|
||||
</div>
|
||||
<?= $error_for($field) ?>
|
||||
<div class="form-text ps-5"><?= escapeHtml($about['help']) ?></div>
|
||||
</div>
|
||||
<?php continue;
|
||||
}
|
||||
$placeholder = $secret ? ($saved !== '' ? 'Saved - type a new one to replace it' : '') : $about['placeholder'];
|
||||
if ($field === 'web_url' && $row && $shown && isset($info['dashboard'])) {
|
||||
// The address it works out when this is left empty
|
||||
@@ -108,6 +123,8 @@ ob_start();
|
||||
<span class="input-group-text"><i class="fas fa-fw <?= escapeHtml($about['icon']) ?>"></i></span>
|
||||
<?php if ($secret) { ?>
|
||||
<input type="password" class="form-control font-monospace" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" autocomplete="new-password" placeholder="<?= escapeHtml($placeholder) ?>" <?= $shown ? '' : 'disabled' ?>>
|
||||
<?php } elseif ($about['type'] === 'text') { ?>
|
||||
<input type="text" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="255" spellcheck="false" autocomplete="off" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
|
||||
<?php } else { ?>
|
||||
<input type="url" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
|
||||
<?php } ?>
|
||||
@@ -152,11 +169,11 @@ ob_start();
|
||||
<?php } ?>
|
||||
|
||||
<?php if (rmmAssetTypesReady()) {
|
||||
$device_types = rmmProviderAssetTypes($row); ?>
|
||||
$device_types = rmmProviderAssetTypes($row, $kind); ?>
|
||||
<div class="mb-3" data-rmm-asset-types>
|
||||
<label class="form-label">Asset types</label>
|
||||
<div class="row g-2">
|
||||
<?php foreach (rmmDeviceKinds() as $guessed => $kind_label) {
|
||||
<?php foreach (rmmDeviceKinds($kind) as $guessed => $kind_label) {
|
||||
$type_id = 'rmmProviderType' . str_replace(' ', '', $guessed); ?>
|
||||
<div class="col-sm-6">
|
||||
<label class="form-label small text-body-secondary mb-1" for="<?= $type_id ?>"><?= escapeHtml($kind_label) ?></label>
|
||||
@@ -172,7 +189,7 @@ ob_start();
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?= $error_for('asset_types') ?>
|
||||
<div class="form-text">What its devices come in as. A device the sync typed follows a change here at the next sync; one whose type you changed on the asset keeps yours. Recurring invoice lines that count managed devices by type count these.</div>
|
||||
<div class="form-text">What its devices come in as. A device the sync typed follows a change here at the next sync; one whose type you changed on the asset keeps yours.<?= $family === 'rmm' ? ' Recurring invoice lines that count managed devices by type count these.' : '' ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
15
admin/network_platforms.php
Normal file
15
admin/network_platforms.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Admin > Network Platforms - UniFi first (functions/rmm_unifi.php). Each platform brings in
|
||||
* the gateways, switches and access points of the sites linked to your clients, as assets.
|
||||
* It is the RMM Providers page (rmm_providers.php) for the network family's kinds, in its
|
||||
* own words - platforms and their sites.
|
||||
*/
|
||||
|
||||
// Default Column Sortby Filter
|
||||
$sort = "rmm_provider_name";
|
||||
$order = "ASC";
|
||||
|
||||
$rmm_family = 'network';
|
||||
require __DIR__ . '/rmm_providers.php';
|
||||
@@ -6,7 +6,8 @@
|
||||
* provider off and on, Delete, and on a provider's Clients page linking its clients to
|
||||
* ITFlow's - one at a time, the suggested ones, unlinking, and bringing back devices whose
|
||||
* assets were deleted (functions/rmm.php). What changed is in the audit log - keys and
|
||||
* secrets only as changed.
|
||||
* secrets only as changed. Network platforms (Admin > Network Platforms) are the same, in
|
||||
* their family's words (rmmFamilyWords()).
|
||||
*/
|
||||
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
@@ -18,6 +19,7 @@ if (isset($_POST['check_rmm_provider']) || isset($_POST['add_rmm_provider']) ||
|
||||
$checking = isset($_POST['check_rmm_provider']);
|
||||
$provider_id = intval($_POST['provider_id'] ?? 0);
|
||||
$before = $provider_id ? rmmProviderRow($provider_id) : null;
|
||||
$words = rmmFamilyWords($before ? rmmFamily($before) : (rmmKind((string) ($_POST['kind'] ?? '')) ? rmmFamily((string) $_POST['kind']) : (($_POST['family'] ?? '') === 'network' ? 'network' : 'rmm')));
|
||||
|
||||
$refuse = function ($text) use ($checking) {
|
||||
if ($checking) {
|
||||
@@ -26,10 +28,10 @@ if (isset($_POST['check_rmm_provider']) || isset($_POST['add_rmm_provider']) ||
|
||||
exit;
|
||||
}
|
||||
flashAlert(escapeHtml($text), 'error');
|
||||
redirect('rmm_providers.php');
|
||||
redirect($words['page']);
|
||||
};
|
||||
if ($provider_id && !$before) {
|
||||
$refuse('That RMM provider no longer exists - close this and look again.');
|
||||
$refuse('That ' . $words['full'] . ' no longer exists - close this and look again.');
|
||||
}
|
||||
if ($before && !rmmKind($before)) {
|
||||
$refuse('This ITFlow doesn\'t know that provider\'s kind of RMM.');
|
||||
@@ -58,10 +60,10 @@ if (isset($_POST['check_rmm_provider']) || isset($_POST['add_rmm_provider']) ||
|
||||
redirect();
|
||||
}
|
||||
rmmProviderWrite($after, $provider_id);
|
||||
logAudit("RMM Provider", "Edit", "$session_name changed RMM provider " . escapeSql(rmmProviderName($before) . ': ' . implode('; ', $lines)), 0, $provider_id);
|
||||
logAudit($words['audit'], "Edit", "$session_name changed {$words['full']} " . escapeSql(rmmProviderName($before) . ': ' . implode('; ', $lines)), 0, $provider_id);
|
||||
} else {
|
||||
$provider_id = rmmProviderWrite($after);
|
||||
logAudit("RMM Provider", "Create", "$session_name added RMM provider " . escapeSql($name . ($name !== $kind['name'] ? " ({$kind['name']})" : '') . ($after['rmm_provider_api_url'] !== '' ? ' at ' . $after['rmm_provider_api_url'] : '')), 0, $provider_id);
|
||||
logAudit($words['audit'], "Create", "$session_name added {$words['full']} " . escapeSql($name . ($name !== $kind['name'] ? " ({$kind['name']})" : '') . ($after['rmm_provider_api_url'] !== '' ? ' at ' . $after['rmm_provider_api_url'] : '')), 0, $provider_id);
|
||||
}
|
||||
|
||||
// Try it - and, connected, bring in its clients so they can be linked
|
||||
@@ -77,7 +79,7 @@ if (isset($_POST['check_rmm_provider']) || isset($_POST['add_rmm_provider']) ||
|
||||
redirect($back);
|
||||
}
|
||||
rmmSync($provider, 0, 60);
|
||||
flashAlert('<strong>' . escapeHtml($name) . '</strong> saved. ' . escapeHtml($test['text']) . ($before ? '' : ' Now link its clients to yours.'));
|
||||
flashAlert('<strong>' . escapeHtml($name) . '</strong> saved. ' . escapeHtml($test['text']) . ($before ? '' : ' Now link its ' . $words['clients'] . ' to your clients.'));
|
||||
redirect($back);
|
||||
|
||||
}
|
||||
@@ -89,7 +91,7 @@ if (isset($_GET['test_rmm_provider'])) {
|
||||
|
||||
$provider = rmmProviderRow($_GET['test_rmm_provider']);
|
||||
if (!$provider) {
|
||||
flashAlert('That RMM provider no longer exists.', 'error');
|
||||
flashAlert('That provider or platform no longer exists.', 'error');
|
||||
redirect('rmm_providers.php');
|
||||
}
|
||||
$test = rmmTest($provider);
|
||||
@@ -105,7 +107,7 @@ if (isset($_GET['sync_rmm'])) {
|
||||
|
||||
$provider = rmmProviderRow($_GET['sync_rmm']);
|
||||
if (!rmmProviderUsable($provider)) {
|
||||
flashAlert('That RMM provider isn\'t set up, or is turned off.', 'error');
|
||||
flashAlert('That provider or platform isn\'t set up, or is turned off.', 'error');
|
||||
redirect();
|
||||
}
|
||||
set_time_limit(180);
|
||||
@@ -123,15 +125,16 @@ if (isset($_GET['turn_rmm_provider_off']) || isset($_GET['turn_rmm_provider_on']
|
||||
$on = isset($_GET['turn_rmm_provider_on']);
|
||||
$provider = rmmProviderRow($on ? $_GET['turn_rmm_provider_on'] : $_GET['turn_rmm_provider_off']);
|
||||
if (!$provider) {
|
||||
flashAlert('That RMM provider no longer exists.', 'error');
|
||||
flashAlert('That provider or platform no longer exists.', 'error');
|
||||
redirect('rmm_providers.php');
|
||||
}
|
||||
$provider_id = intval($provider['rmm_provider_id']);
|
||||
$name = rmmProviderName($provider);
|
||||
$words = rmmFamilyWords(rmmFamily($provider));
|
||||
// Back on, the alerts open then are taken as known - not a ticket each for all that came up while it was off
|
||||
mysqli_query($mysqli, "UPDATE rmm_providers SET rmm_provider_active = " . ($on ? 1 : 0) . ($on && intval($provider['rmm_provider_active']) === 0 && rmmAlertsReady() ? ', rmm_provider_alerts_since = NULL' : '') . " WHERE rmm_provider_id = $provider_id");
|
||||
logAudit("RMM Provider", "Edit", "$session_name turned RMM provider " . escapeSql($name) . ($on ? ' on' : ' off'), 0, $provider_id);
|
||||
flashAlert('<strong>' . escapeHtml($name) . '</strong> is ' . ($on ? 'on - the linked clients\' devices come in again with the next sync' : 'off - nothing is brought in'));
|
||||
logAudit($words['audit'], "Edit", "$session_name turned {$words['full']} " . escapeSql($name) . ($on ? ' on' : ' off'), 0, $provider_id);
|
||||
flashAlert('<strong>' . escapeHtml($name) . '</strong> is ' . ($on ? 'on - the linked ' . $words['clients'] . '\' devices come in again with the next sync' : 'off - nothing is brought in'));
|
||||
redirect();
|
||||
|
||||
}
|
||||
@@ -143,11 +146,12 @@ if (isset($_GET['delete_rmm_provider'])) {
|
||||
|
||||
$provider = rmmProviderRow($_GET['delete_rmm_provider']);
|
||||
if (!$provider) {
|
||||
flashAlert('That RMM provider no longer exists.', 'error');
|
||||
flashAlert('That provider or platform no longer exists.', 'error');
|
||||
redirect('rmm_providers.php');
|
||||
}
|
||||
$provider_id = intval($provider['rmm_provider_id']);
|
||||
$name = rmmProviderName($provider);
|
||||
$words = rmmFamilyWords(rmmFamily($provider));
|
||||
$devices = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM rmm_devices WHERE rmm_device_provider_id = $provider_id AND rmm_device_asset_id > 0"))[0]);
|
||||
mysqli_query($mysqli, "DELETE FROM rmm_devices WHERE rmm_device_provider_id = $provider_id");
|
||||
if (rmmAlertsReady()) {
|
||||
@@ -155,9 +159,9 @@ if (isset($_GET['delete_rmm_provider'])) {
|
||||
}
|
||||
mysqli_query($mysqli, "DELETE FROM rmm_clients WHERE rmm_client_provider_id = $provider_id");
|
||||
mysqli_query($mysqli, "DELETE FROM rmm_providers WHERE rmm_provider_id = $provider_id");
|
||||
logAudit("RMM Provider", "Delete", "$session_name deleted RMM provider " . escapeSql($name) . " - the $devices assets it brought in stay, no longer kept up", 0, $provider_id);
|
||||
logAudit($words['audit'], "Delete", "$session_name deleted {$words['full']} " . escapeSql($name) . " - the $devices assets it brought in stay, no longer kept up", 0, $provider_id);
|
||||
flashAlert('<strong>' . escapeHtml($name) . '</strong> deleted - the ' . number_format($devices) . ' asset' . ($devices === 1 ? '' : 's') . ' it brought in stay, as they are', 'error');
|
||||
redirect('rmm_providers.php');
|
||||
redirect($words['page']);
|
||||
|
||||
}
|
||||
|
||||
@@ -176,7 +180,8 @@ $rmm_link_client = function (array $rmm_client, int $client_id) use ($mysqli, &$
|
||||
}
|
||||
mysqli_query($mysqli, "UPDATE rmm_clients SET rmm_client_client_id = $client_id, rmm_client_synced_at = NULL WHERE rmm_client_id = $rmm_client_id");
|
||||
$client_name = (string) getFieldById('clients', $client_id, 'client_name');
|
||||
logAudit("RMM Provider", "Link", "$session_name linked " . escapeSql("$name client {$rmm_client['rmm_client_name']} to $client_name"), $client_id, intval($rmm_client['rmm_client_provider_id']));
|
||||
$words = rmmFamilyWords(rmmFamily($rmm_client));
|
||||
logAudit($words['audit'], "Link", "$session_name linked " . escapeSql("$name {$words['client']} {$rmm_client['rmm_client_name']} to $client_name"), $client_id, intval($rmm_client['rmm_client_provider_id']));
|
||||
return ['client_name' => $client_name, 'left' => $left, 'before_name' => $before ? (string) getFieldById('clients', $before, 'client_name') : ''];
|
||||
};
|
||||
|
||||
@@ -188,7 +193,7 @@ if (isset($_POST['link_rmm_client'])) {
|
||||
$client_id = intval($_POST['client_id'] ?? 0);
|
||||
$client = $client_id ? mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT client_id, client_archived_at FROM clients WHERE client_id = $client_id")) : null;
|
||||
if (!$rmm_client || $rmm_client['rmm_client_removed_at'] !== null) {
|
||||
flashAlert('Its RMM no longer has that client - sync again.', 'error');
|
||||
flashAlert('It is no longer listed there - sync again.', 'error');
|
||||
redirect();
|
||||
}
|
||||
$back = 'rmm_clients.php?provider_id=' . intval($rmm_client['rmm_client_provider_id']);
|
||||
@@ -217,10 +222,11 @@ if (isset($_GET['link_rmm_suggested'])) {
|
||||
|
||||
$provider = rmmProviderRow($_GET['provider_id'] ?? 0);
|
||||
if (!$provider) {
|
||||
flashAlert('That RMM provider no longer exists.', 'error');
|
||||
flashAlert('That provider or platform no longer exists.', 'error');
|
||||
redirect('rmm_providers.php');
|
||||
}
|
||||
$provider_id = intval($provider['rmm_provider_id']);
|
||||
$words = rmmFamilyWords(rmmFamily($provider));
|
||||
$back = "rmm_clients.php?provider_id=$provider_id";
|
||||
$suggestions = rmmClientSuggestions($provider_id);
|
||||
if ($_GET['link_rmm_suggested'] !== 'all') {
|
||||
@@ -236,7 +242,7 @@ if (isset($_GET['link_rmm_suggested'])) {
|
||||
}
|
||||
set_time_limit(180);
|
||||
$sync = rmmSync($provider, count($suggestions) === 1 ? intval(array_key_first($suggestions)) : 0, 150);
|
||||
flashAlert(count($suggestions) . ' client' . (count($suggestions) === 1 ? '' : 's') . ' linked - ' . escapeHtml($sync['note']), $sync['ok'] ? 'success' : 'warning');
|
||||
flashAlert(count($suggestions) . ' ' . $words['client'] . (count($suggestions) === 1 ? '' : 's') . ' linked - ' . escapeHtml($sync['note']), $sync['ok'] ? 'success' : 'warning');
|
||||
redirect($back);
|
||||
|
||||
}
|
||||
@@ -252,9 +258,10 @@ if (isset($_GET['unlink_rmm_client'])) {
|
||||
redirect();
|
||||
}
|
||||
$rmm_client_id = intval($rmm_client['rmm_client_id']);
|
||||
rmmForgetClientDevices($rmm_client_id, rmmProviderName($rmm_client), 'its client there was unlinked');
|
||||
$words = rmmFamilyWords(rmmFamily($rmm_client));
|
||||
rmmForgetClientDevices($rmm_client_id, rmmProviderName($rmm_client), "its {$words['client']} there was unlinked");
|
||||
mysqli_query($mysqli, "UPDATE rmm_clients SET rmm_client_client_id = 0, rmm_client_synced_at = NULL WHERE rmm_client_id = $rmm_client_id");
|
||||
logAudit("RMM Provider", "Unlink", "$session_name unlinked " . escapeSql(rmmProviderName($rmm_client) . " client {$rmm_client['rmm_client_name']} from " . $rmm_client['client_name']), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id']));
|
||||
logAudit($words['audit'], "Unlink", "$session_name unlinked " . escapeSql(rmmProviderName($rmm_client) . " {$words['client']} {$rmm_client['rmm_client_name']} from " . $rmm_client['client_name']), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id']));
|
||||
flashAlert('<strong>' . escapeHtml($rmm_client['rmm_client_name']) . '</strong> unlinked - its devices no longer come in. Their assets stay.', 'error');
|
||||
redirect('rmm_clients.php?provider_id=' . intval($rmm_client['rmm_client_provider_id']));
|
||||
|
||||
@@ -275,7 +282,8 @@ if (isset($_GET['rmm_bring_back'])) {
|
||||
$brought = mysqli_affected_rows($mysqli);
|
||||
set_time_limit(180);
|
||||
$sync = rmmSync(rmmProviderRow($rmm_client['rmm_client_provider_id']), $rmm_client_id, 150);
|
||||
logAudit("RMM Provider", "Edit", "$session_name brought back $brought deleted devices of " . escapeSql(rmmProviderName($rmm_client) . " client {$rmm_client['rmm_client_name']}"), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id']));
|
||||
$words = rmmFamilyWords(rmmFamily($rmm_client));
|
||||
logAudit($words['audit'], "Edit", "$session_name brought back $brought deleted devices of " . escapeSql(rmmProviderName($rmm_client) . " {$words['client']} {$rmm_client['rmm_client_name']}"), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id']));
|
||||
flashAlert('<strong>' . escapeHtml($rmm_client['rmm_client_name']) . '</strong> - ' . escapeHtml($sync['note']), $sync['ok'] ? 'success' : 'warning');
|
||||
redirect('rmm_clients.php?provider_id=' . intval($rmm_client['rmm_client_provider_id']));
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* is linked to the ITFlow client its devices go to, or not linked yet - with the client of the
|
||||
* same name suggested. Linking brings that client's devices in straight away; after that,
|
||||
* every 15 minutes (cron/rmm_sync.php) or with Sync now. The handlers are admin/post/rmm.php.
|
||||
* A network platform's are its sites, in its family's words (rmmFamilyWords()).
|
||||
*/
|
||||
|
||||
// Default Column Sortby Filter
|
||||
@@ -15,9 +16,10 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$provider = rmmProviderRow($_GET['provider_id'] ?? 0);
|
||||
$kind = $provider ? rmmKind($provider) : null;
|
||||
$words = rmmFamilyWords($provider ? rmmFamily($provider) : 'rmm');
|
||||
|
||||
if (!$provider || !$kind) { ?>
|
||||
<div class="alert alert-secondary"><i class="fas fa-fw fa-question-circle me-2"></i><?= $provider ? 'This ITFlow doesn\'t know that provider\'s kind of RMM.' : 'That RMM provider is gone - it may have been deleted.' ?> <a href="rmm_providers.php" class="alert-link">RMM Providers</a></div>
|
||||
<div class="alert alert-secondary"><i class="fas fa-fw fa-question-circle me-2"></i><?= $provider ? 'This ITFlow doesn\'t know that provider\'s kind of RMM.' : 'That ' . $words['full'] . ' is gone - it may have been deleted.' ?> <a href="<?= $words['page'] ?>" class="alert-link"><?= $words['title'] ?></a></div>
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
exit;
|
||||
@@ -25,6 +27,7 @@ if (!$provider || !$kind) { ?>
|
||||
|
||||
$provider_id = intval($provider['rmm_provider_id']);
|
||||
$name = rmmProviderName($provider);
|
||||
$page_title = "$name {$words['Clients']}";
|
||||
$short = $kind['short'];
|
||||
$on = intval($provider['rmm_provider_active']) === 1;
|
||||
$usable = rmmProviderUsable($provider);
|
||||
@@ -34,7 +37,7 @@ $suggestions = rmmClientSuggestions($provider_id);
|
||||
|
||||
// The views - every client it has, the ones not linked yet, the linked ones, and the ones it no longer has
|
||||
$shows = [
|
||||
'' => ['label' => 'All', 'icon' => 'fa-list', 'sql' => 'rmm_client_removed_at IS NULL', 'title' => "Every client $name has"],
|
||||
'' => ['label' => 'All', 'icon' => 'fa-list', 'sql' => 'rmm_client_removed_at IS NULL', 'title' => "Every {$words['client']} $name has"],
|
||||
'unlinked' => ['label' => 'Not linked', 'icon' => 'fa-unlink', 'sql' => 'rmm_client_removed_at IS NULL AND rmm_client_client_id = 0', 'title' => 'Their devices don\'t come in until they are linked'],
|
||||
'linked' => ['label' => 'Linked', 'icon' => 'fa-link', 'sql' => 'rmm_client_removed_at IS NULL AND rmm_client_client_id > 0', 'title' => 'Their devices come in as assets'],
|
||||
'removed' => ['label' => "Gone from $short", 'icon' => 'fa-ghost', 'sql' => 'rmm_client_removed_at IS NOT NULL', 'title' => "$name no longer has them"],
|
||||
@@ -94,16 +97,16 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark py-2">
|
||||
<h3 class="card-title mt-2"><i class="<?= escapeHtml($kind['icon']) ?> fa-fw me-2"></i><?= escapeHtml($name) ?> <span class="fw-normal opacity-75">· Clients</span>
|
||||
<h3 class="card-title mt-2"><i class="<?= escapeHtml($kind['icon']) ?> fa-fw me-2"></i><?= escapeHtml($name) ?> <span class="fw-normal opacity-75">· <?= $words['Clients'] ?></span>
|
||||
<?php if (!$on) { ?><span class="badge rounded-pill text-bg-secondary ms-2 fw-normal" data-rmm-provider-state="off" title="Nothing is brought in, and assets keep what it last said">Off</span><?php } ?>
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
<a class="btn btn-outline-light me-1" href="rmm_providers.php" title="Back to RMM Providers"><i class="fas fa-fw fa-arrow-left"></i><span class="d-none d-lg-inline ms-2">RMM Providers</span></a>
|
||||
<a class="btn btn-outline-light me-1" href="<?= $words['page'] ?>" title="Back to <?= $words['title'] ?>"><i class="fas fa-fw fa-arrow-left"></i><span class="d-none d-lg-inline ms-2"><?= $words['title'] ?></span></a>
|
||||
<?php if ($dashboard !== '') { ?>
|
||||
<a class="btn btn-outline-light me-1" href="<?= escapeHtml($dashboard) ?>" target="_blank" rel="noopener noreferrer" title="<?= escapeHtml($name) ?>'s dashboard"><i class="fas fa-fw fa-external-link-alt"></i><span class="d-none d-lg-inline ms-2">Open <?= escapeHtml($short) ?></span></a>
|
||||
<?php } ?>
|
||||
<?php if ($usable) { ?>
|
||||
<a class="btn btn-primary" href="post.php?sync_rmm=<?= $provider_id ?>&csrf_token=<?= $csrf ?>" data-rmm-sync title="Bring in the linked clients' devices now"><i class="fas fa-fw fa-sync-alt"></i><span class="d-none d-lg-inline ms-2">Sync Now</span></a>
|
||||
<a class="btn btn-primary" href="post.php?sync_rmm=<?= $provider_id ?>&csrf_token=<?= $csrf ?>" data-rmm-sync title="Bring in the linked <?= $words['clients'] ?>' devices now"><i class="fas fa-fw fa-sync-alt"></i><span class="d-none d-lg-inline ms-2">Sync Now</span></a>
|
||||
<?php } ?>
|
||||
<div class="dropdown dropstart d-inline-block ms-1">
|
||||
<button class="btn btn-outline-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
|
||||
@@ -130,7 +133,7 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
<div class="card-header py-2 small" data-rmm-sync-state="<?= $provider['rmm_provider_sync_at'] ? (intval($provider['rmm_provider_sync_ok']) ? 'ok' : 'failed') : 'never' ?>">
|
||||
<div class="d-flex flex-wrap align-items-center column-gap-3 row-gap-1">
|
||||
<?php if (!$provider['rmm_provider_sync_at']) { ?>
|
||||
<span class="text-body-secondary"><i class="fas fa-fw fa-info-circle me-1"></i>Not synced yet - link a client below and its devices come in straight away.</span>
|
||||
<span class="text-body-secondary"><i class="fas fa-fw fa-info-circle me-1"></i>Not synced yet - link a <?= $words['client'] ?> below and its devices come in straight away.</span>
|
||||
<?php } elseif (intval($provider['rmm_provider_sync_ok'])) { ?>
|
||||
<span><i class="fas fa-fw fa-check-circle text-success me-1"></i>Synced <span title="<?= formatDateTime($provider['rmm_provider_sync_at']) ?>"><?= escapeHtml(timeAgo($provider['rmm_provider_sync_at'])) ?></span> - <?= escapeHtml((string) $provider['rmm_provider_sync_note']) ?></span>
|
||||
<?php } else { ?>
|
||||
@@ -147,12 +150,12 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-lg-5 col-md-6">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search clients..." title="<?= escapeHtml($short) ?>'s client, or yours">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search <?= $words['clients'] ?>..." title="<?= escapeHtml($short) ?>'s <?= $words['client'] ?>, or your client">
|
||||
<button class="btn btn-dark" title="Search"><i class="fas fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-7 col-md-6 small text-body-secondary text-md-end">
|
||||
Link each of <?= escapeHtml($short) ?>'s clients to yours - its devices come in as assets.
|
||||
Link each of <?= escapeHtml($short) ?>'s <?= $words['clients'] ?> to <?= $words['client'] === 'client' ? 'yours' : 'a client' ?> - its devices come in as assets.
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -172,7 +175,7 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light text-nowrap <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th class="ps-3"><?= sortLink('rmm_client_name', escapeHtml("$short client")) ?></th>
|
||||
<th class="ps-3"><?= sortLink('rmm_client_name', escapeHtml("$short {$words['client']}")) ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= sortLink('rmm_client_devices', 'Devices') ?></th>
|
||||
<th><?= sortLink('client_name', 'ITFlow client') ?></th>
|
||||
<th class="d-none d-lg-table-cell"><?= sortLink('rmm_client_synced_at', 'Brought in') ?></th>
|
||||
@@ -196,7 +199,7 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
<div class="fw-semibold"><?= escapeHtml($row['rmm_client_name']) ?>
|
||||
<?php if ($removed) { ?><span class="badge rounded-pill text-bg-secondary fw-normal ms-1" title="<?= escapeHtml($name) ?> stopped listing it <?= escapeHtml(timeAgo($row['rmm_client_removed_at'])) ?>">Gone from <?= escapeHtml($short) ?></span><?php } ?>
|
||||
</div>
|
||||
<div class="small text-body-secondary"><?= $sites ?> site<?= $sites === 1 ? '' : 's' ?><span class="d-md-none"> · <?= intval($row['rmm_client_devices']) ?> devices</span></div>
|
||||
<div class="small text-body-secondary"><?php if ($words['client'] === 'client') { ?><?= $sites ?> site<?= $sites === 1 ? '' : 's' ?><span class="d-md-none"> · </span><?php } ?><span class="d-md-none"><?= intval($row['rmm_client_devices']) ?> devices</span></div>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-nowrap">
|
||||
<div><?= number_format(intval($row['rmm_client_devices'])) ?> in <?= escapeHtml($short) ?></div>
|
||||
@@ -273,10 +276,10 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO
|
||||
</div>
|
||||
<?php
|
||||
$empty_state = [
|
||||
'thing' => "$short clients",
|
||||
'thing' => "$short {$words['clients']}",
|
||||
'icon' => $kind['icon'],
|
||||
'title' => escapeHtml($show === 'unlinked' ? "Every $short client is linked" : "No $short clients yet"),
|
||||
'text' => $show === 'unlinked' ? '' : escapeHtml($provider['rmm_provider_sync_at'] ? "$name has no clients this key can see." : "Sync now asks $name for its clients."),
|
||||
'title' => escapeHtml($show === 'unlinked' ? "Every $short {$words['client']} is linked" : "No $short {$words['clients']} yet"),
|
||||
'text' => $show === 'unlinked' ? '' : escapeHtml($provider['rmm_provider_sync_at'] ? "$name has no {$words['clients']} it can see." : "Sync now asks $name for its {$words['clients']}."),
|
||||
'actions' => $usable && !$provider['rmm_provider_sync_at'] ? [['label' => 'Sync Now', 'href' => "post.php?sync_rmm=$provider_id&csrf_token=$csrf", 'icon' => 'fa-sync-alt']] : [],
|
||||
'filtered' => $q !== '',
|
||||
];
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
* last sync went. Its clients are
|
||||
* linked on its Clients page (rmm_clients.php). Add and Edit are one window
|
||||
* (modals/rmm/rmm_provider_edit.php); the rest are admin/post/rmm.php.
|
||||
*
|
||||
* Admin > Network Platforms (network_platforms.php) is this page for the network family's
|
||||
* kinds - UniFi - in its words (rmmFamilyWords()): platforms and their sites.
|
||||
*/
|
||||
|
||||
// Default Column Sortby Filter
|
||||
@@ -15,15 +18,23 @@ $order = "ASC";
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
// The tables arrive with the 3.6.7 database update
|
||||
if (!rmmTablesReady()) { ?>
|
||||
<div class="alert alert-warning"><i class="fas fa-fw fa-exclamation-triangle me-2"></i>RMM Providers arrive with a database update - run it in <a href="update.php">Maintenance > Update</a> first.</div>
|
||||
$rmm_family = ($rmm_family ?? 'rmm') === 'network' ? 'network' : 'rmm';
|
||||
$words = rmmFamilyWords($rmm_family);
|
||||
|
||||
// The tables arrive with the 3.6.7 database update - and network platforms' columns with 4.1.5
|
||||
if (!rmmTablesReady() || ($rmm_family === 'network' && !rmmNetworkReady())) { ?>
|
||||
<div class="alert alert-warning"><i class="fas fa-fw fa-exclamation-triangle me-2"></i><?= $words['title'] ?> arrive with a database update - run it in <a href="update.php">Maintenance > Update</a> first.</div>
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
$kinds = rmmProviderKinds();
|
||||
$kinds = rmmProviderKinds($rmm_family);
|
||||
// Only this family's - one of a kind ITFlow doesn't know shows with the RMMs
|
||||
$network_kinds = array_keys(rmmProviderKinds('network'));
|
||||
$family_sql = $rmm_family === 'network'
|
||||
? "AND rmm_provider_kind IN ('" . implode("', '", array_map('escapeSql', array_keys($kinds))) . "')"
|
||||
: ($network_kinds ? "AND rmm_provider_kind NOT IN ('" . implode("', '", array_map('escapeSql', $network_kinds)) . "')" : '');
|
||||
|
||||
// Only these sort - an unknown column would take the page down
|
||||
$sortable_columns = [
|
||||
@@ -43,8 +54,10 @@ $kinds_found = array_keys(array_filter($kinds, function ($kind) use ($q) {
|
||||
}));
|
||||
$kind_search = $kinds_found ? " OR rmm_provider_kind IN ('" . implode("', '", array_map('escapeSql', $kinds_found)) . "')" : '';
|
||||
|
||||
// Alerts open tickets once the 3.6.8 database update is in - and their open ones, with tickets
|
||||
$alerts_ready = rmmAlertsReady();
|
||||
// Alerts open tickets once the 3.6.8 database update is in - and their open ones, with tickets. A family none of whose kinds has alerts has no column for them
|
||||
$alerts_ready = rmmAlertsReady() && array_filter($kinds, function ($kind) {
|
||||
return isset($kind['alerts'], $kind['alert']);
|
||||
});
|
||||
$alerts_sql = $alerts_ready ? ", (SELECT COUNT(*) FROM rmm_alerts WHERE rmm_alert_provider_id = rmm_provider_id AND rmm_alert_cleared_at IS NULL AND rmm_alert_ticket_id > 0) AS alerts_open" : '';
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS rmm_providers.*,
|
||||
@@ -54,29 +67,29 @@ $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS rmm_providers.*,
|
||||
(SELECT COUNT(*) FROM rmm_devices WHERE rmm_device_provider_id = rmm_provider_id AND rmm_device_removed_at IS NULL AND rmm_device_asset_id > 0 AND rmm_device_status = 'overdue') AS devices_overdue
|
||||
$alerts_sql
|
||||
FROM rmm_providers
|
||||
WHERE (rmm_provider_name LIKE '%$q%' OR rmm_provider_api_url LIKE '%$q%' OR rmm_provider_kind LIKE '%$q%'$kind_search)
|
||||
WHERE (rmm_provider_name LIKE '%$q%' OR rmm_provider_api_url LIKE '%$q%' OR rmm_provider_kind LIKE '%$q%'$kind_search) $family_sql
|
||||
ORDER BY {$sortable_columns[$sort]}, rmm_provider_id ASC
|
||||
LIMIT $record_from, $record_to");
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
|
||||
// Syncing needs cron - say so while a provider is on and it isn't running
|
||||
$any_on = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM rmm_providers WHERE rmm_provider_active = 1"))[0]) > 0;
|
||||
$any_on = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM rmm_providers WHERE rmm_provider_active = 1 $family_sql"))[0]) > 0;
|
||||
$cron_on = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT config_enable_cron FROM settings WHERE company_id = 1"))[0] ?? 0) === 1;
|
||||
$job = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT cron_job_enabled FROM cron_jobs WHERE cron_job_name = 'rmm_sync' LIMIT 1"));
|
||||
$job_on = !$job || intval($job['cron_job_enabled']) === 1;
|
||||
|
||||
|
||||
$add_url = 'modals/rmm/rmm_provider_add.php';
|
||||
$add_url = 'modals/rmm/rmm_provider_add.php' . ($rmm_family === 'network' ? '?family=network' : '');
|
||||
$csrf = $_SESSION['csrf_token'];
|
||||
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark py-2">
|
||||
<h3 class="card-title mt-2"><i class="fas fa-fw fa-laptop-medical me-2"></i>RMM Providers</h3>
|
||||
<h3 class="card-title mt-2"><i class="<?= $words['icon'] ?> fa-fw me-2"></i><?= $words['title'] ?></h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="<?= $add_url ?>"><i class="fas fa-plus"></i><span class="d-none d-lg-inline ms-2">New Provider</span></button>
|
||||
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="<?= $add_url ?>"><i class="fas fa-plus"></i><span class="d-none d-lg-inline ms-2">New <?= $words['One'] ?></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($any_on && (!$cron_on || !$job_on)) { ?>
|
||||
@@ -89,7 +102,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-lg-5 col-md-6">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search RMM providers..." title="Name, kind or API address">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search <?= strtolower($words['title']) ?>..." title="Name, kind or address">
|
||||
<button class="btn btn-dark" title="Search"><i class="fas fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -100,9 +113,9 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light text-nowrap <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th class="ps-3"><?= sortLink('rmm_provider_name', 'Provider') ?></th>
|
||||
<th class="ps-3"><?= sortLink('rmm_provider_name', $words['One']) ?></th>
|
||||
<th class="d-none d-lg-table-cell"><?= sortLink('rmm_provider_kind', 'Kind') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= sortLink('clients_linked', 'Clients') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= sortLink('clients_linked', $words['Clients']) ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= sortLink('devices_in', 'Devices') ?></th>
|
||||
<?php if ($alerts_ready) { ?><th class="d-none d-lg-table-cell">Alerts</th><?php } ?>
|
||||
<th class="d-none d-sm-table-cell"><?= sortLink('rmm_provider_sync_at', 'Last sync') ?></th>
|
||||
@@ -131,7 +144,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<tr data-rmm-provider-id="<?= $provider_id ?>" class="<?= $on ? '' : 'text-body-secondary' ?>">
|
||||
<td class="ps-3">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<span class="d-none d-sm-inline-flex itflow-asset-icon itflow-asset-tone-other" aria-hidden="true"><i class="<?= escapeHtml($kind['icon'] ?? 'fas fa-laptop-medical') ?>"></i></span>
|
||||
<span class="d-none d-sm-inline-flex itflow-asset-icon itflow-asset-tone-other" aria-hidden="true"><i class="<?= escapeHtml($kind['icon'] ?? $words['icon']) ?>"></i></span>
|
||||
<div class="min-w-0">
|
||||
<a class="fw-semibold text-body" href="<?= $clients_url ?>"><?= escapeHtml($name) ?></a>
|
||||
<?php if (!$kind) { ?>
|
||||
@@ -141,7 +154,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<?php } ?>
|
||||
<div class="small text-body-secondary text-truncate"><span class="d-lg-none"><?= escapeHtml($kind['name'] ?? $row['rmm_provider_kind']) ?><?= $host !== '' ? ' · ' : '' ?></span><?= escapeHtml($host) ?></div>
|
||||
<!-- On smaller screens its clients and devices come along under the name -->
|
||||
<div class="d-md-none small text-body-secondary"><?= $linked ?> of <?= $total ?> clients linked · <?= number_format($devices) ?> devices</div>
|
||||
<div class="d-md-none small text-body-secondary"><?= $linked ?> of <?= $total ?> <?= $words['clients'] ?> linked · <?= number_format($devices) ?> devices</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -149,7 +162,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<td class="d-none d-md-table-cell small text-nowrap">
|
||||
<a class="text-reset" href="<?= $clients_url ?>"><?= $linked ?> of <?= $total ?> linked</a>
|
||||
<?php if ($suggested) { ?>
|
||||
<div><a class="text-body-secondary" href="<?= $clients_url ?>&show=unlinked" data-rmm-suggested="<?= $suggested ?>" title="Your clients of the same name - link them on its Clients page"><?= $suggested ?> to link</a></div>
|
||||
<div><a class="text-body-secondary" href="<?= $clients_url ?>&show=unlinked" data-rmm-suggested="<?= $suggested ?>" title="Your clients of the same name - link them on its <?= $words['Clients'] ?> page"><?= $suggested ?> to link</a></div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell small text-nowrap">
|
||||
@@ -188,12 +201,12 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<div class="dropdown dropstart">
|
||||
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="<?= $clients_url ?>"><i class="fas fa-fw fa-users text-secondary me-2"></i>Clients</a>
|
||||
<a class="dropdown-item" href="<?= $clients_url ?>"><i class="fas fa-fw <?= $rmm_family === 'network' ? 'fa-map-marker-alt' : 'fa-users' ?> text-secondary me-2"></i><?= $words['Clients'] ?></a>
|
||||
<?php if ($kind) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="<?= $edit_url ?>"><i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit</a>
|
||||
<?php } ?>
|
||||
<?php if ($usable) { ?>
|
||||
<a class="dropdown-item" href="post.php?sync_rmm=<?= $provider_id ?>&csrf_token=<?= $csrf ?>" data-rmm-sync title="Bring in its linked clients' devices now"><i class="fas fa-fw fa-sync-alt text-secondary me-2"></i>Sync Now</a>
|
||||
<a class="dropdown-item" href="post.php?sync_rmm=<?= $provider_id ?>&csrf_token=<?= $csrf ?>" data-rmm-sync title="Bring in its linked <?= $words['clients'] ?>' devices now"><i class="fas fa-fw fa-sync-alt text-secondary me-2"></i>Sync Now</a>
|
||||
<?php } ?>
|
||||
<?php if ($kind) { ?>
|
||||
<a class="dropdown-item" href="post.php?test_rmm_provider=<?= $provider_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-vial text-secondary me-2"></i>Test the Connection</a>
|
||||
@@ -213,7 +226,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger confirm-link" href="post.php?delete_rmm_provider=<?= $provider_id ?>&csrf_token=<?= $csrf ?>"
|
||||
data-confirm-title="Delete <?= escapeHtml($name) ?>?" data-confirm-button="Delete"
|
||||
data-confirm-text="The links between its clients and yours are forgotten, and assets no longer show what it says about them. The <?= number_format($devices) ?> asset<?= $devices === 1 ? '' : 's' ?> it brought in stay, as they are.<?= $billed_lines ? ' ' . $billed_lines . ' recurring invoice line' . ($billed_lines === 1 ? ' bills' : 's bill') . ' its managed devices - look at ' . ($billed_lines === 1 ? 'it' : 'them') . ' after, as its devices no longer count.' : '' ?>">
|
||||
data-confirm-text="The links between its <?= $words['clients'] ?> and your clients are forgotten, and assets no longer show what it says about them. The <?= number_format($devices) ?> asset<?= $devices === 1 ? '' : 's' ?> it brought in stay, as they are.<?= $billed_lines ? ' ' . $billed_lines . ' recurring invoice line' . ($billed_lines === 1 ? ' bills' : 's bill') . ' its managed devices - look at ' . ($billed_lines === 1 ? 'it' : 'them') . ' after, as its devices no longer count.' : '' ?>">
|
||||
<i class="fas fa-fw fa-trash me-2"></i>Delete
|
||||
</a>
|
||||
</div>
|
||||
@@ -225,7 +238,12 @@ $csrf = $_SESSION['csrf_token'];
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
$empty_state = [
|
||||
$empty_state = $rmm_family === 'network' ? [
|
||||
'thing' => 'network platforms',
|
||||
'icon' => 'fa-network-wired',
|
||||
'text' => 'Add your UniFi controller, a UniFi console, or every console your UI account has through Site Manager, and link its sites to your clients: their gateways, switches and access points come in as assets, matched to the ones you have by MAC address, and each shows whether it is online and whether its firmware is out of date - kept up every 15 minutes.',
|
||||
'actions' => [['label' => 'New Platform', 'modal' => $add_url]],
|
||||
] : [
|
||||
'thing' => 'RMM providers',
|
||||
'icon' => 'fa-laptop-medical',
|
||||
'text' => 'Add ' . escapeHtml(implode(' or ', array_column($kinds, 'name'))) . ' and link its clients to yours: their devices come in as assets, matched to the ones you have, and each asset shows whether it is online, who is signed in and what needs attention - kept up every 15 minutes.',
|
||||
|
||||
Reference in New Issue
Block a user