From c3751cde81892362e3d79aaeb8cd1c535e9ed446 Mon Sep 17 00:00:00 2001 From: BigTigerKU Date: Sun, 15 Sep 2024 23:08:41 -0700 Subject: [PATCH] Make Person List Columns Configurable --- src/ChurchCRM/dto/ListColumn.php | 21 +++++++ src/ChurchCRM/dto/SystemConfig.php | 22 ++++++- src/v2/templates/people/person-list.php | 81 +++++++++++-------------- 3 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 src/ChurchCRM/dto/ListColumn.php diff --git a/src/ChurchCRM/dto/ListColumn.php b/src/ChurchCRM/dto/ListColumn.php new file mode 100644 index 0000000000..2ec228d680 --- /dev/null +++ b/src/ChurchCRM/dto/ListColumn.php @@ -0,0 +1,21 @@ +name = $name; + $this->function = $function; + $this->emptyOrUnassigned = $emptyOrUnassigned; + $this->visible = $visible; + } +} diff --git a/src/ChurchCRM/dto/SystemConfig.php b/src/ChurchCRM/dto/SystemConfig.php index b7a2dfb1b6..efafb43d41 100644 --- a/src/ChurchCRM/dto/SystemConfig.php +++ b/src/ChurchCRM/dto/SystemConfig.php @@ -91,6 +91,25 @@ public static function getInitialStyleChoices(): array ]; } + public static function getPersonListColumns(): array + { + return [ + 'Id' => new ListColumn('Id', 'getId', false, false), + 'Family Name' => new ListColumn('Family Name', 'getFamilyName', false, false), + 'Name' => new ListColumn('Name', 'getFullName', false, false), + 'Last Name' => new ListColumn('Last Name', 'getLastName', false, true), + 'First Name' => new ListColumn('First Name', 'getFirstName', false, true), + 'Birth Date' => new ListColumn('Birth Date', 'getFormattedBirthDate', false, false), + 'Address' => new ListColumn('Address', 'getAddress', false, false), + 'Home Phone' => new ListColumn('Home Phone', 'getHomePhone', false, true), + 'Cell Phone' => new ListColumn('Cell Phone', 'getCellPhone', false, true), + 'Email' => new ListColumn('Email', 'getEmail', false, true), + 'Gender' => new ListColumn('Gender', 'getGenderName', true, true), + 'Classification' => new ListColumn('Classification', 'getClassificationName', true, true), + 'Roles' => new ListColumn('Roles', 'getFamilyRoleName', true, true), + ]; + } + private static function buildConfigs(): array { return [ @@ -279,6 +298,7 @@ private static function buildConfigs(): array 'sGoogleMapsRenderKey' => new ConfigItem(2072, 'sGoogleMapsRenderKey', 'text', '', gettext('Google Maps API Key used for rendering maps in browser'), 'https://developers.google.com/maps/documentation/javascript/get-api-key'), 'sInactiveClassification' => new ConfigItem(2073, 'sInactiveClassification', 'text', '', gettext('Comma separated list of classifications that should appear as inactive')), 'sDefaultZip' => new ConfigItem(2074, 'sDefaultZip', 'text', '', gettext('Default Zip')), + 'sPersonListColumns' => new ConfigItem(2075, 'sPersonListColumns', 'json', json_encode(SystemConfig::getPersonListColumns()), gettext('Person List Columns')), ]; } @@ -288,7 +308,7 @@ private static function buildCategories(): array gettext('Church Information') => ['sChurchName', 'sChurchAddress', 'sChurchCity', 'sChurchState', 'sChurchZip', 'sChurchCountry', 'sChurchPhone', 'sChurchEmail', 'sHomeAreaCode', 'sTimeZone', 'iChurchLatitude', 'iChurchLongitude', 'sChurchWebSite', 'sChurchFB', 'sChurchTwitter'], gettext('User Setup') => ['iMinPasswordLength', 'iMinPasswordChange', 'iMaxFailedLogins', 'iSessionTimeout', 'aDisallowedPasswords', 'bEnableLostPassword', 'bEnable2FA', 'bRequire2FA', 's2FAApplicationName', 'bSendUserDeletedEmail'], gettext('Email Setup') => ['sSMTPHost', 'bSMTPAuth', 'sSMTPUser', 'sSMTPPass', 'iSMTPTimeout', 'sToEmailAddress', 'bPHPMailerAutoTLS', 'sPHPMailerSMTPSecure'], - gettext('People Setup') => ['sDirClassifications', 'sDirRoleHead', 'sDirRoleSpouse', 'sDirRoleChild', 'sDefaultCity', 'sDefaultState', 'sDefaultZip', 'sDefaultCountry', 'bShowFamilyData', 'bHidePersonAddress', 'bHideFriendDate', 'bHideFamilyNewsletter', 'bHideWeddingDate', 'bHideLatLon', 'bForceUppercaseZip', 'bEnableSelfRegistration', 'bAllowEmptyLastName', 'iPersonNameStyle', 'iPersonInitialStyle', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2', 'sInactiveClassification'], + gettext('People Setup') => ['sDirClassifications', 'sDirRoleHead', 'sDirRoleSpouse', 'sDirRoleChild', 'sDefaultCity', 'sDefaultState', 'sDefaultZip', 'sDefaultCountry', 'bShowFamilyData', 'bHidePersonAddress', 'bHideFriendDate', 'bHideFamilyNewsletter', 'bHideWeddingDate', 'bHideLatLon', 'bForceUppercaseZip', 'bEnableSelfRegistration', 'bAllowEmptyLastName', 'iPersonNameStyle', 'iPersonInitialStyle', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2', 'sInactiveClassification', 'sPersonListColumns'], gettext('Enabled Features') => ['bEnabledFinance', 'bEnabledSundaySchool', 'bEnabledEvents', 'bEnabledCalendar', 'bEnabledFundraiser', 'bEnabledEmail', 'bEnabledMenuLinks'], gettext('Map Settings') => ['sGeoCoderProvider', 'sGoogleMapsGeocodeKey', 'sGoogleMapsRenderKey', 'sBingMapKey', 'sGMapIcons', 'iMapZoom'], gettext('Report Settings') => ['sQBDTSettings', 'leftX', 'incrementY', 'sTaxReport1', 'sTaxReport2', 'sTaxReport3', 'sTaxSigner', 'sReminder1', 'sReminderSigner', 'sReminderNoPledge', 'sReminderNoPayments', 'sConfirm1', 'sConfirm2', 'sConfirm3', 'sConfirm4', 'sConfirm5', 'sConfirm6', 'sDear', 'sConfirmSincerely', 'sConfirmSigner', 'sPledgeSummary1', 'sPledgeSummary2', 'sDirectoryDisclaimer1', 'sDirectoryDisclaimer2', 'bDirLetterHead', 'sZeroGivers', 'sZeroGivers2', 'sZeroGivers3', 'iPDFOutputType'], diff --git a/src/v2/templates/people/person-list.php b/src/v2/templates/people/person-list.php index 9ff520b337..3edc56b237 100644 --- a/src/v2/templates/people/person-list.php +++ b/src/v2/templates/people/person-list.php @@ -158,16 +158,22 @@ function emptyOrUnassignedJSON($stuff): string - getId() ?> - getLastName()?> - getFirstName()?> - getAddress() ?> - getHomePhone() ?> - getCellPhone() ?> - getEmail() ?> - getGenderName()) ?> - getClassificationName()) ?> - getFamilyRoleName()) ?> + + $columnValue) { + echo ''; + if ($columnValue->visible === "true") { + $columnData = [$person, $columnValue->function](); + if ($columnValue->emptyOrUnassigned == 1) { + echo emptyOrUnassigned($columnData); + } else { + echo $columnData; + } + } + echo ''; + } + ?> getPropertiesString()) ?> getCustomFields($allPersonCustomFields, $CustomMapping, $CustomList, $option_name)) ?> getGroups()) ?> @@ -201,8 +207,6 @@ function emptyOrUnassignedJSON($stuff): string // setup datatables 'use strict'; - var bVisible = parseInt(""); - let dataTableConfig = { deferRender: true, search: { regex: true }, @@ -210,38 +214,23 @@ function emptyOrUnassignedJSON($stuff): string { title:i18next.t('Actions'), }, - { - title:i18next.t('Id'), - visible:false - }, - { - title:i18next.t('Last Name'), - }, - { - title:i18next.t('First Name'), - }, - { - title:i18next.t('Address'), - visible:bVisible - }, - { - title:i18next.t('Home Phone'), - }, - { - title:i18next.t('Cell Phone'), - }, - { - title:i18next.t('Email'), - }, - { - title:i18next.t('Gender'), - }, - { - title:i18next.t('Classification'), - }, - { - title:i18next.t('Roles'), - }, + $columnValue) { + $columnId++; + echo '{ title:i18next.t(\'' . $columnValue->name . '\'), '; + if ($columnValue->visible === "false") { + echo 'visible:false'; + } else { + if ($firstVisibleColumnId > $columnId) { + $firstVisibleColumnId = $columnId; + } + } + echo '},' . "\n"; + } + ?> { title:i18next.t('Properties'), visible:false @@ -255,8 +244,8 @@ function emptyOrUnassignedJSON($stuff): string visible:false } ], - // sortby name - order: [[ 2, "asc" ]] + // sort by first visible column + order: [[ , "asc" ]] } $.extend(dataTableConfig, window.CRM.plugin.dataTable);