mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
rename /user/ to /agent/ and update links to use agent/ instead
This commit is contained in:
247
agent/modals/service/service_add.php
Normal file
247
agent/modals/service/service_add.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<div class="modal" id="addServiceModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-stream mr-2"></i>New Service</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
|
||||
<div class="modal-body">
|
||||
<?php if ($client_url) { ?>
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-overview">Overview</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-general">General</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-assets">Assets</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<!-- //TODO: The multiple selects won't play nicely with the icons or just general formatting. I've just added blank <p> tags to format it better for now -->
|
||||
|
||||
<div class="tab-pane fade show active" id="pills-overview">
|
||||
|
||||
<?php if ($client_url) { ?>
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<?php } else { ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Client <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="client_id" required>
|
||||
<option value="">- Select Client -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL $access_permission_query ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']); ?>
|
||||
<option <?php if ($client_id == isset($_GET['client'])) { echo "selected"; } ?> value="<?php echo $client_id; ?>"><?php echo $client_name; ?></option>
|
||||
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-stream"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Name of Service" maxlength="200" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Description <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info-circle"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="description" placeholder="Description of Service" maxlength="200" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- //TODO: Integrate with company wide categories: /categories.php -->
|
||||
<div class="form-group">
|
||||
<label>Category</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="category" placeholder="Category" maxlength="20">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Importance</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="importance" required>
|
||||
<option>Low</option>
|
||||
<option>Medium</option>
|
||||
<option>High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Backup</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-hdd"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="backup" placeholder="Backup strategy" maxlength="200">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Notes</label>
|
||||
<textarea class="form-control" rows="3" placeholder="Enter some notes" name="note"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($client_url) { ?>
|
||||
|
||||
<div class="tab-pane fade" id="pills-general">
|
||||
<div class="form-group">
|
||||
<label for="contacts">Select related Contacts</label>
|
||||
<select class="form-control select2" id="contacts" name="contacts[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||
echo "<option value=\"$contact_id\">$contact_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="vendors">Select related vendors</label>
|
||||
<select class="form-control select2" id="vendors" name="vendors[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
echo "<option value=\"$vendor_id\">$vendor_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="documents">Select related documents</label>
|
||||
<select class="form-control select2" id="documents" name="documents[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$document_id = intval($row['document_id']);
|
||||
$document_name = nullable_htmlentities($row['document_name']);
|
||||
echo "<option value=\"$document_id\">$document_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- TODO: Services related to other services -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-assets">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="assets">Select related assets</label>
|
||||
<select class="form-control select2" id="assets" name="assets[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$asset_id = intval($row['asset_id']);
|
||||
$asset_name = nullable_htmlentities($row['asset_name']);
|
||||
echo "<option value=\"$asset_id\">$asset_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="logins">Select related Credentials</label>
|
||||
<select class="form-control select2" id="credentials" name="credentials[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$credential_id = intval($row['credential_id']);
|
||||
$credential_name = nullable_htmlentities($row['credential_name']);
|
||||
echo "<option value=\"$credential_id\">$credential_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="domains">Select related domains</label>
|
||||
<select class="form-control select2" id="domains" name="domains[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM domains WHERE domain_archived_at IS NULL AND domain_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$domain_id = intval($row['domain_id']);
|
||||
$domain_name = nullable_htmlentities($row['domain_name']);
|
||||
echo "<option value=\"$domain_id\">$domain_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="certificates">Select related certificates</label>
|
||||
<select class="form-control select2" id="certificates" name="certificates[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_archived_at IS NULL AND certificate_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$cert_id = intval($row['certificate_id']);
|
||||
$cert_name = nullable_htmlentities($row['certificate_name']);
|
||||
$cert_domain = nullable_htmlentities($row['certificate_domain']);
|
||||
echo "<option value=\"$cert_id\">$cert_name ($cert_domain)</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" name="add_service" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
314
agent/modals/service/service_details.php
Normal file
314
agent/modals/service/service_details.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
$service_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM services WHERE service_id = $service_id LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$service_name = nullable_htmlentities($row['service_name']);
|
||||
$service_description = nullable_htmlentities($row['service_description']);
|
||||
$service_category = nullable_htmlentities($row['service_category']);
|
||||
$service_importance = nullable_htmlentities($row['service_importance']);
|
||||
$service_backup = nullable_htmlentities($row['service_backup']);
|
||||
$service_notes = nullable_htmlentities($row['service_notes']);
|
||||
$service_created_at = nullable_htmlentities($row['service_created_at']);
|
||||
$service_updated_at = nullable_htmlentities($row['service_updated_at']);
|
||||
$service_review_due = nullable_htmlentities($row['service_review_due']);
|
||||
$client_id = intval($row['service_client_id']);
|
||||
|
||||
// Service Importance
|
||||
if ($service_importance == "High") {
|
||||
$service_importance_display = "<span class='p-2 badge badge-danger'>$service_importance</span>";
|
||||
} elseif ($service_importance == "Medium") {
|
||||
$service_importance_display = "<span class='p-2 badge badge-warning'>$service_importance</span>";
|
||||
} elseif ($service_importance == "Low") {
|
||||
$service_importance_display = "<span class='p-2 badge badge-info'>$service_importance</span>";
|
||||
} else {
|
||||
$service_importance_display = "-";
|
||||
}
|
||||
|
||||
// Associated Assets (and their credentials/networks/locations)
|
||||
$sql_assets = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_assets
|
||||
LEFT JOIN assets ON service_assets.asset_id = assets.asset_id
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1
|
||||
LEFT JOIN credentials ON service_assets.asset_id = credentials.credential_asset_id
|
||||
LEFT JOIN networks ON interface_network_id = networks.network_id
|
||||
LEFT JOIN locations ON assets.asset_location_id = locations.location_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated credentials
|
||||
$sql_credentials = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_credentials
|
||||
LEFT JOIN credentials ON service_credentials.credential_id = credentials.credential_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Domains
|
||||
$sql_domains = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_domains
|
||||
LEFT JOIN domains ON service_domains.domain_id = domains.domain_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Certificates
|
||||
$sql_certificates = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_certificates
|
||||
LEFT JOIN certificates ON service_certificates.certificate_id = certificates.certificate_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Vendors
|
||||
$sql_vendors = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_vendors
|
||||
LEFT JOIN vendors ON service_vendors.vendor_id = vendors.vendor_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Contacts
|
||||
$sql_contacts = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_contacts
|
||||
LEFT JOIN contacts ON service_contacts.contact_id = contacts.contact_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Documents
|
||||
$sql_docs = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_documents
|
||||
LEFT JOIN documents ON service_documents.document_id = documents.document_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Generate the HTML form content using output buffering.
|
||||
ob_start();
|
||||
?>
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-stream mr-2"></i><?php echo $service_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<!-- Main/Left side -->
|
||||
<div class="col-8 border-right">
|
||||
<div class="col-12">
|
||||
<h4>Service Overview: <?php echo "$service_name $service_importance_display"; ?></h4>
|
||||
<b>Description:</b> <?php echo $service_description; ?> <br>
|
||||
<b>Backup Info:</b> <?php echo $service_backup; ?> <br><br>
|
||||
|
||||
<h5><i class="fas fa-fw fa-sticky-note mr-2"></i>Notes</h5>
|
||||
<div style="white-space: pre-line"><?php echo $service_notes; ?></div>
|
||||
<hr>
|
||||
|
||||
<!-- Assets -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_assets) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-desktop mr-2'></i>Assets</h5><ul>";
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
$asset_id = intval($row['asset_id']);
|
||||
$asset_name = nullable_htmlentities($row['asset_name']);
|
||||
$ip = !empty($row['interface_ip']) ? '(' . nullable_htmlentities($row['interface_ip']) . ')' : '';
|
||||
echo "<li><a class='ajax-modal' href='#' data-modal-size='lg' data-modal-url='modals/asset/asset_details.php?id=$asset_id'>$asset_name</a>$ip</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Networks -->
|
||||
<?php
|
||||
$networks = [];
|
||||
if ($sql_assets) {
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
if (!empty($row['network_name'])) {
|
||||
$network_data = nullable_htmlentities($row["network_name"]) . ':' . nullable_htmlentities($row["network_vlan"]);
|
||||
$networks[] = $network_data;
|
||||
}
|
||||
}
|
||||
$networks = array_unique($networks);
|
||||
if (!empty($networks)) {
|
||||
echo "<h5><i class='fas fa-fw fa-network-wired mr-2'></i>Networks</h5><ul>";
|
||||
foreach ($networks as $network) {
|
||||
$network_parts = explode(":", $network);
|
||||
$network_name = $network_parts[0];
|
||||
$network_vlan = $network_parts[1] ?? '';
|
||||
echo "<li><a href='networks.php?client_id=$client_id&q=$network_name'>$network_name</a> (VLAN $network_vlan)</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Locations -->
|
||||
<?php
|
||||
$location_names = [];
|
||||
if ($sql_assets) {
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
if (!empty($row['location_name'])) {
|
||||
$location_names[] = nullable_htmlentities($row['location_name']);
|
||||
}
|
||||
}
|
||||
$location_names = array_unique($location_names);
|
||||
if (!empty($location_names)) {
|
||||
echo "<h5><i class='fas fa-fw fa-map-marker-alt mr-2'></i>Locations</h5><ul>";
|
||||
foreach ($location_names as $location) {
|
||||
echo "<li><a href='locations.php?client_id=$client_id&q=$location'>$location</a></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Domains -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_domains) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-globe mr-2'></i>Domains</h5><ul>";
|
||||
mysqli_data_seek($sql_domains, 0);
|
||||
while ($row = mysqli_fetch_array($sql_domains)) {
|
||||
if (!empty($row['domain_name'])) {
|
||||
$domain_name = nullable_htmlentities($row['domain_name']);
|
||||
echo "<li><a href='domains.php?client_id=$client_id&q=$domain_name'>$domain_name</a></li>";
|
||||
}
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Certificates -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_certificates) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-lock mr-2'></i>Certificates</h5><ul>";
|
||||
mysqli_data_seek($sql_certificates, 0);
|
||||
while ($row = mysqli_fetch_array($sql_certificates)) {
|
||||
if (!empty($row['certificate_name'])) {
|
||||
$certificate_name = nullable_htmlentities($row['certificate_name']);
|
||||
$certificate_domain = nullable_htmlentities($row['certificate_domain']);
|
||||
echo "<li><a href='certificates.php?client_id=$client_id&q=$certificate_name'>$certificate_name ($certificate_domain)</a></li>";
|
||||
}
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right side -->
|
||||
<div class="col-4">
|
||||
<div class="col-12">
|
||||
<h4>Additional Related Items</h4>
|
||||
<br>
|
||||
|
||||
<!-- Vendors -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_vendors) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-building mr-2'></i>Vendors</h5><ul>";
|
||||
mysqli_data_seek($sql_vendors, 0);
|
||||
while ($row = mysqli_fetch_array($sql_vendors)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
echo "<li><a class='ajax-modal' href='#' data-modal-size='lg' data-modal-url='modals/vendor/vendor_details.php?id=$vendor_id'>$vendor_name</a></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Contacts -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_contacts) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-users mr-2'></i>Contacts</h5><ul>";
|
||||
mysqli_data_seek($sql_contacts, 0);
|
||||
while ($row = mysqli_fetch_array($sql_contacts)) {
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||
echo "<li><a href='#' class='ajax-modal' data-modal-size='lg' data-modal-url='modals/contact/contact_details.php?id=$contact_id'>$contact_name</a></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Credentials -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_assets) > 0 || mysqli_num_rows($sql_credentials) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-key mr-2'></i>Credentials</h5><ul>";
|
||||
// Credentials linked to assets
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
$credential_name = nullable_htmlentities($row['credential_name']);
|
||||
if (!empty($credential_name)) {
|
||||
echo "<li><a href='credentials.php?client_id=$client_id&q=$credential_name'>$credential_name</a></li>";
|
||||
}
|
||||
}
|
||||
// Explicitly linked credentials
|
||||
mysqli_data_seek($sql_credentials, 0);
|
||||
while ($row = mysqli_fetch_array($sql_credentials)) {
|
||||
$credential_name = nullable_htmlentities($row['credential_name']);
|
||||
if (!empty($credential_name)) {
|
||||
echo "<li><a href='credentials.php?client_id=$client_id&q=$credential_name'>$credential_name</a></li>";
|
||||
}
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- URLs -->
|
||||
<?php
|
||||
$urls = [];
|
||||
mysqli_data_seek($sql_credentials, 0);
|
||||
while ($row = mysqli_fetch_array($sql_credentials)) {
|
||||
if (!empty($row['credential_uri'])) {
|
||||
$urls[] = sanitize_url($row['credential_uri']);
|
||||
}
|
||||
}
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
if (!empty($row['asset_uri'])) {
|
||||
$urls[] = sanitize_url($row['asset_uri']);
|
||||
}
|
||||
}
|
||||
$urls = array_unique($urls);
|
||||
if (!empty($urls)) {
|
||||
echo "<h5><i class='fas fa-fw fa-link mr-2'></i>URLs</h5><ul>";
|
||||
foreach ($urls as $url) {
|
||||
$label = htmlspecialchars(parse_url($url, PHP_URL_HOST) ?: $url);
|
||||
echo "<li><a href='$url' target='_blank'>$label</a></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Documents -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_docs) > 0) {
|
||||
echo "<h5><i class='fas fa-fw fa-file-alt mr-2'></i>Documents</h5><ul>";
|
||||
mysqli_data_seek($sql_docs, 0);
|
||||
while ($row = mysqli_fetch_array($sql_docs)) {
|
||||
$document_id = intval($row['document_id']);
|
||||
$document_name = nullable_htmlentities($row['document_name']);
|
||||
echo "<li><a class='ajax-modal' href='#' data-modal-size='lg' data-modal-url='modals/document/document_view.php?id=$document_id'>$document_name</a></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
|
||||
358
agent/modals/service/service_edit.php
Normal file
358
agent/modals/service/service_edit.php
Normal file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
$service_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM services WHERE service_id = $service_id LIMIT 1");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$service_name = nullable_htmlentities($row['service_name']);
|
||||
$service_description = nullable_htmlentities($row['service_description']);
|
||||
$service_category = nullable_htmlentities($row['service_category']);
|
||||
$service_importance = nullable_htmlentities($row['service_importance']);
|
||||
$service_backup = nullable_htmlentities($row['service_backup']);
|
||||
$service_notes = nullable_htmlentities($row['service_notes']);
|
||||
$service_created_at = nullable_htmlentities($row['service_created_at']);
|
||||
$service_updated_at = nullable_htmlentities($row['service_updated_at']);
|
||||
$service_review_due = nullable_htmlentities($row['service_review_due']);
|
||||
$client_id = intval($row['service_client_id']);
|
||||
|
||||
// Associated Assets (and their credentials/networks/locations)
|
||||
$sql_assets = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_assets
|
||||
LEFT JOIN assets ON service_assets.asset_id = assets.asset_id
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1
|
||||
LEFT JOIN credentials ON service_assets.asset_id = credentials.credential_asset_id
|
||||
LEFT JOIN networks ON interface_network_id = networks.network_id
|
||||
LEFT JOIN locations ON assets.asset_location_id = locations.location_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated credentials
|
||||
$sql_credentials = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_credentials
|
||||
LEFT JOIN credentials ON service_credentials.credential_id = credentials.credential_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Domains
|
||||
$sql_domains = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_domains
|
||||
LEFT JOIN domains ON service_domains.domain_id = domains.domain_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
// Associated Certificates
|
||||
$sql_certificates = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_certificates
|
||||
LEFT JOIN certificates ON service_certificates.certificate_id = certificates.certificate_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated URLs ---- REMOVED for now
|
||||
//$sql_urls = mysqli_query($mysqli, "SELECT * FROM service_urls
|
||||
//WHERE service_id = '$service_id'");
|
||||
|
||||
// Associated Vendors
|
||||
$sql_vendors = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_vendors
|
||||
LEFT JOIN vendors ON service_vendors.vendor_id = vendors.vendor_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Contacts
|
||||
$sql_contacts = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_contacts
|
||||
LEFT JOIN contacts ON service_contacts.contact_id = contacts.contact_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated Documents
|
||||
$sql_docs = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_documents
|
||||
LEFT JOIN documents ON service_documents.document_id = documents.document_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Generate the HTML form content using output buffering.
|
||||
ob_start();
|
||||
?>
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-stream mr-2"></i>Editing service: <strong><?php echo $service_name; ?></strong></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id ?>">
|
||||
<input type="hidden" name="service_id" value="<?php echo $service_id ?>">
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-overview<?php echo $service_id ?>">Overview</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-general<?php echo $service_id ?>">General</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-assets<?php echo $service_id ?>">Assets</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="tab-content" <?php if (lookupUserPermission('module_support') <= 1) { echo 'inert'; } ?>>
|
||||
|
||||
<div class="tab-pane fade show active" id="pills-overview<?php echo $service_id ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-stream"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Name of Service" maxlength="200" value="<?php echo $service_name ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Description <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info-circle"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="description" placeholder="Description of Service" maxlength="200" value="<?php echo $service_description ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- //TODO: Integrate with company wide categories: /categories.php -->
|
||||
<div class="form-group">
|
||||
<label>Category</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="category" placeholder="Category" maxlength="20" value="<?php echo $service_category ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Importance</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="importance" required>
|
||||
<option <?php if ($service_importance == 'Low') { echo "selected"; } ?> >Low</option>
|
||||
<option <?php if ($service_importance == 'Medium') { echo "selected"; } ?> >Medium</option>
|
||||
<option <?php if ($service_importance == 'High') { echo "selected"; } ?> >High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Backup</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-hdd"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="backup" placeholder="Backup strategy" maxlength="200" value="<?php echo $service_backup ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Notes</label>
|
||||
<textarea class="form-control" rows="3" placeholder="Enter some notes" name="note"><?php echo $service_notes ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-general<?php echo $service_id ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="contacts">Contacts</label>
|
||||
<select multiple class="form-control select2" name="contacts[]">
|
||||
<?php
|
||||
// Get just the currently selected contact IDs
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_contacts, MYSQLI_ASSOC), "contact_id");
|
||||
|
||||
// Get all contacts
|
||||
// NOTE: These are called $sql_all and $row_all for a reason - anything overwriting $sql or $row will break the current while loop we are in from client_services.php
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM contacts WHERE (contact_archived_at > '$service_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id");
|
||||
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$contact_id = intval($row_all['contact_id']);
|
||||
$contact_name = nullable_htmlentities($row_all['contact_name']);
|
||||
|
||||
if (in_array($contact_id, $selected_ids)) {
|
||||
echo "<option value=\"$contact_id\" selected>$contact_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$contact_id\">$contact_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="vendors">Vendors</label>
|
||||
<select multiple class="form-control select2" name="vendors[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_vendors, MYSQLI_ASSOC), "vendor_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$service_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$vendor_id = intval($row_all['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row_all['vendor_name']);
|
||||
|
||||
if (in_array($vendor_id, $selected_ids)) {
|
||||
echo "<option value=\"$vendor_id\" selected>$vendor_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$vendor_id\">$vendor_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="documents">Documents</label>
|
||||
<select multiple class="form-control select2" name="documents[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_docs, MYSQLI_ASSOC), "document_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$document_id = intval($row_all['document_id']);
|
||||
$document_name = nullable_htmlentities($row_all['document_name']);
|
||||
|
||||
if (in_array($document_id, $selected_ids)) {
|
||||
echo "<option value=\"$document_id\" selected>$document_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$document_id\">$document_name</option>";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- TODO: Services related to other services -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade" id="pills-assets<?php echo $service_id ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="assets">Assets</label>
|
||||
<select multiple class="form-control select2" name="assets[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_assets, MYSQLI_ASSOC), "asset_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM assets WHERE (asset_archived_at > '$service_created_at' OR asset_archived_at IS NULL) AND asset_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$asset_id = intval($row_all['asset_id']);
|
||||
$asset_name = nullable_htmlentities($row_all['asset_name']);
|
||||
|
||||
if (in_array($asset_id, $selected_ids)) {
|
||||
echo "<option value=\"$asset_id\" selected>$asset_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$asset_id\">$asset_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="credentials">Credentials</label>
|
||||
<select multiple class="form-control select2" name="credentials[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_credentials, MYSQLI_ASSOC), "credential_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM credentials WHERE (credential_archived_at > '$service_created_at' OR credential_archived_at IS NULL) AND credential_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$credential_id = intval($row_all['credential_id']);
|
||||
$credential_name = nullable_htmlentities($row_all['credential_name']);
|
||||
|
||||
if (in_array($credential_id, $selected_ids)) {
|
||||
echo "<option value=\"$credential_id\" selected>$credential_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$credential_id\">$credential_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="domains">Domains</label>
|
||||
<select multiple class="form-control select2" name="domains[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_domains, MYSQLI_ASSOC), "domain_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM domains WHERE (domain_archived_at > '$service_created_at' OR domain_archived_at IS NULL) AND domain_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$domain_id = intval($row_all['domain_id']);
|
||||
$domain_name = nullable_htmlentities($row_all['domain_name']);
|
||||
|
||||
if (in_array($domain_id, $selected_ids)) {
|
||||
echo "<option value=\"$domain_id\" selected>$domain_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$domain_id\">$domain_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="certificates">Certificates</label>
|
||||
<select multiple class="form-control select2" name="certificates[]">
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_certificates, MYSQLI_ASSOC), "certificate_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM certificates WHERE (certificate_archived_at > '$service_created_at' OR certificate_archived_at IS NULL) AND certificate_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$cert_id = intval($row_all['certificate_id']);
|
||||
$cert_name = nullable_htmlentities($row_all['certificate_name']);
|
||||
|
||||
if (in_array($cert_id, $selected_ids)) {
|
||||
echo "<option value=\"$cert_id\" selected>$cert_name</option>";
|
||||
}
|
||||
else{
|
||||
echo "<option value=\"$cert_id\">$cert_name</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" name="edit_service" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
Reference in New Issue
Block a user