diff --git a/CRM/BUGP/BAO/Bugp.php b/CRM/BUGP/BAO/Bugp.php index 59e7f0078b24c8069a0e7010afaa41e696ba2bef..74722ccde8e5702a3c3ad70c003c780a6f2289b3 100755 --- a/CRM/BUGP/BAO/Bugp.php +++ b/CRM/BUGP/BAO/Bugp.php @@ -373,14 +373,16 @@ GROUP BY ccg.id"; if (!empty($grantTypes)) { $groupByClause[] = 'grant_type_id'; } - $dao = CRM_Core_DAO::executeQuery("SELECT id FROM civicrm_uf_field WHERE uf_group_id = {$profileId} + $dao = CRM_Core_DAO::executeQuery("SELECT id, GROUP_CONCAT(field_type) field_type FROM civicrm_uf_field WHERE uf_group_id = {$profileId} AND field_type IN ('Individual', 'Organization', 'Household') AND is_active = 1"); - if ($dao->N) { + $contactTypes = array(); + if ($dao->fetch()) { $groupByClause[] = 'contact_type'; + $contactTypes = explode(',', $dao->field_type); } - $query = 'SELECT cg.id FROM civicrm_grant cg INNER JOIN civicrm_contact cc ON cc.id = cg.contact_id WHERE cg.id IN (' . implode(',', $grantIds) . ') '; + $query = 'SELECT cg.id, cc.contact_type FROM civicrm_grant cg INNER JOIN civicrm_contact cc ON cc.id = cg.contact_id WHERE cg.id IN (' . implode(',', $grantIds) . ') '; if (!empty($groupByClause)) { $query .= ' GROUP BY ' . implode(',', $groupByClause); } @@ -388,7 +390,8 @@ GROUP BY ccg.id"; return FALSE; } $result = CRM_Core_DAO::executeQuery($query); - if ($result->N > 1) { + $result->fetch(); + if ($result->N > 1 || ($result->N == 1 && !in_array($result->contact_type, $contactTypes))) { return TRUE; } else { diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index d9d7f3bfebdb7c60a9c82fafe6217f7c457a257f..82063c84a1f1b3905e1a07944494c6fe48c303a7 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1097,7 +1097,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, - $absolute + $absolute, + $additionalWhereClause ); $params[$index] = $values[$index] = $fileURL['file_url']; } @@ -1825,14 +1826,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); if (substr($fieldName, 0, 14) === 'state_province') { - $controlField = str_replace('state_province', 'country', $name); - if (isset($form->_fields[$controlField]) || in_array($controlField, $fieldsProcessed)) { - $form->addChainSelect($name, array('label' => $title, 'required' => $required)); - } - else { - $options = CRM_Core_PseudoConstant::stateProvince(); - $form->add('select', $name, $title, $options, $required && $options, $selectAttributes); - } + $form->addChainSelect($name, array('label' => $title, 'required' => $required)); $config = CRM_Core_Config::singleton(); if (!in_array($mode, array( CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH)) && @@ -1855,14 +1849,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } elseif (substr($fieldName, 0, 6) === 'county') { if ($addressOptions['county']) { - $controlField = str_replace('county', 'state_province', $name); - if (isset($form->_fields[$controlField]) || in_array($controlField, $fieldsProcessed)) { - $form->addChainSelect($name, array('label' => $title, 'required' => $required)); - } - else { - $options = CRM_Core_PseudoConstant::county(); - $form->add('select', $name, $title, $options, $required && $options, $selectAttributes); - } + $form->addChainSelect($name, array('label' => $title, 'required' => $required)); } } elseif (substr($fieldName, 0, 9) === 'image_URL') { @@ -3150,9 +3137,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $groupTypeExpr .= implode(',', $coreTypes); } if ($subTypes) { - if (count($subTypes) > 1) { - throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget."); - } + //CRM-15427 Allow Multiple subtype filtering + //if (count($subTypes) > 1) { + //throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget."); + //} foreach ($subTypes as $subType => $subTypeIds) { $groupTypeExpr .= $delim . $subType . ':' . implode(':', $subTypeIds); } @@ -3283,18 +3271,20 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $skipValue = FALSE; foreach ($formattedGroupTree as $tree) { - if (isset($tree['fields'][$customFieldDetails[0]]) && 'CheckBox' == CRM_Utils_Array::value('html_type', $tree['fields'][$customFieldDetails[0]])) { - $skipValue = TRUE; - $defaults['field'][$componentId][$name] = $customValue; - break; - } - elseif (isset($tree['fields'][$customFieldDetails[0]]) && CRM_Utils_Array::value('data_type', $tree['fields'][$customFieldDetails[0]]) == 'Date') { - $skipValue = TRUE; + if (!empty($tree['fields'][$customFieldDetails[0]])) { + if ('CheckBox' == CRM_Utils_Array::value('html_type', $tree['fields'][$customFieldDetails[0]])) { + $skipValue = TRUE; + $defaults['field'][$componentId][$name] = $customValue; + break; + } + elseif (CRM_Utils_Array::value('data_type', $tree['fields'][$customFieldDetails[0]]) == 'Date') { + $skipValue = TRUE; - // CRM-6681, $default contains formatted date, time values. - $defaults[$fldName] = $customValue; - if (!empty($defaults[$customKey . '_time'])) { - $defaults['field'][$componentId][$name . '_time'] = $defaults[$customKey . '_time']; + // CRM-6681, $default contains formatted date, time values. + $defaults[$fldName] = $customValue; + if (!empty($defaults[$customKey . '_time'])) { + $defaults['field'][$componentId][$name . '_time'] = $defaults[$customKey . '_time']; + } } } } diff --git a/CRM/Grant/Form/Task/PickProfile.php b/CRM/Grant/Form/Task/PickProfile.php index c19314a91de7e620c984493e3c11a503385b11cd..cb913db1fe22373d4c23e4c49bf0bb3b01986e50 100644 --- a/CRM/Grant/Form/Task/PickProfile.php +++ b/CRM/Grant/Form/Task/PickProfile.php @@ -120,7 +120,7 @@ class CRM_Grant_Form_Task_PickProfile extends CRM_Grant_Form_Task { } //add Contact type profiles - $this->_grantTypes = array_merge($this->_grantTypes, array('Grant', 'Contact', 'Individual')); + $this->_grantTypes = array_merge($this->_grantTypes, array('Grant', 'Contact', 'Individual', 'Organization', 'Household')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($this->_grantTypes); @@ -129,7 +129,7 @@ class CRM_Grant_Form_Task_PickProfile extends CRM_Grant_Form_Task { CRM_Core_Session::setStatus(ts("The grant selected for Batch Update does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error'); CRM_Utils_System::redirect($this->_userContext); } - $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE); + $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE, array('class' => 'crm-select2 huge')); $this->assign('totalSelectedContacts', count($this->_grantIds)); $this->addDefaultButtons(ts('Continue >>')); }