Added location to networks

This commit is contained in:
root 2019-06-13 18:29:06 -04:00
parent 4330254891
commit 98532b0c7d
7 changed files with 70 additions and 22 deletions

View File

@ -10,18 +10,18 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="client_net_terms" value="<?php echo $client_net_terms; ?>">
<?php if(isset($_GET['client_id'])){ ?>
<input type="hidden" name="client" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="modal-body bg-white">
<?php if(isset($_GET['client_id'])){ ?>
<input type="hidden" name="client" value="<?php echo $client_id; ?>">
<?php }else{ ?>
<div class="form-group">
<label>Client</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 selectpicker show-tick" data-live-search="true" name="client" required <?php if(isset($_GET['client_id'])){ echo "disabled"; } ?>>
<select class="form-control selectpicker show-tick" data-live-search="true" name="client" required>
<option value="">- Client -</option>
<?php
@ -38,6 +38,8 @@
</select>
</div>
</div>
<?php } ?>
<div class="form-group">
<label>Invoice Date</label>

View File

@ -49,6 +49,31 @@
<input type="text" class="form-control" name="dhcp_range" placeholder="ex 192.168.1.11-199">
</div>
</div>
<div class="form-group">
<label>Location</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-map-marker-alt"></i></span>
</div>
<select class="form-control selectpicker show-tick" data-live-search="true" name="location">
<option value="">- Location -</option>
<?php
$sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE client_id = $client_id");
while($row = mysqli_fetch_array($sql)){
$location_id = $row['location_id'];
$location_name = $row['location_name'];
?>
<option value="<?php echo $location_id; ?>"><?php echo $location_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>

View File

@ -9,14 +9,16 @@
</div>
<form action="post.php" method="post" autocomplete="off">
<div class="modal-body bg-white">
<?php if(isset($_GET['client_id'])){ ?>
<input type="hidden" name="client" value="<?php echo $client_id; ?>">
<?php }else{ ?>
<div class="form-group">
<label>Client</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 selectpicker show-tick" data-live-search="true" name="client" required <?php if(isset($_GET['client_id'])){ echo "disabled"; } ?>>
<select class="form-control selectpicker show-tick" data-live-search="true" name="client" required>
<option value="">- Client -</option>
<?php
@ -33,6 +35,7 @@
</select>
</div>
</div>
<?php } ?>
<div class="form-group">
<label>Subject</label>

View File

@ -26,7 +26,8 @@
$network = $row['network'];
$network_gateway = $row['network_gateway'];
$network_dhcp_range = $row['network_dhcp_range'];
$network_dhcp_range = $row['network_dhcp_range'];
$location_id = $row['location_id'];
?>
<tr>

View File

@ -49,6 +49,31 @@
<input type="text" class="form-control" name="dhcp_range" placeholder="ex 192.168.1.11-199" value="<?php echo $network_dhcp_range; ?>">
</div>
</div>
<div class="form-group">
<label>Location</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-map-marker-alt"></i></span>
</div>
<select class="form-control selectpicker show-tick" data-live-search="true" name="location">
<option value="">- Location -</option>
<?php
$sql_locations = mysqli_query($mysqli,"SELECT * FROM locations WHERE client_id = $client_id");
while($row = mysqli_fetch_array($sql_locations)){
$location_id_select = $row['location_id'];
$location_name_select = $row['location_name'];
?>
<option <?php if($location_id == $location_id_select){ echo "selected"; } ?> value="<?php echo $location_id_select; ?>"><?php echo $location_name_select; ?></option>
<?php
}
?>
</select>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>

View File

@ -2,7 +2,7 @@
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header text-white">
<h5 class="modal-title"><i class="fa fa-fw fa-tag mr-2"></i>Ticket # <?php echo $ticket_id; ?></h5>
<h5 class="modal-title"><i class="fa fa-fw fa-tag mr-2"></i>Ticket # <?php echo $ticket_id; ?> for Client <?php echo $client_name; ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
</button>
@ -10,17 +10,7 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
<div class="modal-body bg-white">
<div class="form-group">
<label>Client</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>
<input type="text" class="form-control" value="<?php echo $client_name; ?>" disabled>
</div>
</div>
<div class="form-group">
<label>Subject</label>
<div class="input-group">

View File

@ -2449,8 +2449,9 @@ if(isset($_POST['add_network'])){
$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']));
$location_id = intval($_POST['location']);
mysqli_query($mysqli,"INSERT INTO networks SET network_name = '$name', network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_created_at = NOW(), client_id = $client_id");
mysqli_query($mysqli,"INSERT INTO networks SET network_name = '$name', network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_created_at = NOW(), location_id = $location_id, client_id = $client_id");
$_SESSION['alert_message'] = "Network added";
@ -2465,8 +2466,9 @@ if(isset($_POST['edit_network'])){
$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']));
$location_id = intval($_POST['location']);
mysqli_query($mysqli,"UPDATE networks SET network_name = '$name', network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_updated_at = NOW() WHERE network_id = $network_id");
mysqli_query($mysqli,"UPDATE networks SET network_name = '$name', network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_updated_at = NOW(), location_id = $location_id WHERE network_id = $network_id");
$_SESSION['alert_message'] = "Network updated";