From 9ec94e53f221d4e2c28d303f50ce478358fa4f03 Mon Sep 17 00:00:00 2001 From: Yashodha Chaku Date: Fri, 9 Apr 2021 14:15:22 +0000 Subject: [PATCH] Change the unit of the duration of a volunteer opportunity --- CRM/Volunteer/Form/Log.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CRM/Volunteer/Form/Log.php b/CRM/Volunteer/Form/Log.php index 66e56df6..5cefb2e6 100644 --- a/CRM/Volunteer/Form/Log.php +++ b/CRM/Volunteer/Form/Log.php @@ -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')); } @@ -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']; @@ -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 { @@ -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);