itflow/client_assets.php

150 lines
6.3 KiB
PHP

<?php $sql = mysqli_query($mysqli,"SELECT * FROM assets WHERE client_id = $client_id ORDER BY asset_id DESC"); ?>
<div class="card">
<div class="card-header">
<h6 class="float-left mt-1"><i class="fa fa-laptop"></i> Assets</h6>
<button class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addAssetModal"><i class="fa fa-plus"></i></button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>IP</th>
<th>Make</th>
<th>Model</th>
<th>Serial</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql)){
$asset_id = $row['asset_id'];
$asset_type = $row['asset_type'];
$asset_name = $row['asset_name'];
$asset_make = $row['asset_make'];
$asset_model = $row['asset_model'];
$asset_serial = $row['asset_serial'];
$asset_ip = $row['asset_ip'];
$asset_purchase_date = $row['asset_purchase_date'];
$asset_warranty_expire = $row['asset_warranty_expire'];
$vendor_id = $row['vendor_id'];
$location_id = $row['location_id'];
$contact_id = $row['contact_id'];
$network_id = $row['network_id'];
if($asset_type == 'Laptop'){
$device_icon = "laptop";
}elseif($asset_type == 'Desktop'){
$device_icon = "desktop";
}elseif($asset_type == 'Server'){
$device_icon = "server";
}elseif($asset_type == 'Printer'){
$device_icon = "print";
}elseif($asset_type == 'Camera'){
$device_icon = "video";
}elseif($asset_type == 'Switch' or $asset_type == 'Firewall/Router'){
$device_icon = "network-wired";
}elseif($asset_type == 'Access Point'){
$device_icon = "wifi";
}elseif($asset_type == 'Phone'){
$device_icon = "phone";
}elseif($asset_type == 'Mobile Phone'){
$device_icon = "mobile-alt";
}elseif($asset_type == 'Tablet'){
$device_icon = "tablet-alt";
}elseif($asset_type == 'TV'){
$device_icon = "tv";
}elseif($asset_type == 'Virtual Machine'){
$device_icon = "cloud";
}else{
$device_icon = "tag";
}
$sql_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE asset_id = $asset_id");
$row = mysqli_fetch_array($sql_logins);
$login_id = $row['login_id'];
$login_username = $row['login_username'];
$login_password = $row['login_password'];
$asset_id_relation = $row['asset_id'];
?>
<tr>
<td><i class="fa fa-fw text-secondary fa-<?php echo $device_icon; ?> mr-3"></i><?php echo $asset_type; ?></td>
<td>
<?php
if($asset_id == $asset_id_relation){
?>
<button type="button" class="btn btn-link btn-sm" data-toggle="modal" data-target="#viewPasswordModal<?php echo $login_id; ?>"><i class="fas fa-key text-dark"></i></button>
<div class="modal" id="viewPasswordModal<?php echo $login_id; ?>" tabindex="-1">
<div class="modal-dialog modal-sm">
<div class="modal-content bg-dark">
<div class="modal-header text-white">
<h5 class="modal-title"><i class="fa fa-fw fa-key mr-2"></i><?php echo $asset_name; ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body bg-white">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-user"></i></span>
</div>
<input type="text" class="form-control" value="<?php echo $login_username; ?>" readonly>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-lock"></i></span>
</div>
<input type="text" class="form-control" value="<?php echo $login_password; ?>" readonly>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
echo $asset_name;
?>
</td>
<td><?php echo $asset_ip; ?></td>
<td><?php echo $asset_make; ?></td>
<td><?php echo $asset_model; ?></td>
<td><?php echo $asset_serial; ?></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="#editAssetModal<?php echo $asset_id; ?>">Edit</a>
<a class="dropdown-item" href="post.php?delete_asset=<?php echo $asset_id; ?>">Delete</a>
</div>
</div>
<?php include("edit_asset_modal.php"); ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include("add_asset_modal.php"); ?>