Esempio n. 1
0
 static function formRule($params, $files, $context)
 {
     $errors = parent::rules($params, $files, $context);
     //make sure primary contact is selected
     $contactId = CRM_Utils_Array::value('primary_contact_id', $params);
     if (!is_numeric($contactId)) {
         $errors['primary_contact_id'] = ts('This field is required.');
     }
     $selectResource = $context->controller->exportValues('SelectResource');
     $resources = json_decode($selectResource['resources'], true);
     $resourcesToValidate['resources'] = array();
     foreach ($resources as $key => $resource) {
         $resource['start'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('start_date', $resource));
         $resource['end'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $resource));
         $resourcesToValidate['resources'][$key] = $resource;
     }
     $result = civicrm_api3('Slot', 'validate', $resourcesToValidate);
     $values = $result['values'];
     if (!$values['is_valid']) {
         $errors['resources'] = ts('Unfortunately one or more of your booking slots are clashing with another booking. You will need to edit your booking times to resolve this before you can save your booking. Please go back to the first page to edit your booking slots.');
     }
     return empty($errors) ? TRUE : $errors;
 }
Esempio n. 2
0
 static function formRule($params, $files, $self)
 {
     $errors = parent::rules($params, $files, $self);
     return empty($errors) ? TRUE : $errors;
 }