Fix Contact Notes and Fix a few broken links

This commit is contained in:
johnnyq
2026-07-29 14:22:18 -04:00
parent a900b2cd74
commit af9990ff13
5 changed files with 23 additions and 14 deletions

View File

@@ -142,6 +142,14 @@ if (isset($_GET['contact_id'])) {
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes LEFT JOIN users ON contact_note_created_by = user_id WHERE contact_note_contact_id = $contact_id AND contact_note_archived_at IS NULL ORDER BY contact_note_created_at DESC");
$note_count = mysqli_num_rows($sql_related_notes);
// Note type icons, read from the categories list so the seeded icons
// stay the single source of truth
$note_type_icons = array();
$sql_note_type_icons = mysqli_query($mysqli, "SELECT category_name, category_icon FROM categories WHERE category_type = 'contact_note_type'");
while ($row = mysqli_fetch_assoc($sql_note_type_icons)) {
$note_type_icons[escapeHtml($row['category_name'])] = escapeHtml($row['category_icon']);
}
// Linked Services
$sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_contacts, services
WHERE service_contacts.contact_id = $contact_id
@@ -1104,14 +1112,6 @@ if (isset($_GET['contact_id'])) {
<tbody>
<?php
$note_types_array = array (
'Call'=>'fa-phone-alt',
'Email'=>'fa-envelope',
'Meeting'=>'fa-handshake',
'In Person'=>'fa-people-arrows',
'Note'=>'fa-sticky-note'
);
while ($row = mysqli_fetch_assoc($sql_related_notes)) {
$contact_note_id = intval($row['contact_note_id']);
$contact_note_type = escapeHtml($row['contact_note_type']);
@@ -1120,7 +1120,7 @@ if (isset($_GET['contact_id'])) {
$contact_note_created_at = escapeHtml($row['contact_note_created_at']);
// Get the corresponding icon for the note type
$note_type_icon = isset($note_types_array[$contact_note_type]) ? $note_types_array[$contact_note_type] : 'fa-fw fa-sticky-note'; // default icon if not found
$note_type_icon = !empty($note_type_icons[$contact_note_type]) ? $note_type_icons[$contact_note_type] : 'fa-sticky-note';
?>

View File

@@ -982,7 +982,7 @@ ob_start();
</div>
<div class="modal-footer">
<a href="asset_details.php?client_id=<?= $client_id ?>&asset_id=<?= $asset_id ?>"
<a href="asset.php?client_id=<?= $client_id ?>&asset_id=<?= $asset_id ?>"
class="btn btn-primary text-bold"><span class="text-white"><i class="fas fa-info-circle mr-2"></i>More Details</span>
</a>
<a href="#" class="btn btn-secondary ajax-modal" data-modal-url="modals/asset/asset_edit.php?id=<?= $asset_id ?>">

View File

@@ -139,6 +139,13 @@ $sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes
");
$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 = 'contact_note_type'");
while ($row = mysqli_fetch_assoc($sql_note_type_icons)) {
$note_type_icons[escapeHtml($row['category_name'])] = escapeHtml($row['category_icon']);
}
// Linked Services
$sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_contacts, services
WHERE service_contacts.contact_id = $contact_id
@@ -873,7 +880,7 @@ ob_start();
$note_by = escapeHtml($row['user_name']);
$contact_note_created_at = escapeHtml($row['contact_note_created_at']);
$note_type_icon = isset($note_types_array[$contact_note_type]) ? $note_types_array[$contact_note_type] : 'fa-fw fa-sticky-note';
$note_type_icon = !empty($note_type_icons[$contact_note_type]) ? $note_type_icons[$contact_note_type] : 'fa-sticky-note';
?>
<tr>
<td><i class="fa fa-fw <?= $note_type_icon ?> mr-2"></i><?= $contact_note_type ?></td>
@@ -898,7 +905,7 @@ ob_start();
</div>
<div class="modal-footer">
<a href="contact_details.php?client_id=<?= $client_id ?>&contact_id=<?= $contact_id ?>" class="btn btn-outline-primary">
<a href="contact.php?client_id=<?= $client_id ?>&contact_id=<?= $contact_id ?>" class="btn btn-outline-primary">
<i class="fas fa-info-circle mr-2"></i>Open Full Contact
</a>
<a href="#" class="btn btn-secondary ajax-modal"

View File

@@ -2,9 +2,11 @@
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_client', 2);
$contact_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE contact_id = $contact_id LIMIT 1");
$sql = mysqli_query($mysqli, "SELECT contact_name, contact_client_id FROM contacts WHERE contact_id = $contact_id LIMIT 1");
$row = mysqli_fetch_assoc($sql);
$contact_name = escapeHtml($row['contact_name']);
$client_id = intval($row['contact_client_id']);

View File

@@ -56,7 +56,7 @@
?>
<div class="ml-2">
<a href="asset_details.php?client_id=<?= $client_id ?>&asset_id=<?= $asset_id ?>" target="_blank"><?= $asset_name ?></a>
<a href="asset.php?client_id=<?= $client_id ?>&asset_id=<?= $asset_id ?>" target="_blank"><?= $asset_name ?></a>
<a class="confirm-link float-right" href="post.php?unlink_asset_from_file&asset_id=<?= $asset_id ?>&file_id=<?= $file_id ?>">
<i class="fas fa-fw fa-trash-alt text-secondary"></i>
</a>