Add move/transfer assets

Add ability to move / transfer assets between clients. Moving an asset involves the asset being archived and then re-created under the new client with most of the same information.

Information about the old & new asset is stored in the audit logs and within the asset notes. Information from the audit logs is accessible via a new History tab on the asset, subject to audit log retention.
This commit is contained in:
wrongecho
2024-08-10 20:46:59 +01:00
parent b732e08aff
commit 3d3492ef27
4 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<div class="modal" id="transferAssetModal<?php echo $asset_id; ?>" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-fw fa-<?php echo $device_icon; ?> mr-2"></i>Transfer asset: <strong><?php echo $asset_name; ?></strong> to a different client</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="current_asset_id" value="<?php echo $asset_id; ?>">
<div class="modal-body bg-white">
<div class="form-group">
<label>New Client <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-users"></i></span>
</div>
<?php $clients_sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_id != $client_id AND client_archived_at IS NULL"); ?>
<select class="form-control select2" name="new_client_id" required>
<?php
while ($row = mysqli_fetch_array($clients_sql)) {
$id = intval($row["client_id"]);
$name = nullable_htmlentities($row["client_name"]);
echo "<option value='$id'>$name</option>";
}
?>
</select>
</div>
</div>
<div class="alert alert-dark" role="alert">
<i>The current asset will be archived and content copied to a new asset.</i>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="change_client_asset" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Transfer</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>