mirror of https://github.com/itflow-org/itflow
Add CRUD for Client Networks
This commit is contained in:
parent
4171d9ac5d
commit
48ad18f90a
|
|
@ -0,0 +1,60 @@
|
|||
<div class="modal fade" id="addClientNetworkModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-network-wired"></i> New Network</h5>
|
||||
<button type="button" class="close" 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; ?>">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-network-wired"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Network name (VLAN, WAN, LAN2 etc)" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Network</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-network-wired"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="network" placeholder="Network ex 192.168.1.0/24" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Gateway</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-route"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="gateway" placeholder="ex 192.168.1.1" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>DHCP Range</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-server"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="dhcp_range" placeholder="ex 192.168.1.11-199">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_client_network" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -32,6 +32,8 @@ if(isset($_GET['client_id'])){
|
|||
$num_vendors = $row['num'];
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_login_id') AS num FROM client_logins WHERE client_id = $client_id"));
|
||||
$num_logins = $row['num'];
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_network_id') AS num FROM client_networks WHERE client_id = $client_id"));
|
||||
$num_networks = $row['num'];
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE client_id = $client_id"));
|
||||
$num_invoices = $row['num'];
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_note_id') AS num FROM client_notes WHERE client_id = $client_id"));
|
||||
|
|
@ -53,6 +55,7 @@ if(isset($_GET['client_id'])){
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addClientAssetModal">New Asset</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addClientVendorModal">New Vendor</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addClientLoginModal">New Login</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addClientNetworkModal">New Network</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceModal">New Invoice</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteModal">New Quote</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addClientAttachmentModal">New Attachment</a>
|
||||
|
|
@ -84,6 +87,7 @@ if(isset($_GET['client_id'])){
|
|||
<?php include("add_client_asset_modal.php"); ?>
|
||||
<?php include("add_client_vendor_modal.php"); ?>
|
||||
<?php include("add_client_login_modal.php"); ?>
|
||||
<?php include("add_client_network_modal.php"); ?>
|
||||
<?php include("add_invoice_modal.php"); ?>
|
||||
<?php include("add_invoice_payment_modal.php"); ?>
|
||||
<?php include("add_quote_modal.php"); ?>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@
|
|||
<span class="badge badge-pill badge-dark"><?php echo $num_logins; ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="?client_id=<?php echo $client_id; ?>&tab=networks">
|
||||
Networks
|
||||
<span class="badge badge-pill badge-dark"><?php echo $num_networks; ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="?client_id=<?php echo $client_id; ?>&tab=invoices">
|
||||
Invoices
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM client_networks WHERE client_id = $client_id ORDER BY client_network_id DESC"); ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Network</th>
|
||||
<th>Gateway</th>
|
||||
<th>DHCP Range</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_network_id = $row['client_network_id'];
|
||||
$client_network_name = $row['client_network_name'];
|
||||
$client_network = $row['client_network'];
|
||||
$client_network_gateway = $row['client_network_gateway'];
|
||||
$client_network_dhcp_range = $row['client_network_dhcp_range'];
|
||||
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $client_network_name; ?></td>
|
||||
<td><?php echo $client_network; ?></td>
|
||||
<td><?php echo $client_network_gateway; ?></td>
|
||||
<td><?php echo $client_network_dhcp_range; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editClientNetworkModal<?php echo $client_network_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_client_network=<?php echo $client_network_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
include("edit_client_network_modal.php");
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -19,6 +19,9 @@ if(isset($_GET['tab'])){
|
|||
elseif($_GET['tab'] == "logins"){
|
||||
include("client_logins.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "networks"){
|
||||
include("client_networks.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "invoices"){
|
||||
include("client_invoices.php");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
<div class="modal fade" id="editClientNetworkModal<?php echo $client_network_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-network-wired"></i> Edit Network</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="client_network_id" value="<?php echo $client_network_id; ?>">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-network-wired"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Network name (VLAN, WAN, LAN2 etc)" value="<?php echo $client_network_name; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Network</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-network-wired"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="network" placeholder="Network ex 192.168.1.0/24" value="<?php echo $client_network; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Gateway</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-route"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="gateway" placeholder="ex 192.168.1.1" value="<?php echo $client_network_gateway; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>DHCP Range</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-server"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="dhcp_range" placeholder="ex 192.168.1.11-199" value="<?php echo $client_network_dhcp_range; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_client_network" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
43
post.php
43
post.php
|
|
@ -749,6 +749,49 @@ if(isset($_GET['delete_client_note'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_client_network'])){
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$network = strip_tags(mysqli_real_escape_string($mysqli,$_POST['network']));
|
||||
$gateway = strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway']));
|
||||
$dhcp_range = strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO client_networks SET client_network_name = '$name', client_network = '$network', client_network_gateway = '$gateway', client_network_dhcp_range = '$dhcp_range', client_id = $client_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Network added";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_client_network'])){
|
||||
|
||||
$client_network_id = intval($_POST['client_network_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$network = strip_tags(mysqli_real_escape_string($mysqli,$_POST['network']));
|
||||
$gateway = strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway']));
|
||||
$dhcp_range = strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE client_networks SET client_network_name = '$name', client_network = '$network', client_network_gateway = '$gateway', client_network_dhcp_range = '$dhcp_range' WHERE client_network_id = $client_network_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Network updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_client_network'])){
|
||||
$client_network_id = intval($_GET['delete_client_network']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM client_networks WHERE client_network_id = $client_network_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Network deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['change_password'])){
|
||||
$current_url = $_POST['current_url'];
|
||||
$new_password = mysqli_real_escape_string($mysqli,$_POST['new_password']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue