rpiambulance / website

RPI Ambulance's website—a work in progress
http://rpiambulance.com/
3 stars 14 forks source link

add check for which week is being worked on #143

Closed ddbruce closed 1 year ago

ddbruce commented 1 year ago

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 🤞