tbar0970 / jethro-pmm

Jethro Pastoral Ministry Manager
GNU General Public License v3.0
35 stars 25 forks source link

Roster assignments on dates with no service #827

Open jefft opened 2 years ago

jefft commented 2 years ago

Under Rosters -> Display Roster Assignments, it's possible to have a situation where a service's date doesn't appear. For instance, 6 Nov, 27 Nov and 4 Dec are all missing:

image

yet those services appear to be defined under Services -> List All:

image

jefft commented 2 years ago

After some investigation:

As we know, the roster assignment table is generated with roster roles on the X axis, and service dates on the Y axis:

image

The problem is: there aren't actually services defined for the '4pm Kids' roster. In the Service Schedule screenshot above, only cells with a ⊕ symbol have a service defined, i.e. only the 4pm congregation:

image

The lack of '4pm Kids' services can be seen more clearly by selecting only that congregation:

image

So why are any dates displaying at all in 'Display Roster Assignments', if no services are defined? Because the 'Display roster assignments' code, after going through each service, also goes through any existing role assignments:

https://github.com/tbar0970/jethro-pmm/blob/94592a8b4548bf0094aa2d5c2ad7513284b45275/db_objects/roster_view.class.php#L632-L646

How can there be a assignment if no service dates are defined? Because in the '4PM KIDS CHURCH' roster view, there is a Roster Role called 'Unavailabilities' which is not tied to any particular congregation:

image

So the presence of an unavailability on a particular date determines whether that date's row shows up, and if it appears, it can have further assignments made for that date, despite there never being a service scheduled. That is how for 10 years, our church has been making roster assignments on '4pm Kids' despite never having services defined.


So that is the cause of the problem. What is the fix? I don't really know, but my 2c:

A purist would say "it shouldn't be possible to make roster assignments on dates when there is no service!". The fix is then to lock down 'Edit Roster Assignments' to not show any date rows if a service isn't defined for that date - even if an assignment is present.

That is fair enough, but then it would also be nice to fix the UI problems when creating Services. Are the '4pm Kids' and '6pm' services defined here or not?

image

image

The answer is that they are not defined. The only indication is the lack of ⊕ or tiny 'x' in edit mode. I think this should be made clearer.

Non-purist me is tempted to go the other way: display date rows if a service is defined in any congregation:

diff --git a/db_objects/roster_view.class.php b/app/db_objects/roster_view.class.php
--- a/db_objects/roster_view.class.php
+++ b/db_objects/roster_view.class.php
@@ -612,7 +612,7 @@ class roster_view extends db_object
                $dummy_service = new Service();

                if (is_null($start_date)) $start_date = date('Y-m-d');
-               $service_params = Array('congregationid' => $this->getCongregations(), '>date' => date('Y-m-d', strtot>
+               $service_params = Array('>date' => date('Y-m-d', strtotime($start_date.' -1 day')));
                if (!is_null($end_date)) $service_params['<date'] = date('Y-m-d', strtotime($end_date.' +1 day'));
                $services = $GLOBALS['system']->getDBObjectData('service', $service_params, 'AND', 'date');

This solves the immediate problem of missing dates, and.. I can't really see a downside.

tbar0970 commented 2 years ago

Some scattered thoughts:

That is fair enough, but then it would also be nice to fix the UI problems when creating Services. Are the '4pm Kids' and '6pm' services defined here or not?

Um, doesn't an empty cell pretty clearly indicate there is no such service?

Non-purist me is tempted to go the other way: display date rows if a service is defined in any congregation:

This would cause problems for churches with, for example, Saturday and Sunday services each week. Don't want to show Saturdays in the Sunday congregation's roster, etc.

One tricky part of all this is that there is no simple relationship between a roster view and a congregation. A roster view might include roster roles from several different congregations, or it might have 100% non-congregational roles. So the "which dates sould be included" question isn't such a simple one.

Final thought: Now that we have planned absences, it'd be a good idea to get rid of that "unavailabilities" role. Some SQL can convert all the existing assignments into planned absences. (Then you would need to create services for the 4pm kids congregation!).

tbar0970 commented 2 years ago

Related: https://github.com/tbar0970/jethro-pmm/issues/422

tbar0970 commented 2 years ago

Also related: https://github.com/tbar0970/jethro-pmm/issues/161

tbar0970 commented 2 years ago

A purist would say "it shouldn't be possible to make roster assignments on dates when there is no service!". The fix is then to lock down 'Edit Roster Assignments' to not show any date rows if a service isn't defined for that date - even if an assignment is present.

Perhaps a better purist position would be: "It shouldn't be posisble to make roster assignments for a congregation-related role on dates when that congregation has no service". So then in your screenshotted scenario, the "unavailabilities" role would be editable for various dates (because it's non-congregational) but the other columns wouldn't (perhaps with some indicator 'no 4pm kids service on this date')