From 9ac92c1289eb807ac1235a27deae02efea024866 Mon Sep 17 00:00:00 2001 From: Tiago Rodrigues Date: Wed, 14 Feb 2024 09:52:32 +0000 Subject: [PATCH 1/5] Inactive people by class --- ...dard.people.filterbyclassification.spec.js | 82 +++++++++++++++++++ src/ChurchCRM/dto/SystemConfig.php | 5 +- src/OptionManager.php | 21 ++++- src/OptionManagerRowOps.php | 17 ++++ src/v2/routes/people.php | 17 +++- 5 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js diff --git a/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js new file mode 100644 index 0000000000..b557e22e62 --- /dev/null +++ b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js @@ -0,0 +1,82 @@ +describe('template spec', () => { + it('filter-by-classification', () => { + cy.loginAdmin("OptionManager.php?mode=classes"); + cy.get("#inactive4").uncheck(); + cy.get("#inactive5").uncheck(); + cy.reload(); + cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive4").check(); + cy.reload(); + cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('be.checked'); + cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive5").check(); + cy.reload(); + cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('be.checked'); + cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('be.checked'); + cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive4").uncheck(); + cy.get("#inactive5").uncheck(); + cy.reload(); + cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + + }) + +}) + + diff --git a/src/ChurchCRM/dto/SystemConfig.php b/src/ChurchCRM/dto/SystemConfig.php index 14c075f392..53fb5140e7 100644 --- a/src/ChurchCRM/dto/SystemConfig.php +++ b/src/ChurchCRM/dto/SystemConfig.php @@ -265,8 +265,9 @@ private static function buildConfigs(): array 's2FAApplicationName' => new ConfigItem(2070, 's2FAApplicationName', 'text', gettext('ChurchCRM'), gettext('Specify the application name to be displayed in authenticator app')), 'bSendUserDeletedEmail' => new ConfigItem(2071, 'bSendUserDeletedEmail', 'boolean', '0', gettext('Send an email notifying users when their account has been deleted')), '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')), - ]; + ]; } private static function buildCategories(): array @@ -275,7 +276,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', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2'], + gettext('People Setup') => ['sDirClassifications', 'sDirRoleHead', 'sDirRoleSpouse', 'sDirRoleChild', 'sDefaultCity', 'sDefaultState', 'sDefaultZip', 'sDefaultCountry', 'bShowFamilyData', 'bHidePersonAddress', 'bHideFriendDate', 'bHideFamilyNewsletter', 'bHideWeddingDate', 'bHideLatLon', 'bForceUppercaseZip', 'bEnableSelfRegistration', 'bAllowEmptyLastName', 'iPersonNameStyle', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2', 'sInactiveClasification'], 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/OptionManager.php b/src/OptionManager.php index 51fc2fa6db..ea7c46fbec 100644 --- a/src/OptionManager.php +++ b/src/OptionManager.php @@ -16,6 +16,7 @@ require 'Include/Config.php'; require 'Include/Functions.php'; +use ChurchCRM\dto\SystemConfig; use ChurchCRM\Authentication\AuthenticationManager; use ChurchCRM\model\ChurchCRM\ListOption; use ChurchCRM\Utils\InputUtils; @@ -312,7 +313,13 @@
+ is_numeric($k)); + + for ($row = 1; $row <= $numRows; $row++) { ?> @@ -337,7 +344,9 @@ } if ($numRows > 0) { echo "'; - } ?> + } + ?> + "; - } ?> + } + if ($mode === 'classes') { + echo ""; + } + ?> is_numeric($k)); + + if (in_array($iID, $inactive_classes)) { + unset($inactive_classes[array_search($iID, $inactive_classes)]); + } else { + $inactive_classes[] = $iID; + } + + $inactive_classes_str = implode(',', $inactive_classes); + SystemConfig::setValue('sInactiveClassification', $inactive_classes_str); + + break; // If no valid action was specified, abort default: RedirectUtils::redirect('v2/dashboard'); diff --git a/src/v2/routes/people.php b/src/v2/routes/people.php index cbc9b47560..4acb9e8b62 100644 --- a/src/v2/routes/people.php +++ b/src/v2/routes/people.php @@ -1,6 +1,7 @@ is_numeric($k)); + $inactive_classes_str = implode(",", $inactive_classes); + if ($familyActiveStatus === 'active') { - $members->leftJoinFamily()->where('family_fam.fam_DateDeactivated is null'); + $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is null) and (per_cls_id not in (' . $inactive_classes_str . ') )'); } elseif ($familyActiveStatus === 'inactive') { - $members->leftJoinFamily()->where('family_fam.fam_DateDeactivated is not null'); + $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is not null) or (per_cls_id in (' . $inactive_classes_str . ') )'); } $members->find(); From 1c15f2891c960fa261c95f71020de50738c28dd0 Mon Sep 17 00:00:00 2001 From: Robert Spencer Date: Tue, 7 May 2024 14:15:18 +0200 Subject: [PATCH 2/5] Apply suggestions from code review --- ...dard.people.filterbyclassification.spec.js | 49 +++++++++---------- src/ChurchCRM/dto/SystemConfig.php | 4 +- src/OptionManager.php | 22 ++++----- src/OptionManagerRowOps.php | 21 ++++---- src/v2/routes/people.php | 24 +++++---- 5 files changed, 62 insertions(+), 58 deletions(-) diff --git a/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js index b557e22e62..9f7a255751 100644 --- a/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js +++ b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js @@ -4,11 +4,11 @@ describe('template spec', () => { cy.get("#inactive4").uncheck(); cy.get("#inactive5").uncheck(); cy.reload(); - cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("#inactive1").should('not.be.checked'); + cy.get("#inactive2").should('not.be.checked'); + cy.get("#inactive3").should('not.be.checked'); + cy.get("#inactive4").should('not.be.checked'); + cy.get("#inactive5").should('not.be.checked'); cy.visit("v2/people?familyActiveStatus=inactive"); cy.get("#members_filter input").type("edwin.adams@example.com"); @@ -22,15 +22,14 @@ describe('template spec', () => { cy.get("#members_filter input").type("edwin.adams@example.com"); cy.contains("(564)-714-4633"); - cy.visit("OptionManager.php?mode=classes"); cy.get("#inactive4").check(); cy.reload(); - cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('be.checked'); - cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("#inactive1").should('not.be.checked'); + cy.get("#inactive2").should('not.be.checked'); + cy.get("#inactive3").should('not.be.checked'); + cy.get("#inactive4").should('be.checked'); + cy.get("#inactive5").should('not.be.checked'); cy.visit("v2/people?familyActiveStatus=inactive"); cy.get("#members_filter input").type("edwin.adams@example.com"); @@ -47,11 +46,11 @@ describe('template spec', () => { cy.visit("OptionManager.php?mode=classes"); cy.get("#inactive5").check(); cy.reload(); - cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('be.checked'); - cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('be.checked'); - cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); + cy.get("#inactive1").should('not.be.checked'); + cy.get("#inactive2").should('not.be.checked'); + cy.get("#inactive3").should('not.be.checked'); + cy.get("#inactive4").should('be.checked'); + cy.get("#inactive5").should('be.checked'); cy.visit("v2/people?familyActiveStatus=inactive"); cy.get("#members_filter input").type("edwin.adams@example.com"); @@ -69,14 +68,10 @@ describe('template spec', () => { cy.get("#inactive4").uncheck(); cy.get("#inactive5").uncheck(); cy.reload(); - cy.get("tr:nth-child(5) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(1) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(2) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(3) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - cy.get("tr:nth-child(4) .TextColumn~ .TextColumn+ td input").should('not.be.checked'); - - }) - -}) - - + cy.get("#inactive1").should('not.be.checked'); + cy.get("#inactive2").should('not.be.checked'); + cy.get("#inactive3").should('not.be.checked'); + cy.get("#inactive4").should('not.be.checked'); + cy.get("#inactive5").should('not.be.checked'); + }); +}); diff --git a/src/ChurchCRM/dto/SystemConfig.php b/src/ChurchCRM/dto/SystemConfig.php index 53fb5140e7..05dbcfaa62 100644 --- a/src/ChurchCRM/dto/SystemConfig.php +++ b/src/ChurchCRM/dto/SystemConfig.php @@ -267,7 +267,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')), - ]; + ]; } private static function buildCategories(): array @@ -276,7 +276,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', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2', 'sInactiveClasification'], + gettext('People Setup') => ['sDirClassifications', 'sDirRoleHead', 'sDirRoleSpouse', 'sDirRoleChild', 'sDefaultCity', 'sDefaultState', 'sDefaultZip', 'sDefaultCountry', 'bShowFamilyData', 'bHidePersonAddress', 'bHideFriendDate', 'bHideFamilyNewsletter', 'bHideWeddingDate', 'bHideLatLon', 'bForceUppercaseZip', 'bEnableSelfRegistration', 'bAllowEmptyLastName', 'iPersonNameStyle', 'iProfilePictureListSize', 'sNewPersonNotificationRecipientIDs', 'IncludeDataInNewPersonNotifications', 'sGreeterCustomMsg1', 'sGreeterCustomMsg2', 'sInactiveClassification'], 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/OptionManager.php b/src/OptionManager.php index ea7c46fbec..ffdb1fe3cc 100644 --- a/src/OptionManager.php +++ b/src/OptionManager.php @@ -16,10 +16,11 @@ require 'Include/Config.php'; require 'Include/Functions.php'; -use ChurchCRM\dto\SystemConfig; use ChurchCRM\Authentication\AuthenticationManager; +use ChurchCRM\dto\SystemConfig; use ChurchCRM\model\ChurchCRM\ListOption; use ChurchCRM\Utils\InputUtils; +use ChurchCRM\Utils\LoggerUtils; use ChurchCRM\Utils\RedirectUtils; $mode = trim($_GET['mode']); @@ -313,12 +314,13 @@
@@ -354,7 +363,15 @@ "; + $check = in_array($aIDs[$row], $inactive_classes) ? "checked" : ""; + echo ""; + echo gettext("Inactive"); + echo "
- is_numeric($k)); + $aInactiveClassificationIds = explode(',', SystemConfig::getValue('sInactiveClassification')); + $aInactiveClasses = array_filter($aInactiveClassificationIds, fn ($k) => is_numeric($k)); + if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { + LoggerUtils::getAppLogger()->warning('Encountered invalid configuration(s) for sInactiveClassification, please fix this'); + } for ($row = 1; $row <= $numRows; $row++) { ?> @@ -344,9 +346,8 @@ } if ($numRows > 0) { echo "'; - } - ?> - + } ?> + "; - } - ?> + } ?> is_numeric($k)); - $inactive_classes = array_filter($str_arr, fn ($k) => is_numeric($k)); + if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { + LoggerUtils::getAppLogger()->warning('Encountered invalid configuration(s) for sInactiveClassification, please fix this'); + } - if (in_array($iID, $inactive_classes)) { - unset($inactive_classes[array_search($iID, $inactive_classes)]); + if (in_array($iID, $aInactiveClasses)) { + unset($aInactiveClasses[array_search($iID, $aInactiveClasses)]); } else { - $inactive_classes[] = $iID; + $aInactiveClasses[] = $iID; } - $inactive_classes_str = implode(',', $inactive_classes); - SystemConfig::setValue('sInactiveClassification', $inactive_classes_str); + $sInactiveClasses = implode(',', $aInactiveClasses); + SystemConfig::setValue('sInactiveClassification', $sInactiveClasses); break; // If no valid action was specified, abort diff --git a/src/v2/routes/people.php b/src/v2/routes/people.php index 4acb9e8b62..0f4fb5025c 100644 --- a/src/v2/routes/people.php +++ b/src/v2/routes/people.php @@ -1,10 +1,11 @@ is_numeric($k)); - $inactive_classes_str = implode(",", $inactive_classes); + $aInactiveClassificationIds = explode(',', $sInactiveClassificationIds); + $aInactiveClasses = array_filter($aInactiveClassificationIds, fn ($k) => is_numeric($k)); + + if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { + LoggerUtils::getAppLogger()->warning('Encountered invalid configuration(s) for sInactiveClassification, please fix this'); + } + + $sInactiveClasses = implode(',', $aInactiveClasses); if ($familyActiveStatus === 'active') { - $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is null) and (per_cls_id not in (' . $inactive_classes_str . ') )'); + $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is null) and (per_cls_id not in (' . $sInactiveClasses . ') )'); } elseif ($familyActiveStatus === 'inactive') { - $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is not null) or (per_cls_id in (' . $inactive_classes_str . ') )'); + $members->leftJoinFamily()->where('(family_fam.fam_DateDeactivated is not null) or (per_cls_id in (' . $sInactiveClasses . ') )'); } $members->find(); From a4a4a3b48cba255c00ca394d3e01e3047b1651cc Mon Sep 17 00:00:00 2001 From: George Dawoud Date: Tue, 7 May 2024 18:04:00 +0000 Subject: [PATCH 3/5] Apply fixes from StyleCI --- src/OptionManagerRowOps.php | 2 +- src/v2/routes/people.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OptionManagerRowOps.php b/src/OptionManagerRowOps.php index 8b1c27ae8e..67fe654286 100644 --- a/src/OptionManagerRowOps.php +++ b/src/OptionManagerRowOps.php @@ -155,7 +155,7 @@ $aInactiveClassificationIds = explode(',', SystemConfig::getValue('sInactiveClassification')); $aInactiveClasses = array_filter($aInactiveClassificationIds, fn ($k) => is_numeric($k)); - if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { + if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { LoggerUtils::getAppLogger()->warning('Encountered invalid configuration(s) for sInactiveClassification, please fix this'); } diff --git a/src/v2/routes/people.php b/src/v2/routes/people.php index 0f4fb5025c..f674f50380 100644 --- a/src/v2/routes/people.php +++ b/src/v2/routes/people.php @@ -71,7 +71,7 @@ function listPeople(Request $request, Response $response, array $args): Response $aInactiveClassificationIds = explode(',', $sInactiveClassificationIds); $aInactiveClasses = array_filter($aInactiveClassificationIds, fn ($k) => is_numeric($k)); - if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { + if (count($aInactiveClassificationIds) !== count($aInactiveClasses)) { LoggerUtils::getAppLogger()->warning('Encountered invalid configuration(s) for sInactiveClassification, please fix this'); } From 9b1b14f80c7c8297eab701b1f84e4b0bbb702464 Mon Sep 17 00:00:00 2001 From: Arun Philip Date: Wed, 8 May 2024 00:54:13 -0400 Subject: [PATCH 4/5] run prettier on cypress js files --- cypress/e2e/ui/events/standard.events.spec.js | 3 - cypress/e2e/ui/people/standard.family.spec.js | 10 +- ...dard.people.filterbyclassification.spec.js | 160 +++++++++--------- 3 files changed, 90 insertions(+), 83 deletions(-) diff --git a/cypress/e2e/ui/events/standard.events.spec.js b/cypress/e2e/ui/events/standard.events.spec.js index 3f235f4800..508d45b084 100644 --- a/cypress/e2e/ui/events/standard.events.spec.js +++ b/cypress/e2e/ui/events/standard.events.spec.js @@ -15,7 +15,6 @@ context("Standard User Session", () => { cy.contains("Berry, Miss Brianna"); }); - it("View Event via URL", () => { cy.loginStandard("EditEventAttendees.php?eventId=3"); cy.contains("Attendees for Event : Summer Camp"); @@ -26,13 +25,11 @@ context("Standard User Session", () => { cy.contains("Listing All Church Events"); }); - it("View Event via invalid URL id", () => { cy.loginStandard("EditEventAttendees.php?eventId=99999", false); cy.contains("Listing All Church Events"); }); - it("CheckIn People", () => { cy.loginStandard("Checkin.php"); cy.contains("Event Checkin"); diff --git a/cypress/e2e/ui/people/standard.family.spec.js b/cypress/e2e/ui/people/standard.family.spec.js index e845f058ee..b2358ae196 100644 --- a/cypress/e2e/ui/people/standard.family.spec.js +++ b/cypress/e2e/ui/people/standard.family.spec.js @@ -62,10 +62,12 @@ context("Standard Family", () => { cy.get('input[name="Longitude"]').clear(); // Fill in Other Info section - const weddingYear = '2024'; - const weddingMonth = '04'; - const weddingDay = '03'; - cy.get('#WeddingDate').type(`${weddingYear}-${weddingMonth}-${weddingDay}`); + const weddingYear = "2024"; + const weddingMonth = "04"; + const weddingDay = "03"; + cy.get("#WeddingDate").type( + `${weddingYear}-${weddingMonth}-${weddingDay}`, + ); // Fill in Family Members cy.get('input[name="FirstName1"]').type("Mike"); diff --git a/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js index 9f7a255751..f50182e645 100644 --- a/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js +++ b/cypress/e2e/ui/people/standard.people.filterbyclassification.spec.js @@ -1,77 +1,85 @@ -describe('template spec', () => { - it('filter-by-classification', () => { - cy.loginAdmin("OptionManager.php?mode=classes"); - cy.get("#inactive4").uncheck(); - cy.get("#inactive5").uncheck(); - cy.reload(); - cy.get("#inactive1").should('not.be.checked'); - cy.get("#inactive2").should('not.be.checked'); - cy.get("#inactive3").should('not.be.checked'); - cy.get("#inactive4").should('not.be.checked'); - cy.get("#inactive5").should('not.be.checked'); - - cy.visit("v2/people?familyActiveStatus=inactive"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("No matching records found"); - - cy.visit("v2/people?familyActiveStatus=all"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("v2/people"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("OptionManager.php?mode=classes"); - cy.get("#inactive4").check(); - cy.reload(); - cy.get("#inactive1").should('not.be.checked'); - cy.get("#inactive2").should('not.be.checked'); - cy.get("#inactive3").should('not.be.checked'); - cy.get("#inactive4").should('be.checked'); - cy.get("#inactive5").should('not.be.checked'); - - cy.visit("v2/people?familyActiveStatus=inactive"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("No matching records found"); - - cy.visit("v2/people?familyActiveStatus=all"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("v2/people"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("OptionManager.php?mode=classes"); - cy.get("#inactive5").check(); - cy.reload(); - cy.get("#inactive1").should('not.be.checked'); - cy.get("#inactive2").should('not.be.checked'); - cy.get("#inactive3").should('not.be.checked'); - cy.get("#inactive4").should('be.checked'); - cy.get("#inactive5").should('be.checked'); - - cy.visit("v2/people?familyActiveStatus=inactive"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("v2/people?familyActiveStatus=all"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("(564)-714-4633"); - - cy.visit("v2/people"); - cy.get("#members_filter input").type("edwin.adams@example.com"); - cy.contains("No matching records found"); - - cy.visit("OptionManager.php?mode=classes"); - cy.get("#inactive4").uncheck(); - cy.get("#inactive5").uncheck(); - cy.reload(); - cy.get("#inactive1").should('not.be.checked'); - cy.get("#inactive2").should('not.be.checked'); - cy.get("#inactive3").should('not.be.checked'); - cy.get("#inactive4").should('not.be.checked'); - cy.get("#inactive5").should('not.be.checked'); - }); +describe("template spec", () => { + it("filter-by-classification", () => { + cy.loginAdmin("OptionManager.php?mode=classes"); + cy.get("#inactive4").uncheck(); + cy.get("#inactive5").uncheck(); + + cy.reload(); + + cy.get("#inactive1").should("not.be.checked"); + cy.get("#inactive2").should("not.be.checked"); + cy.get("#inactive3").should("not.be.checked"); + cy.get("#inactive4").should("not.be.checked"); + cy.get("#inactive5").should("not.be.checked"); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive4").check(); + + cy.reload(); + + cy.get("#inactive1").should("not.be.checked"); + cy.get("#inactive2").should("not.be.checked"); + cy.get("#inactive3").should("not.be.checked"); + cy.get("#inactive4").should("be.checked"); + cy.get("#inactive5").should("not.be.checked"); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive5").check(); + + cy.reload(); + + cy.get("#inactive1").should("not.be.checked"); + cy.get("#inactive2").should("not.be.checked"); + cy.get("#inactive3").should("not.be.checked"); + cy.get("#inactive4").should("be.checked"); + cy.get("#inactive5").should("be.checked"); + + cy.visit("v2/people?familyActiveStatus=inactive"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people?familyActiveStatus=all"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("(564)-714-4633"); + + cy.visit("v2/people"); + cy.get("#members_filter input").type("edwin.adams@example.com"); + cy.contains("No matching records found"); + + cy.visit("OptionManager.php?mode=classes"); + cy.get("#inactive4").uncheck(); + cy.get("#inactive5").uncheck(); + + cy.reload(); + + cy.get("#inactive1").should("not.be.checked"); + cy.get("#inactive2").should("not.be.checked"); + cy.get("#inactive3").should("not.be.checked"); + cy.get("#inactive4").should("not.be.checked"); + cy.get("#inactive5").should("not.be.checked"); + }); }); From 2592150c2d5e2222fafea12cf191dda0959edc3e Mon Sep 17 00:00:00 2001 From: Arun Philip Date: Wed, 8 May 2024 03:30:10 -0400 Subject: [PATCH 5/5] fix php deprecation notice in Countries This resolves the issue shown below: ``` PHP Deprecated: Use of "static" in callables is deprecated in develop/ChurchCRM/src/ChurchCRM/data/Countries.php on line 280 Deprecated: Use of "static" in callables is deprecated in develop/ChurchCRM/src/ChurchCRM/data/Countries.php on line 280 ``` --- src/ChurchCRM/data/Countries.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ChurchCRM/data/Countries.php b/src/ChurchCRM/data/Countries.php index 1c56949fa7..1f0957ed3b 100644 --- a/src/ChurchCRM/data/Countries.php +++ b/src/ChurchCRM/data/Countries.php @@ -277,7 +277,7 @@ public static function getNames(): array { self::initializeCountries(); - return array_map(['static', 'getSingleName'], self::$countries); + return array_map([__CLASS__, 'getSingleName'], self::$countries); } public static function getAll(): array @@ -303,7 +303,7 @@ public static function getCountryByName(string $CountryName): ?Country self::initializeCountries(); $result = array_filter(self::$countries, fn ($e): bool => $e->getCountryName() === $CountryName); if (count($result) === 1) { - // Note that array_values() is needed because array_filter does not return continuous array + // Note that array_values() is needed because array_filter does not return a continuous array return array_values($result)[0]; }
@@ -366,12 +367,11 @@ } if ($mode === 'classes') { echo ""; - $check = in_array($aIDs[$row], $inactive_classes) ? "checked" : ""; + $check = in_array($aIDs[$row], $aInactiveClasses) ? "checked" : ""; echo ""; echo gettext("Inactive"); echo "