Assets and Logins

- Show asset location when relating it to a login
- Bugfix: Swap login_id for asset_id on client_assets.php, as login_id won't yet be defined
- Bugfix: Don't show archived assets in the login relation modal
This commit is contained in:
Marcus Hill
2024-03-17 19:19:59 +00:00
parent 064629d499
commit 6788781ee6
3 changed files with 49 additions and 32 deletions

View File

@@ -184,12 +184,19 @@
<option value="0">- None -</option>
<?php
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets LEFT JOIN locations on asset_location_id = location_id WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
while ($row = mysqli_fetch_array($sql_assets)) {
$asset_id_select = intval($row['asset_id']);
$asset_name_select = nullable_htmlentities($row['asset_name']);
$asset_location_select = nullable_htmlentities($row['location_name']);
$asset_select_display_string = $asset_name_select;
if (!empty($asset_location_select)) {
$asset_select_display_string = "$asset_name_select ($asset_location_select)";
}
?>
<option <?php if ($login_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo $asset_name_select; ?></option>
<option <?php if ($login_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo $asset_select_display_string; ?></option>
<?php } ?>
</select>