mirror of
https://github.com/itflow-org/itflow
synced 2026-08-05 07:07:14 +00:00
Add UI Elements for Asset Notes similar to contact notes
This commit is contained in:
@@ -218,6 +218,22 @@ $sql_related_software = mysqli_query(
|
||||
|
||||
$software_count = mysqli_num_rows($sql_related_software);
|
||||
|
||||
// Related Notes
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM asset_notes
|
||||
LEFT JOIN users ON asset_note_created_by = user_id
|
||||
WHERE asset_note_asset_id = $asset_id
|
||||
AND asset_note_archived_at IS NULL
|
||||
ORDER BY asset_note_created_at DESC"
|
||||
);
|
||||
$note_count = mysqli_num_rows($sql_related_notes);
|
||||
|
||||
// Note type icons, read from the categories list
|
||||
$note_type_icons = array();
|
||||
$sql_note_type_icons = mysqli_query($mysqli, "SELECT category_name, category_icon FROM categories WHERE category_type = 'asset_note_type'");
|
||||
while ($row = mysqli_fetch_assoc($sql_note_type_icons)) {
|
||||
$note_type_icons[escapeHtml($row['category_name'])] = escapeHtml($row['category_icon']);
|
||||
}
|
||||
|
||||
if (isset($_GET['client_id'])) {
|
||||
$client_url = "client_id=$client_id&";
|
||||
} else {
|
||||
@@ -293,6 +309,13 @@ ob_start();
|
||||
<i class="fas fa-fw fa-briefcase mr-2"></i>Files (<?= $file_count ?>)</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if ($note_count) { ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-asset-notes">
|
||||
<i class="fas fa-fw fa-sticky-note mr-2"></i>Notes (<?= $note_count ?>)
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
@@ -913,6 +936,47 @@ ob_start();
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($note_count) { ?>
|
||||
<div class="tab-pane fade" id="pills-asset-notes">
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-sm table-striped table-borderless table-hover">
|
||||
<thead class="text-dark">
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Note</th>
|
||||
<th>By</th>
|
||||
<th>Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_related_notes)) {
|
||||
$asset_note_type = escapeHtml($row['asset_note_type']);
|
||||
$asset_note = nl2br(escapeHtml($row['asset_note']));
|
||||
$note_by = escapeHtml($row['user_name']);
|
||||
$asset_note_created_at = escapeHtml($row['asset_note_created_at']);
|
||||
|
||||
$note_type_icon = !empty($note_type_icons[$asset_note_type]) ? $note_type_icons[$asset_note_type] : 'fa-sticky-note';
|
||||
?>
|
||||
<tr>
|
||||
<td><i class="fa fa-fw <?= $note_type_icon ?> mr-2"></i><?= $asset_note_type ?></td>
|
||||
<td><?= $asset_note ?></td>
|
||||
<td><?= $note_by ?></td>
|
||||
<td><?= $asset_note_created_at ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
70
agent/modals/asset/asset_note_add.php
Normal file
70
agent/modals/asset/asset_note_add.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$asset_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_name, asset_client_id FROM assets WHERE asset_id = $asset_id LIMIT 1");
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$asset_name = escapeHtml($row['asset_name']);
|
||||
$client_id = intval($row['asset_client_id']);
|
||||
|
||||
enforceClientAccess();
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class='fa fa-fw fa-sticky-note mr-2'></i>Creating note: <strong><?= $asset_name ?></strong></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="asset_id" value="<?= $asset_id ?>">
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Type</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="type">
|
||||
<?php
|
||||
$sql_asset_note_types_select = mysqli_query($mysqli, "
|
||||
SELECT category_name FROM categories
|
||||
WHERE category_type = 'asset_note_type'
|
||||
AND category_archived_at IS NULL
|
||||
ORDER BY category_order ASC, category_name ASC
|
||||
");
|
||||
while ($row = mysqli_fetch_assoc($sql_asset_note_types_select)) {
|
||||
$asset_note_type_select = escapeHtml($row['category_name']);
|
||||
?>
|
||||
<option><?= $asset_note_type_select ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" rows="6" name="note" placeholder="Notes, eg what was done, parts replaced, config changed, etc"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="submit" name="add_asset_note" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Create</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
Reference in New Issue
Block a user