mirror of https://github.com/itflow-org/itflow
Added Contact name to assigned asset under asset licneses in Software, move javascript for the new edit network modal from top to the bottom
This commit is contained in:
parent
b850d913a0
commit
0d2b2bb5fd
|
|
@ -2,55 +2,7 @@
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script>
|
|
||||||
function populateNetworkEditModal(client_id, network_id) {
|
|
||||||
//alert (network_id)
|
|
||||||
|
|
||||||
// Send a GET request to post.php as post.php?network_get_json_details=true&client_id=NUM&network_id=NUM
|
|
||||||
jQuery.get(
|
|
||||||
"post.php",
|
|
||||||
{network_get_json_details: 'true', client_id: client_id, network_id: network_id},
|
|
||||||
function(data){
|
|
||||||
|
|
||||||
// If we get a response from post.php, parse it as JSON
|
|
||||||
const response = JSON.parse(data);
|
|
||||||
|
|
||||||
// Access the network (only one!) and locations (possibly multiple)
|
|
||||||
const network = response.network[0];
|
|
||||||
const locations = response.locations;
|
|
||||||
|
|
||||||
// Populate the network modal fields
|
|
||||||
document.getElementById("edit_network_name_header").innerText = " " + network.network_name;
|
|
||||||
document.getElementById("edit_network_id").value = network_id;
|
|
||||||
document.getElementById("edit_network_name").value = network.network_name;
|
|
||||||
document.getElementById("edit_network_vlan").value = network.network_vlan;
|
|
||||||
document.getElementById("edit_network_cidr").value = network.network;
|
|
||||||
document.getElementById("edit_network_gw").value = network.network_gateway;
|
|
||||||
document.getElementById("edit_network_dhcp").value = network.network_dhcp_range;
|
|
||||||
|
|
||||||
// Select the location dropdown
|
|
||||||
var location_dropdown = document.getElementById("edit_network_location");
|
|
||||||
|
|
||||||
// Clear location dropdown
|
|
||||||
var i, L = location_dropdown.options.length -1;
|
|
||||||
for(i = L; i >= 0; i--) {
|
|
||||||
location_dropdown.remove(i);
|
|
||||||
}
|
|
||||||
location_dropdown[location_dropdown.length] = new Option('- Location -', '0');
|
|
||||||
|
|
||||||
// Populate location dropdown
|
|
||||||
locations.forEach(location => {
|
|
||||||
if(parseInt(location.location_id) == parseInt(network.network_location_id)){
|
|
||||||
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id, true, true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
@ -218,3 +170,53 @@ include("client_network_edit_modal.php");
|
||||||
include("client_network_add_modal.php");
|
include("client_network_add_modal.php");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function populateNetworkEditModal(client_id, network_id) {
|
||||||
|
//alert (network_id)
|
||||||
|
|
||||||
|
// Send a GET request to post.php as post.php?network_get_json_details=true&client_id=NUM&network_id=NUM
|
||||||
|
jQuery.get(
|
||||||
|
"post.php",
|
||||||
|
{network_get_json_details: 'true', client_id: client_id, network_id: network_id},
|
||||||
|
function(data){
|
||||||
|
|
||||||
|
// If we get a response from post.php, parse it as JSON
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
|
||||||
|
// Access the network (only one!) and locations (possibly multiple)
|
||||||
|
const network = response.network[0];
|
||||||
|
const locations = response.locations;
|
||||||
|
|
||||||
|
// Populate the network modal fields
|
||||||
|
document.getElementById("edit_network_name_header").innerText = " " + network.network_name;
|
||||||
|
document.getElementById("edit_network_id").value = network_id;
|
||||||
|
document.getElementById("edit_network_name").value = network.network_name;
|
||||||
|
document.getElementById("edit_network_vlan").value = network.network_vlan;
|
||||||
|
document.getElementById("edit_network_cidr").value = network.network;
|
||||||
|
document.getElementById("edit_network_gw").value = network.network_gateway;
|
||||||
|
document.getElementById("edit_network_dhcp").value = network.network_dhcp_range;
|
||||||
|
|
||||||
|
// Select the location dropdown
|
||||||
|
var location_dropdown = document.getElementById("edit_network_location");
|
||||||
|
|
||||||
|
// Clear location dropdown
|
||||||
|
var i, L = location_dropdown.options.length -1;
|
||||||
|
for(i = L; i >= 0; i--) {
|
||||||
|
location_dropdown.remove(i);
|
||||||
|
}
|
||||||
|
location_dropdown[location_dropdown.length] = new Option('- Location -', '0');
|
||||||
|
|
||||||
|
// Populate location dropdown
|
||||||
|
locations.forEach(location => {
|
||||||
|
if(parseInt(location.location_id) == parseInt(network.network_location_id)){
|
||||||
|
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id, true, true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -136,17 +136,19 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$sql = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
$sql = mysqli_query($mysqli,"SELECT * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
||||||
|
|
||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$asset_id = $row['asset_id'];
|
$asset_id = $row['asset_id'];
|
||||||
$asset_name = $row['asset_name'];
|
$asset_name = $row['asset_name'];
|
||||||
|
$asset_type = $row['asset_type'];
|
||||||
|
$contact_name = $row['contact_name'];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id; ?>">
|
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id; ?>">
|
||||||
<label class="form-check-label ml-2"><?php echo $asset_name; ?></label>
|
<label class="form-check-label ml-2"><?php echo "$asset_name - $contact_name"; ?></label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,17 +136,19 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$sql_assets_select = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
$sql_assets_select = mysqli_query($mysqli,"SELECT * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
||||||
|
|
||||||
while($row = mysqli_fetch_array($sql_assets_select)){
|
while($row = mysqli_fetch_array($sql_assets_select)){
|
||||||
$asset_id_select = $row['asset_id'];
|
$asset_id_select = $row['asset_id'];
|
||||||
$asset_name_select = $row['asset_name'];
|
$asset_name_select = $row['asset_name'];
|
||||||
|
$asset_type_select = $row['asset_type'];
|
||||||
|
$contact_name_select = $row['contact_name'];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id_select; ?>" <?php if(in_array($asset_id_select,$asset_licenses_array)){ echo "checked"; } ?>>
|
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id_select; ?>" <?php if(in_array($asset_id_select,$asset_licenses_array)){ echo "checked"; } ?>>
|
||||||
<label class="form-check-label ml-2"><?php echo $asset_name_select; ?></label>
|
<label class="form-check-label ml-2"><?php echo "$asset_name_select - $contact_name_select"; ?></label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue