Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the unit of the duration of a volunteer opportunity #559

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CRM/Volunteer/Form/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static function formRule($params, $files, $self) {
if (!$duration) {
$errors["field[$key][actual_duration]"] =
ts('Please enter the actual duration volunteered.', array('domain' => 'org.civicrm.volunteer'));
} elseif (!ctype_digit($duration)) {
} elseif (!CRM_Utils_Rule::numeric($duration)) {
$errors["field[$key][actual_duration]"] =
ts('Please enter duration as a number.', array('domain' => 'org.civicrm.volunteer'));
}
Expand Down Expand Up @@ -233,8 +233,8 @@ function setDefaultValues() {
$volunteerStatus = CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate');

foreach ($this->_volunteerData as $data) {
$defaults['field'][$i]['scheduled_duration'] = $data['time_scheduled_minutes'];
$defaults['field'][$i]['actual_duration'] = $data['time_completed_minutes'];
$defaults['field'][$i]['scheduled_duration'] = $data['time_scheduled_minutes'] / 60;
$defaults['field'][$i]['actual_duration'] = $data['time_completed_minutes'] / 60;
$defaults['field'][$i]['volunteer_role'] = CRM_Utils_Array::value($data['volunteer_role_id'], $volunteerRole);
$defaults['field'][$i]['volunteer_status'] = $data['status_id'];
$defaults['field'][$i]['activity_id'] = $data['id'];
Expand Down Expand Up @@ -273,8 +273,8 @@ public function postProcess() {
$volunteer = array(
'status_id' => $value['volunteer_status'],
'id' => $value['activity_id'],
'time_completed_minutes' => CRM_Utils_Array::value('actual_duration', $value),
'time_scheduled_minutes' => CRM_Utils_Array::value('scheduled_duration', $value),
'time_completed_minutes' => CRM_Utils_Array::value('actual_duration', $value) * 60,
'time_scheduled_minutes' => CRM_Utils_Array::value('scheduled_duration', $value) * 60,
);
CRM_Volunteer_BAO_Assignment::createVolunteerActivity($volunteer);
} else {
Expand All @@ -286,8 +286,8 @@ public function postProcess() {
'subject' => $this->_title . ' Volunteering',
'volunteer_need_id' => $flexibleNeedId,
'volunteer_role_id' => CRM_Utils_Array::value('volunteer_role', $value),
'time_completed_minutes' => CRM_Utils_Array::value('actual_duration', $value),
'time_scheduled_minutes' => CRM_Utils_Array::value('scheduled_duration', $value),
'time_completed_minutes' => CRM_Utils_Array::value('actual_duration', $value) * 60,
'time_scheduled_minutes' => CRM_Utils_Array::value('scheduled_duration', $value) * 60,
);
if (!empty($value['start_date'])) {
$volunteer['activity_date_time'] = CRM_Utils_Date::processDate($value['start_date'], $value['start_date_time'], TRUE);
Expand Down