/** * Method to get groups * * @return array * @access protected */ protected function getSubtypes() { $subTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); $options = array(); foreach ($subTypes as $name => $type) { if (!empty($type['parent_id'])) { $options[$name] = $type['parent_label'] . ' - ' . $type['label']; } } return $options; }
/** * Returns a user friendly text explaining the condition params * e.g. 'Older than 65' * * @return string * @access public */ public function userFriendlyConditionParams() { $params = $this->getActionParameters(); $label = ts('Set contact subtype to: '); $subTypeLabels = array(); $subTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); foreach ($params['sub_type'] as $sub_type) { $subTypeLabels[] = $subTypes[$sub_type]['parent_label'] . ' - ' . $subTypes[$sub_type]['label']; } $label .= implode(', ', $subTypeLabels); return $label; }
function browse() { $basicType = CRM_Contact_BAO_ContactType::contactTypeInfo(true); $subType = CRM_Contact_BAO_ContactType::subTypeInfo(null, true); $rows = array_merge($basicType, $subType); foreach ($rows as $key => $value) { $mask = null; if (CRM_Utils_Array::value('is_reserved', $value)) { $mask -= CRM_Core_Action::DELETE + 1; } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id'])); } $this->assign('rows', $rows); }
function browse() { $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(true); foreach ($rows as $key => $value) { $mask = null; if (CRM_Utils_Array::value('is_reserved', $value)) { $mask = CRM_Core_Action::UPDATE; } else { $mask -= CRM_Core_Action::DELETE - 2; if (CRM_Utils_Array::value('is_active', $value)) { $mask -= CRM_Core_Action::ENABLE; } else { $mask -= CRM_Core_Action::DISABLE; } } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id'])); } $this->assign('rows', $rows); }
/** * Browse contact types. */ public function browse() { $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); foreach ($rows as $key => $value) { $mask = NULL; if (!empty($value['is_reserved'])) { $mask = CRM_Core_Action::UPDATE; } else { $mask -= CRM_Core_Action::DELETE - 2; if (!empty($value['is_active'])) { $mask -= CRM_Core_Action::ENABLE; } else { $mask -= CRM_Core_Action::DISABLE; } } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id']), ts('more'), FALSE, 'contactType.manage.action', 'ContactType', $value['id']); } $this->assign('rows', $rows); }
function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); foreach ($rows as $key => $value) { $mask = NULL; if (!empty($value['is_reserved'])) { $mask = CRM_Core_Action::UPDATE; } else { $mask -= CRM_Core_Action::DELETE - 2; if (!empty($value['is_active'])) { $mask -= CRM_Core_Action::ENABLE; } else { $mask -= CRM_Core_Action::DISABLE; } } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id']), ts('more'), FALSE, 'contactType.manage.action', 'ContactType', $value['id']); } $this->assign('rows', $rows); }
/** * Preprocess function. */ public function preProcess() { $this->_type = $this->_cdType = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, TRUE); $this->_subType = CRM_Utils_Request::retrieve('subType', 'String'); $this->_subName = CRM_Utils_Request::retrieve('subName', 'String'); $this->_groupCount = CRM_Utils_Request::retrieve('cgcount', 'Positive'); $this->_entityId = CRM_Utils_Request::retrieve('entityID', 'Positive'); $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive'); $this->assign('cdType', FALSE); $this->assign('cgCount', $this->_groupCount); $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); if (array_key_exists($this->_type, $contactTypes)) { $this->assign('contactId', $this->_entityId); } if (!is_array($this->_subType) && strstr($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)) { $this->_subType = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)); } CRM_Custom_Form_CustomData::setGroupTree($this, $this->_subType, $this->_groupID); $this->assign('suppressForm', TRUE); $this->controller->_generateQFKey = FALSE; }
/** * Build the form object. */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } // Select list $relationshipList = CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId); // Metadata needed on clientside $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); $jsData = array(); // Get just what we need to keep the dom small $whatWeWant = array_flip(array('contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b')); foreach ($this->_allRelationshipNames as $id => $vals) { if ($vals['name_a_b'] === 'Employee of') { $this->assign('employmentRelationship', $id); } if (isset($relationshipList["{$id}_a_b"]) || isset($relationshipList["{$id}_b_a"])) { $jsData[$id] = array_filter(array_intersect_key($this->_allRelationshipNames[$id], $whatWeWant)); // Add user-friendly placeholder foreach (array('a', 'b') as $x) { $type = !empty($jsData[$id]["contact_sub_type_{$x}"]) ? $jsData[$id]["contact_sub_type_{$x}"] : CRM_Utils_Array::value("contact_type_{$x}", $jsData[$id]); $jsData[$id]["placeholder_{$x}"] = $type ? ts('- select %1 -', array(strtolower($contactTypes[$type]['label']))) : ts('- select contact -'); } } } $this->assign('relationshipData', $jsData); $this->addField('relationship_type_id', array('options' => array('' => ts('- select -')) + $relationshipList, 'class' => 'huge', 'placeholder' => '- select -'), TRUE); $label = $this->_action & CRM_Core_Action::ADD ? ts('Contact(s)') : ts('Contact'); $contactField = $this->addField('related_contact_id', array('label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, 'create' => TRUE), TRUE); // This field cannot be updated if ($this->_action & CRM_Core_Action::UPDATE) { $contactField->freeze(); } $this->add('advcheckbox', 'is_current_employer', $this->_contactType == 'Organization' ? ts('Current Employee') : ts('Current Employer')); $this->addField('start_date', array('label' => ts('Start Date'), 'formatType' => 'searchDate')); $this->addField('end_date', array('label' => ts('End Date'), 'formatType' => 'searchDate')); $this->addField('is_active', array('label' => ts('Enabled?'))); $this->addField('is_permission_a_b'); $this->addField('is_permission_b_a'); $this->addField('description', array('label' => ts('Description'))); CRM_Contact_Form_Edit_Notes::buildQuickForm($this); if ($this->_action & CRM_Core_Action::VIEW) { $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done')))); } else { // make this form an upload since we don't know if the custom data injected dynamically is of type file etc. $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } }
/** * @param $relationshipList * @return array */ public static function getRelationshipTypeMetadata($relationshipList) { $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); $allRelationshipNames = CRM_Core_PseudoConstant::relationshipType('name'); $jsData = array(); // Get just what we need to keep the dom small $whatWeWant = array_flip(array('contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b')); foreach ($allRelationshipNames as $id => $vals) { if (isset($relationshipList["{$id}_a_b"]) || isset($relationshipList["{$id}_b_a"])) { $jsData[$id] = array_filter(array_intersect_key($allRelationshipNames[$id], $whatWeWant)); // Add user-friendly placeholder foreach (array('a', 'b') as $x) { $type = !empty($jsData[$id]["contact_sub_type_{$x}"]) ? $jsData[$id]["contact_sub_type_{$x}"] : CRM_Utils_Array::value("contact_type_{$x}", $jsData[$id]); $jsData[$id]["placeholder_{$x}"] = $type ? ts('- select %1 -', array(strtolower($contactTypes[$type]['label']))) : ts('- select contact -'); } } } return $jsData; }