This fixes the issue that was discussed in #110 but wouldn't have been fixed with just changing 7 to 14.
Basically, $tableloop is 0 or 1 depending on which week is being modified. That is, if you're trying to sign up for a night crew this week, $tableloop will be 0, and day 0 is indexed to the Sunday of this week. In that case, we want to look forward to the end of next week to ensure you're not riding so as to enforce the "every two week" policy that's currently in place. ~Note that this code will have to be changed if/when that policy is reverted to "every week."~ I also added a boolean for a two- vs. one-week rotation.
Conversely, if you're trying to sign up for a crew next week, $tableloop is 1, and day 0 is indexed to the Sunday of next week. As such, we only want to look forward seven days, which, yes, still gets you to the end of next week. If you were to use 14 as was coded in #110, you'll end up at the end of the following week, which doesn't exist in the database yet.
I hope that makes sense. It only took about an hour of walking through the code to figure out what was going on. tbh we're still not entirely sure 🤞
This fixes the issue that was discussed in #110 but wouldn't have been fixed with just changing
7
to14
.Basically,
$tableloop
is0
or1
depending on which week is being modified. That is, if you're trying to sign up for a night crew this week,$tableloop
will be0
, and day0
is indexed to the Sunday of this week. In that case, we want to look forward to the end of next week to ensure you're not riding so as to enforce the "every two week" policy that's currently in place. ~Note that this code will have to be changed if/when that policy is reverted to "every week."~ I also added a boolean for a two- vs. one-week rotation.Conversely, if you're trying to sign up for a crew next week,
$tableloop
is1
, and day0
is indexed to the Sunday of next week. As such, we only want to look forward seven days, which, yes, still gets you to the end of next week. If you were to use14
as was coded in #110, you'll end up at the end of the following week, which doesn't exist in the database yet.I hope that makes sense. It only took about an hour of walking through the code to figure out what was going on. tbh we're still not entirely sure 🤞