From 234afd25fb8ba9f6a96e28ee27a7fb55bec3a582 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 14 Oct 2026 18:33:18 -0400 Subject: [PATCH] Contacts overhaul: rebuilt contacts list with role tabs and counts, avatars, flag pills, hover copy on phone/mobile/email, inline location picker, linked asset/credential/license/ticket chips and tag filter; contact page rebuilt to match the asset page with header actions, Reach/Details/Quick notes cards and tabbed Assets, Credentials, Tickets, Recurring, Licenses, Documents, Files, Services and Notes; add and edit contact share one tabbed form (Details, Roles, Access, Notes) with field icons, role switches, password generator, duplicate email check and photo removal; contact quick look redone to match the asset quick look; contact avatars now used everywhere a contact appears - contact pickers, ticket header, contact card, client replies, ticket list, kanban, assets, clients list, client header, overview key contacts, credentials, documents, services, invoice/quote/statement recipients, license users and global search - with each contact keeping the same colour throughout; ticket contact pickers show the name with title and role underneath; fixes: permission checks on the add contact modal and contact page/list actions, contact location limited to the contact's own client on add/edit/bulk assign, contacts list no longer selects user account columns, archived assets and credentials left off the contact page and quick look, saving a contact with the client portal disabled no longer clears their portal login method, replacing a photo no longer tries to delete a directory, sort column whitelisted, list counts and tags batched instead of per row, recurring ticket menu markup, undefined index notices, contacts list no longer scrolls sideways on phones, Edit Service shows avatars on unselected contacts and assets, license user labels toggle their checkbox; new functions/contact.php helpers (contactAvatar, contactLink, contactFlagPills, contactPhoneLink, contactAvatarData, contactOptionDescription), shared contact_form.php, contact_location quick pick, removed unused assetContactAvatar and clientOverviewPersonInitials --- agent/ajax.php | 46 +- agent/asset.php | 2 +- agent/assets.php | 4 +- agent/client_overview.php | 12 +- agent/clients.php | 6 +- agent/contact.php | 1953 ++++++++--------- agent/contacts.php | 645 +++--- agent/credentials.php | 7 +- agent/document.php | 12 +- agent/global_search.php | 9 + agent/includes/client_details.php | 4 +- agent/includes/inc_all_client.php | 3 +- agent/js/ticket_change_client.js | 18 +- agent/js/tickets_add_modal.js | 5 +- .../asset/asset_bulk_assign_contact.php | 2 +- agent/modals/asset/asset_form.php | 270 ++- agent/modals/client/client_statement.php | 29 +- agent/modals/contact/contact.php | 1174 ++++------ agent/modals/contact/contact_add.php | 334 +-- agent/modals/contact/contact_edit.php | 341 +-- agent/modals/contact/contact_form.php | 335 +++ agent/modals/credential/credential_add.php | 2 +- agent/modals/credential/credential_edit.php | 2 +- .../modals/document/document_link_contact.php | 2 +- agent/modals/invoice/invoice_email.php | 29 +- agent/modals/location/location_add.php | 2 +- agent/modals/location/location_edit.php | 2 +- agent/modals/quote/quote_email.php | 37 +- .../recurring_ticket_edit.php | 20 +- agent/modals/service/service.php | 9 +- agent/modals/service/service_add.php | 2 +- agent/modals/service/service_edit.php | 16 +- agent/modals/share_modal.php | 2 +- agent/modals/software/software_add.php | 9 +- agent/modals/software/software_edit.php | 9 +- agent/modals/ticket/ticket_add_watcher.php | 2 +- agent/modals/ticket/ticket_contact.php | 22 +- agent/modals/ticket/ticket_edit.php | 20 +- agent/post/contact.php | 73 +- agent/post/contact_model.php | 28 +- agent/ticket.php | 26 +- agent/ticket_kanban.php | 9 +- agent/ticket_list.php | 2 +- agent/tickets.php | 2 +- css/itflow_custom.css | 121 +- functions.php | 1 + functions/asset.php | 58 +- functions/client_overview.php | 9 - functions/contact.php | 190 ++ functions/format.php | 10 +- functions/search.php | 4 +- functions/ticket_fields.php | 3 +- js/global_search.js | 24 +- js/itflow_select.js | 10 +- js/quick_pick.js | 22 +- 55 files changed, 2795 insertions(+), 3195 deletions(-) create mode 100644 agent/modals/contact/contact_form.php create mode 100644 functions/contact.php diff --git a/agent/ajax.php b/agent/ajax.php index 8cd109b15..8eb50f044 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -189,7 +189,8 @@ if (isset($_POST['tag_picker_set']) || isset($_POST['tag_picker_create'])) { if (isset($_GET['quick_pick_options'])) { header('Content-Type: application/json'); - enforceUserPermission('module_support', 2); + // A contact's location is the clients module's; everything else here is support's + enforceUserPermission(($_GET['field'] ?? '') === 'contact_location' ? 'module_client' : 'module_support', 2); $field = (string) ($_GET['field'] ?? ''); $options = []; @@ -210,9 +211,9 @@ if (isset($_GET['quick_pick_options'])) { $options = quickPickAgents(); } elseif ($field === 'project_manager') { $options = quickPickAgents('No manager'); - } elseif (in_array($field, ASSET_QUICK_FIELDS, true)) { - // Locations and contacts are the asset's client's own - functions/asset.php - $options = assetQuickOptions($field, intval($_GET['scope'] ?? 0)); + } elseif (in_array($field, ASSET_QUICK_FIELDS, true) || $field === 'contact_location') { + // Locations and contacts are the client's own - functions/asset.php + $options = assetQuickOptions($field === 'contact_location' ? 'asset_location' : $field, intval($_GET['scope'] ?? 0)); if ($options === null) { http_response_code(403); echo json_encode(['error' => 'You cannot see that client.']); @@ -272,6 +273,40 @@ if (isset($_POST['quick_pick_set'])) { exit(); } + // A contact's location - contacts of clients this agent can reach, with + // the same permission as Edit Contact (functions/contact.php) + if ($field === 'contact_location') { + $contact_ids = $ticket_ids; + $allowed = lookupUserPermission('module_client') >= 2 && $contact_ids; + foreach ($allowed ? $contact_ids : [] as $id) { + $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_client_id FROM contacts WHERE contact_id = $id")); + if (!$row || !hasClientAccess($row['contact_client_id'])) { + $allowed = false; + break; + } + } + if (!$allowed) { + http_response_code(403); + echo json_encode(['error' => 'You cannot change that on these contacts.']); + exit(); + } + + $message = ''; + $response = ['records' => []]; + foreach ($contact_ids as $id) { + [$ok, $message] = contactQuickSetLocation($id, $value); + if (!$ok) { + http_response_code(422); + echo json_encode(['error' => $message]); + exit(); + } + $response['records'][$id] = contactQuickRecord($id); + } + $response['message'] = count($contact_ids) === 1 ? $message : 'Updated ' . count($contact_ids) . ' contacts'; + echo json_encode($response); + exit(); + } + // A project's manager or a recurring ticket's assignee - open projects // and recurring tickets of clients this agent can reach, like their edit modals if ($field === 'project_manager' || $field === 'recurring_assignee') { @@ -923,8 +958,9 @@ if (isset($_GET['get_client_contacts'])) { $response['contacts'] = []; while ($row = mysqli_fetch_assoc($contact_sql)) { - // For the picker: initials, or the photo when there is one + // For the picker: initials on their own colour, or the photo when there is one $row['contact_initials'] = personInitials($row['contact_name']); + $row['contact_tone'] = contactAvatarTone($row['contact_id']); $row['contact_photo_url'] = $row['contact_photo'] ? "/uploads/clients/$client_id/" . rawurlencode($row['contact_photo']) : ''; unset($row['contact_photo']); $response['contacts'][] = $row; diff --git a/agent/asset.php b/agent/asset.php index ba5a23569..386e30821 100644 --- a/agent/asset.php +++ b/agent/asset.php @@ -532,7 +532,7 @@ if (mysqli_num_rows($sql) == 0) { - > + true, 'archived' => $contact_archived]) ?> Nobody diff --git a/agent/assets.php b/agent/assets.php index cc065f066..9cbcad4a5 100644 --- a/agent/assets.php +++ b/agent/assets.php @@ -354,7 +354,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
+ class="btn " title=""> Archived