Affects Version/s: 1.0
Fix Version/s: 1.0
Implement batch entry UI for logging volunteer hours.
1. Link to "Log Volunteer Hours" will be included in Manage Events >> Volunteers tab. Link should contain volunteer project ID of the volunteer_project row linked to this event. All remaining logic for this workflow uses the volunteer_project.id key.
I think URL formation should be something like "civicrm/volunteer/loghours" (i.e. NOT in civicrm/event scope). Need to think about permissioning though. Maybe inherit 'edit all events' permission for now?? Or should the extension add it's own 'manage volunteers' permission?
2. User click's Log Volunteer Hours which loads a grid page containing a row for each Volunteer for this volunteer project with activity status of Scheduled OR Available. (Retrieve activities where volunteer_need_id is a need linked to this volunteer_project.)
Contact (name), Role, Start Time, Scheduled Duration, and Status should be pre-filled from activity and linked civicrm_volunteer_need records. These are all READ-ONLY except for Status. The Actual Duration field is text input field for user to fill in and is required IF status is set to Completed.
Some volunteer activity records may NOT have a linked volunteer_need_id. For these rows, only the Contact (name) and Status are pre-filled and the remaining fields are all editable.
'Copy Column Values' widget (as we have on other Batch Data Entry grids) should be added for Actual Duration and Status columns. This allows user to enter values in the first row and then copy them down to all rows with a single click (e.g. set all statuses to Completed).
NOTE: I think we'll want a hidden activity_id column in the grid to facilitate postProcessing.
3. User clicks Add Another if they want to log hours for a volunteer not already listed in the grid. Clicking Add Another inserts an 'empty' row in the grid with all fields editable. The Contact widget (select or create new) allows them to select any individual (or subtype) contact in the DB. They may even select a contact who already has a scheduled or completed volunteer activity for this event - since it is possible for an individual to fill multiple volunteer needs.
4. User clicks Save when they are finished entering data. Form rules are:
- Contact is required
- Actual Duration is required IF Status = Completed (e.g. user may leave some rows as Scheduled, and time completed would not be required for those rows)
5. Save (post-process) does the following:
- Rows with activity_id set: update the activity record
- For 'Added rows':
- insert new volunteer_need record IF role_id is set
- need.project_id = $thisProjectId
- need.duration = actual_duration if scheduled duration is not set
- if start_time is not set, is_flexible column is TRUE
- insert new volunteer activity record
NOTE: Not sure if we should always have a volunteer_need.id for every volunteer activity? If so, then we could use the 'generic flexible' need which is created for each project (event) when volunteering is enabled. However, we'd want to prevent users from deleting that need record if it's required.
- redirect back to Manage Event >> Manage Volunteers tab for the selected event (with status : Volunteer hours have been recorded for $count volunteers)