Hide Certain fields on edit asset if Asset type matches criteria

This commit is contained in:
johnnyq 2022-01-21 15:53:27 -05:00
parent 7327802fb6
commit 1f0d62fd00
3 changed files with 20 additions and 15 deletions

View File

@ -2,7 +2,7 @@
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-fw fa-desktop"></i> New Asset</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-desktop"></i> New <?php if(!empty($_GET['type'])){ echo ucwords($_GET['type']); }else{ echo "Asset"; } ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
@ -47,7 +47,7 @@
<input type="text" class="form-control" name="name" placeholder="Name the asset" required autofocus>
</div>
</div>
<?php if($_GET['type'] !== 'virtual' AND $_GET['type'] !== 'servers'){ ?>
<div class="form-group">
<label>Type <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -62,9 +62,9 @@
</select>
</div>
</div>
<?php } ?>
<?php if($_GET['type'] !== 'virtual'){ ?>
<?php //Do not display Make Model or Serial if Virtual is selected
if($_GET['type'] !== 'virtual'){ ?>
<div class="form-group">
<label>Make <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -83,11 +83,8 @@
</div>
<input type="text" class="form-control" name="model" placeholder="Model Number">
</div>
</div>
<?php } ?>
</div>
<?php //Do not display Serial if Virtual is selected
if($_GET['type'] !== 'virtual'){ ?>
<div class="form-group">
<label>Serial Number</label>
<div class="input-group">

View File

@ -66,9 +66,9 @@ if(isset($_GET['o'])){
}
//Asset Type from GET
if(isset($_GET['type']) && ($_GET['type']) == 'workstations'){
if(isset($_GET['type']) && ($_GET['type']) == 'workstation'){
$type_query = "asset_type = 'desktop' OR asset_type = 'laptop'";
}elseif(isset($_GET['type']) && ($_GET['type']) == 'servers'){
}elseif(isset($_GET['type']) && ($_GET['type']) == 'server'){
$type_query = "asset_type = 'server'";
}elseif(isset($_GET['type']) && ($_GET['type']) == 'virtual'){
$type_query = "asset_type = 'Virtual Machine'";
@ -97,7 +97,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-desktop"></i> Assets</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addAssetModal"><i class="fas fa-fw fa-plus"></i> New Asset</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addAssetModal"><i class="fas fa-fw fa-plus"></i> New <?php if(!empty($_GET['type'])){ echo ucwords($_GET['type']); }else{ echo "Asset"; } ?></button>
</div>
</div>
<div class="card-body">
@ -109,7 +109,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<div class="col-md-4">
<div class="input-group mb-3 mb-md-0">
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search">
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search <?php if(!empty($_GET['type'])){ echo ucwords($_GET['type']); }else{ echo "Asset"; } ?>s">
<div class="input-group-append">
<button class="btn btn-dark"><i class="fa fa-search"></i></button>
</div>
@ -117,15 +117,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
</div>
<div class="col-sm-6">
<div class="btn-group btn-group-lg">
<a href="?<?php echo $url_query_strings_sb; ?>&type=%" class="btn <?php if($_GET['type'] == '%' OR empty($_GET['type'])){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>">All Assets <span class="right badge badge-light"><?php echo $all_count; ?></span></a>
<a href="?<?php echo $url_query_strings_sb; ?>&type=" class="btn <?php if($_GET['type'] == '' OR empty($_GET['type'])){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>">All Assets <span class="right badge badge-light"><?php echo $all_count; ?></span></a>
<?php
if($workstation_count > 0){ ?>
<a href="?<?php echo $url_query_strings_sb; ?>&type=workstations" class="btn <?php if($_GET['type'] == 'workstations'){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>"><i class="fa fa-fw fa-desktop"></i> Workstations <span class="right badge badge-light"><?php echo $workstation_count; ?></span></a>
<a href="?<?php echo $url_query_strings_sb; ?>&type=workstation" class="btn <?php if($_GET['type'] == 'workstation'){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>"><i class="fa fa-fw fa-desktop"></i> Workstations <span class="right badge badge-light"><?php echo $workstation_count; ?></span></a>
<?php
} ?>
<?php
if($server_count > 0){ ?>
<a href="?<?php echo $url_query_strings_sb; ?>&type=servers" class="btn <?php if($_GET['type'] == 'servers'){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>"><i class="fa fa-fw fa-server"></i> Servers <span class="right badge badge-light"><?php echo $server_count; ?></span></a>
<a href="?<?php echo $url_query_strings_sb; ?>&type=server" class="btn <?php if($_GET['type'] == 'server'){ echo 'btn-primary'; }else{ echo 'btn-default'; } ?>"><i class="fa fa-fw fa-server"></i> Servers <span class="right badge badge-light"><?php echo $server_count; ?></span></a>
<?php
} ?>
<?php

View File

@ -62,6 +62,8 @@
</div>
</div>
<?php //Do not display Make Model or Serial if Virtual is selected
if($asset_type !== 'virtual'){ ?>
<div class="form-group">
<label>Make <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -91,7 +93,9 @@
<input type="text" class="form-control" name="serial" placeholder="Serial number" value="<?php echo $asset_serial; ?>">
</div>
</div>
<?php } ?>
<?php if($asset_type !== 'Phone' AND $asset_type !== 'Mobile Phone' AND $asset_type !== 'Tablet' AND $asset_type !== 'Firewall/Router' AND $asset_type !== 'Switch' AND $asset_type !== 'Access Point' AND $asset_type !== 'Printer' AND $asset_type !== 'Camera' AND $asset_type !== 'TV' AND $asset_type !== 'Other'){ ?>
<div class="form-group">
<label>Operating System</label>
<div class="input-group">
@ -101,6 +105,7 @@
<input type="text" class="form-control" name="os" placeholder="ex Windows 10 Pro" value="<?php echo $asset_os; ?>">
</div>
</div>
x<?php } ?>
</div>
@ -130,6 +135,7 @@
</div>
</div>
<?php if($asset_type !== 'Firewall/Router' AND $asset_type !== 'Switch' AND $asset_type !== 'Access Point' AND $asset_type !== 'Printer' AND $asset_type !== 'Server' AND $asset_type !== 'Virtual Machine'){ ?>
<div class="form-group">
<label>Assigned To</label>
<div class="input-group">
@ -238,6 +244,7 @@
</div>
</div>
<?php if($asset_type !== 'virtual'){ ?>
<div class="form-group">
<label>Purchase Date</label>
<div class="input-group">
@ -257,6 +264,7 @@
<input type="date" class="form-control" name="warranty_expire" value="<?php echo $asset_warranty_expire; ?>">
</div>
</div>
<?php } ?>
</div>