/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // add select for tag $this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); foreach ($this->_tags as $tagID => $tagName) { $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", NULL, $tagName); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE); $this->addDefaultButtons(ts('Remove Tags from activities')); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // add select for tag $this->_tags = CRM_Core_BAO_Tag::getTags(); foreach ($this->_tags as $tagID => $tagName) { $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", NULL, $tagName); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_contact'); $this->addDefaultButtons(ts('Tag Contacts')); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // add select for tag $this->_tags = CRM_Core_BAO_Tag::getTags(); foreach ($this->_tags as $tagID => $tagName) { $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", null, $tagName); } require_once 'CRM/Core/Form/Tag.php'; require_once 'CRM/Core/BAO/Tag.php'; $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_contact', null, true); $this->addDefaultButtons(ts('Remove Tag Contacts')); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_batchStatusId == 2) { $this->add('submit', 'export_batch', ts('Export Batch')); } // do not build rest of form unless it is open batch if ($this->_batchStatusId != 1) { return; } parent::buildQuickForm(); $this->add('submit', 'close_batch', ts('Close Batch')); $this->add('submit', 'export_batch', ts('Close & Export Batch')); // text for sort_name $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $this->_group = CRM_Core_PseudoConstant::group(); // multiselect for groups if ($this->_group) { $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -'))); } $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } CRM_Contribute_BAO_Query::buildSearchForm($this); $this->addElement('checkbox', 'toggleSelects', NULL, NULL); $this->add('select', 'trans_remove', ts('Task'), array('' => ts('- actions -')) + array('Remove' => ts('Remove from Batch'))); $this->add('submit', 'rSubmit', ts('Go'), array('class' => 'form-submit', 'id' => 'GoRemove')); self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive'); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Search'), 'isDefault' => TRUE))); $this->addElement('checkbox', 'toggleSelect', NULL, NULL); $this->add('select', 'trans_assign', ts('Task'), array('' => ts('- actions -')) + array('Assign' => ts('Assign to Batch'))); $this->add('submit', 'submit', ts('Go'), array('class' => 'form-submit', 'id' => 'Go')); $this->applyFilter('__ALL__', 'trim'); $this->addElement('hidden', 'batch_id', self::$_entityID); $this->add('text', 'name', ts('Batch Name')); }
/** * Add all the elements shared between case activity search and advanced search. * * * @param CRM_Core_Form $form * @return void */ public static function buildSearchForm(&$form) { $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); $form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))); CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE); $followUpActivity = array(1 => ts('Yes'), 2 => ts('No')); $form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE)); $form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE)); $activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by')); $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE)); $form->setDefaults(array('activity_role' => 3)); $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name')); $form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))); $form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled']))); $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $form->addYesNo('activity_test', ts('Activity is a Test?')); $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if ($activity_tags) { foreach ($activity_tags as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName); } } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE); $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE); if ($surveys) { $form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2')); } $extends = array('Activity'); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends); if ($groupDetails) { $form->assign('activityGroupTree', $groupDetails); foreach ($groupDetails as $group) { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE); } } } CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id'); //add engagement level CRM-7775 $buildEngagementLevel = FALSE; $buildSurveyResult = FALSE; if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $buildEngagementLevel = TRUE; $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search')); // Add survey result field. $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name'); $resultOptions = array(); foreach ($optionGroups as $gid => $name) { if ($name) { $value = array(); $value = CRM_Core_OptionGroup::values($name); if (!empty($value)) { while (list($k, $v) = each($value)) { $resultOptions[$v] = $v; } } } } // If no survey result options have been created, don't build // the field to avoid clutter. if (count($resultOptions) > 0) { $buildSurveyResult = TRUE; asort($resultOptions); $form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2')); } } $form->assign('buildEngagementLevel', $buildEngagementLevel); $form->assign('buildSurveyResult', $buildSurveyResult); $form->setDefaults(array('activity_test' => 0)); }
/** * add all the elements shared between case activity search and advanaced search * * @access public * @return void * @static */ static function buildSearchForm(&$form) { $activityOptions = CRM_Core_PseudoConstant::activityType(true, true, false, 'label', true); asort($activityOptions); foreach ($activityOptions as $activityID => $activity) { $form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", null, $activity, array('onClick' => 'showCustomData( this.id );')); } $form->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate')); $form->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate')); $activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to')); $form->addRadio('activity_role', null, $activityRoles, null, '<br />'); $form->setDefaults(array('activity_role' => 1)); $form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); foreach ($activityStatus as $activityStatusID => $activityStatusName) { $activity_status[] = HTML_QuickForm::createElement('checkbox', $activityStatusID, null, $activityStatusName); } $form->addGroup($activity_status, 'activity_status', ts('Activity Status')); $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1)); $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $form->addElement('checkbox', 'activity_test', ts('Find Test Activities?')); require_once 'CRM/Core/BAO/Tag.php'; $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if ($activity_tags) { foreach ($activity_tags as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", null, $tagName); } } require_once 'CRM/Campaign/BAO/Survey.php'; $surveys = array('' => ts('- none -')) + CRM_Campaign_BAO_Survey::getSurveyList(); $form->add('select', 'activity_survey_id', ts('Survey'), $surveys, false); require_once 'CRM/Core/BAO/CustomGroup.php'; $extends = array('Activity'); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends); if ($groupDetails) { require_once 'CRM/Core/BAO/CustomField.php'; $form->assign('activityGroupTree', $groupDetails); foreach ($groupDetails as $group) { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true); } } } }
/** * Get options for a given field. * * @see CRM_Core_DAO::buildOptions * @see CRM_Core_DAO::buildOptionsContext * * @param string $fieldName * @param string $context * As per CRM_Core_DAO::buildOptionsContext. * @param array $props * whatever is known about this dao object. * * @return array|bool */ public static function buildOptions($fieldName, $context = NULL, $props = array()) { $params = array(); if ($fieldName == 'tag' || $fieldName == 'tag_id') { if (!empty($props['entity_table'])) { $entity = CRM_Utils_Type::escape($props['entity_table'], 'String'); $params[] = "used_for LIKE '%{$entity}%'"; } // Output tag list as nested hierarchy // TODO: This will only work when api.entity is "entity_tag". What about others? if ($context == 'search' || $context == 'create') { return CRM_Core_BAO_Tag::getTags(CRM_Utils_Array::value('entity_table', $props, 'civicrm_contact'), CRM_Core_DAO::$_nullArray, CRM_Utils_Array::value('parent_id', $params), '- '); } } $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); return $options; }
public function buildQuickForm() { if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', FALSE); $button = ts('Delete'); if ($this->_action & CRM_Core_Action::RENEW) { $button = ts('Restore'); } $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } // Build other activity links. CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this); // Enable form element (ActivityLinks sets this true). $this->assign('suppressForm', FALSE); $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required')); // Freeze for update mode. if ($this->_action & CRM_Core_Action::UPDATE) { $element->freeze(); } // Call to RecurringEntity buildQuickForm for add/update mode. if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { CRM_Core_Form_RecurringEntity::buildQuickForm($this); } foreach ($this->_fields as $field => $values) { if (!empty($this->_fields[$field])) { $attribute = CRM_Utils_Array::value('attributes', $values); $required = !empty($values['required']); if ($values['type'] == 'select' && empty($attribute)) { $this->addSelect($field, array('entity' => 'activity'), $required); } elseif ($values['type'] == 'entityRef') { $this->addEntityRef($field, $values['label'], $attribute, $required); } else { $this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values)); } } } // CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); // Add engagement level CRM-7775 $buildEngagementLevel = FALSE; if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $buildEngagementLevel = TRUE; $this->addSelect('engagement_level', array('entity' => 'activity')); $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger'); } $this->assign('buildEngagementLevel', $buildEngagementLevel); // check for survey activity $this->_isSurveyActivity = FALSE; if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId); if ($this->_isSurveyActivity) { $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id'); $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId); if ($responseOptions) { $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions)); } $surveyTitle = NULL; if ($surveyId) { $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title'); } $this->assign('surveyTitle', $surveyTitle); } } $this->assign('surveyActivity', $this->_isSurveyActivity); // this option should be available only during add mode if ($this->_action != CRM_Core_Action::UPDATE) { $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.')); } $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger'); $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime')); // Add followup date. $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime')); // Only admins and case-workers can change the activity source if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') { $this->getElement('source_contact_id')->freeze(); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Activity'); $this->assign('customDataSubType', $this->_activityTypeId); $this->assign('entityID', $this->_activityId); CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, ' ', TRUE); if (!empty($tags)) { $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge')); } // we need to hide activity tagset for special activities $specialActivities = array('Open Case'); if (!in_array($this->_activityTypeName, $specialActivities)) { // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId); } // if we're viewing, we're assigning different buttons than for adding/editing if ($this->_action & CRM_Core_Action::VIEW) { if (isset($this->_groupTree)) { CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree); } // form should be frozen for view mode $this->freeze(); $buttons = array(); $buttons[] = array('type' => 'cancel', 'name' => ts('Done')); $this->addButtons($buttons); } else { $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.')); $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");"); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::buildQuickForm($this); $this->addFormRule(array($className, 'formRule'), $this); } $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this); if (Civi::settings()->get('activity_assignee_notification')) { $this->assign('activityAssigneeNotification', TRUE); } else { $this->assign('activityAssigneeNotification', FALSE); } }
public function buildQuickForm() { if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', FALSE); $button = ts('Delete'); if ($this->_action & CRM_Core_Action::RENEW) { $button = ts('Restore'); } $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if (!$this->_single && !empty($this->_contactIds)) { $withArray = array(); foreach ($this->_contactIds as $contactId) { $withDisplayName = self::_getDisplayNameById($contactId); $withArray[] = "\"{$withDisplayName}\" "; } $this->assign('with', implode(', ', $withArray)); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //build other activity links CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this); //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', FALSE); $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );")); //freeze for update mode. if ($this->_action & CRM_Core_Action::UPDATE) { $element->freeze(); } foreach ($this->_fields as $field => $values) { if (CRM_Utils_Array::value($field, $this->_fields)) { $attribute = NULL; if (CRM_Utils_Array::value('attributes', $values)) { $attribute = $values['attributes']; } $required = FALSE; if (CRM_Utils_Array::value('required', $values)) { $required = TRUE; } if ($values['type'] == 'wysiwyg') { $this->addWysiwyg($field, $values['label'], $attribute, $required); } else { $this->add($values['type'], $field, $values['label'], $attribute, $required); } } } //CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); //add engagement level CRM-7775 $buildEngagementLevel = FALSE; if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $buildEngagementLevel = TRUE; $this->add('select', 'engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel()); $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger'); } $this->assign('buildEngagementLevel', $buildEngagementLevel); // check for survey activity $this->_isSurveyActivity = FALSE; if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId); if ($this->_isSurveyActivity) { $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id'); $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId); if ($responseOptions) { $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions)); } $surveyTitle = NULL; if ($surveyId) { $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title'); } $this->assign('surveyTitle', $surveyTitle); } } $this->assign('surveyActivity', $this->_isSurveyActivity); // this option should be available only during add mode if ($this->_action != CRM_Core_Action::UPDATE) { $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.')); } $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger'); $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime')); //add followup date $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime')); //autocomplete url $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE); $this->assign('dataUrl', $dataUrl); //tokeninput url $tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", FALSE, NULL, FALSE); $this->assign('tokenUrl', $tokenUrl); $admin = CRM_Core_Permission::check('administer CiviCRM'); //allow to edit source contact field field if context is civicase. if ($this->_context == 'caseActivity') { $admin = TRUE; } $this->assign('admin', $admin); $sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], NULL, $admin); $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid')); CRM_Contact_Form_NewContact::buildQuickForm($this); $this->add('text', 'assignee_contact_id', ts('assignee')); if ($sourceContactField->getValue()) { $this->assign('source_contact', $sourceContactField->getValue()); } elseif ($this->_currentUserId) { // we're setting currently LOGGED IN user as source for this activity $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId)); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Activity'); $this->assign('customDataSubType', $this->_activityTypeId); $this->assign('entityID', $this->_activityId); $tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if (!empty($tags)) { $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } // we need to hide activity tagset for special activities $specialActivities = array('Open Case'); if (!in_array($this->_activityTypeName, $specialActivities)) { // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId, TRUE, TRUE); } // if we're viewing, we're assigning different buttons than for adding/editing if ($this->_action & CRM_Core_Action::VIEW) { if (isset($this->_groupTree)) { CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree); } $buttons = array(); // do check for permissions if (CRM_Case_BAO_Case::checkPermission($this->_activityId, 'File On Case', $this->_activityTypeId)) { $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'subName' => 'file_on_case', 'js' => array('onClick' => "javascript:fileOnCase( \"file\", {$this->_activityId} ); return false;")); } // form should be frozen for view mode $this->freeze(); $buttons[] = array('type' => 'cancel', 'name' => ts('Done')); $this->addButtons($buttons); } else { $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.')); $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");"); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::buildQuickForm($this); $this->addFormRule(array($className, 'formRule'), $this); } $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this); if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) { $this->assign('activityAssigneeNotification', TRUE); } else { $this->assign('activityAssigneeNotification', FALSE); } }
/** * Add all the elements shared between case search and advanaced search. * * * @param CRM_Core_Form $form * * @return void */ public static function buildSearchForm(&$form) { $config = CRM_Core_Config::singleton(); //validate case configuration. $configured = CRM_Case_BAO_Case::isCaseConfigured(); $form->assign('notConfigured', !$configured['configured']); $form->add('select', 'case_type_id', ts('Case Type'), CRM_Case_PseudoConstant::caseType('title', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')); $form->add('select', 'case_status_id', ts('Case Status'), CRM_Case_PseudoConstant::caseStatus('label', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')); CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE); CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE); $form->assign('validCiviCase', TRUE); //give options when all cases are accessible. $accessAllCases = FALSE; if (CRM_Core_Permission::check('access all cases and activities')) { $accessAllCases = TRUE; $caseOwner = array(1 => ts('Search All Cases'), 2 => ts('Only My Cases')); $form->addRadio('case_owner', ts('Cases'), $caseOwner); } $form->assign('accessAllCases', $accessAllCases); $caseTags = CRM_Core_BAO_Tag::getTags('civicrm_case'); if ($caseTags) { foreach ($caseTags as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "case_tags[{$tagID}]", NULL, $tagName); } } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_case', NULL, TRUE, FALSE); if (CRM_Core_Permission::check('administer CiviCRM')) { $form->addElement('checkbox', 'case_deleted', ts('Deleted Cases')); } // add all the custom searchable fields $extends = array('Case'); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends); if ($groupDetails) { $form->assign('caseGroupTree', $groupDetails); foreach ($groupDetails as $group) { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE); } } } $form->setDefaults(array('case_owner' => 1)); }
public function buildQuickForm() { $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); $this->assign('multiClient', $isMultiClient); if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) { $title = 'Delete'; if ($this->_action & CRM_Core_Action::RENEW) { $title = 'Restore'; } $this->addButtons(array(array('type' => 'next', 'name' => $title, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Case'); CRM_Custom_Form_CustomData::buildQuickForm($this); // we don't want to show button on top of custom form $this->assign('noPreCustomButton', TRUE); $s = CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject'); if (!is_array($s)) { $s = array(); } $this->add('text', 'activity_subject', ts('Subject'), array_merge($s, array('maxlength' => '128')), TRUE); $tags = CRM_Core_BAO_Tag::getTags('civicrm_case'); if (!empty($tags)) { $this->add('select', 'tag', ts('Select Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );"); }
static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type $contact_type = array(); $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { $form->add('select', 'group', ts('Groups'), $form->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['tags']) { // multiselect for categories $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE); } // add text box for last name, first name, street name, city $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // add text box for last name, first name, street name, city $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); //added contact source $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source')); //added job title $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); //added internal ID $attributes['id']['size'] = 30; $form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"'); //added external ID $attributes['external_identifier']['size'] = 30; $form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"'); $config = CRM_Core_Config::singleton(); if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) { $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)')); } // add checkbox for cms users only $form->addYesNo('uf_user', ts('CMS User?')); // tag all search $form->add('text', 'tag_search', ts('All Tags')); // add search profiles // FIXME: This is probably a part of profiles - need to be // FIXME: eradicated from here when profiles are reworked. $types = array('Participant', 'Contribution', 'Membership'); // get component profiles $componentProfiles = array(); $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types); $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1); $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW); $searchProfiles = array(); foreach ($ufGroups as $key => $var) { if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) { $searchProfiles[$key] = $var['title']; } } $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles); $componentModes = CRM_Contact_Form_Search::getModeSelect(); // unset contributions or participants if user does not have // permission on them if (!CRM_Core_Permission::access('CiviContribute')) { unset($componentModes['2']); } if (!CRM_Core_Permission::access('CiviEvent')) { unset($componentModes['3']); } if (!CRM_Core_Permission::access('CiviMember')) { unset($componentModes['5']); } if (!CRM_Core_Permission::check('view all activities')) { unset($componentModes['4']); } if (count($componentModes) > 1) { $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes); } $form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR'))); // add the option to display relationships $rTypes = CRM_Core_PseudoConstant::relationshipType(); $rSelect = array('' => ts('- Select Relationship Type-')); foreach ($rTypes as $rid => $rValue) { if ($rValue['label_a_b'] == $rValue['label_b_a']) { $rSelect[$rid] = $rValue['label_a_b']; } else { $rSelect["{$rid}_a_b"] = $rValue['label_a_b']; $rSelect["{$rid}_b_a"] = $rValue['label_b_a']; } } $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect); // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'title' => ts('- select -'))); $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND'))); $toggleChoice = array(); $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Exclude'), '1'); $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Include by Privacy Option(s)'), '2'); $form->addGroup($toggleChoice, 'privacy_toggle', 'Privacy Options'); // preferred communication method $comm = CRM_Core_PseudoConstant::pcm(); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v); } $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts('')); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $langPreff = CRM_Core_PseudoConstant::languages(); $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff); }
/** * processing needed for buildForm and later * * @return void * @access public */ function preProcess() { /** * set the varios class variables */ $this->_group =& CRM_Core_PseudoConstant::group(); $this->_groupIterator =& CRM_Core_PseudoConstant::groupIterator(); $this->_tag = CRM_Core_BAO_Tag::getTags(); $this->_done = false; /* * we allow the controller to set force/reset externally, useful when we are being * driven by the wizard framework */ $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Positive', $this); $this->_amtgID = CRM_Utils_Request::retrieve('amtgID', 'Positive', $this); $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $this->_ufGroupID = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_componentMode = CRM_Utils_Request::retrieve('component_mode', 'Positive', $this, false, 1, $_REQUEST); /** * set the button names */ $this->_searchButtonName = $this->getButtonName('refresh'); $this->_printButtonName = $this->getButtonName('next', 'print'); $this->_actionButtonName = $this->getButtonName('next', 'action'); $this->assign('printButtonName', $this->_printButtonName); $this->assign('actionButtonName', $this->_actionButtonName); // reset from session, CRM-3526 $session = CRM_Core_Session::singleton(); if ($this->_force && $session->get('selectedSearchContactIds')) { $session->resetScope('selectedSearchContactIds'); } // if we dont get this from the url, use default if one exsts $config = CRM_Core_Config::singleton(); if ($this->_ufGroupID == null && $config->defaultSearchProfileID != null) { $this->_ufGroupID = $config->defaultSearchProfileID; } /* * assign context to drive the template display, make sure context is valid */ $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'search'); if (!CRM_Utils_Array::value($this->_context, self::validContext())) { $this->_context = 'search'; } $this->set('context', $this->_context); $this->assign('context', $this->_context); $this->_modeValue = $this->getModeValue($this->_componentMode); $this->assign($this->_modeValue); $this->set('selectorName', $this->_selectorName); // get user submitted values // get it from controller only if form has been submitted, else preProcess has set this // $this->controller->isModal( ) returns true if page is // valid, i.e all the validations are true if (!empty($_POST) && !$this->controller->isModal()) { $this->_formValues = $this->controller->exportValues($this->_name); $this->normalizeFormValues(); $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); // also get the uf group id directly from the post value $this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $_POST, $this->_ufGroupID); $this->_formValues['uf_group_id'] = $this->_ufGroupID; $this->set('id', $this->_ufGroupID); // also get the object mode directly from the post value $this->_componentMode = CRM_Utils_Array::value('component_mode', $_POST, $this->_componentMode); } else { $this->_formValues = $this->get('formValues'); $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); } if (empty($this->_formValues)) { //check if group is a smart group (fix for CRM-1255) if ($this->_groupID) { if ($ssId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id')) { $this->_ssID = $ssId; } } // fix for CRM-1907 if (isset($this->_ssID) && $this->_context != 'smog') { // we only retrieve the saved search values if out current values are null $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); //fix for CRM-1505 if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id')) { $this->_params =& CRM_Contact_BAO_SavedSearch::getSearchParams($this->_ssID); } else { $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); } $this->_returnProperties =& $this->returnProperties(); } else { if (isset($this->_ufGroupID)) { // also set the uf group id if not already present $this->_formValues['uf_group_id'] = $this->_ufGroupID; } if (isset($this->_componentMode)) { $this->_formValues['component_mode'] = $this->_componentMode; } } } $this->assign('id', CRM_Utils_Array::value('uf_group_id', $this->_formValues)); // show the context menu only when we’re not searching for deleted contacts; CRM-5673 if (!CRM_Utils_Array::value('deleted_contacts', $this->_formValues)) { require_once 'CRM/Contact/BAO/Contact.php'; $menuItems = CRM_Contact_BAO_Contact::contextMenu(); $primaryActions = CRM_Utils_Array::value('primaryActions', $menuItems, array()); $this->_contextMenu = CRM_Utils_Array::value('moreActions', $menuItems, array()); $this->assign('contextMenu', $primaryActions + $this->_contextMenu); } // CRM_Core_Error::debug( 'f', $this->_formValues ); // CRM_Core_Error::debug( 'p', $this->_params ); if (!isset($this->_componentMode)) { $this->_componentMode = CRM_Contact_BAO_Query::MODE_CONTACTS; } $modeValues = $this->getModeValue($this->_componentMode); require_once str_replace('_', DIRECTORY_SEPARATOR, $this->_modeValue['selectorName']) . '.php'; $this->_selectorName = $this->_modeValue['selectorName']; if (strpos($this->_selectorName, 'CRM_Contact_Selector') !== false) { eval('$selector = new ' . $this->_selectorName . '( $this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, false, true, $this->_context );'); } else { eval('$selector = new ' . $this->_selectorName . '( $this->_params, $this->_action, null, false, null, "search", "advanced" );'); } $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(true); if ($this->_force) { $this->postProcess(); /* * Note that we repeat this, since the search creates and stores * values that potentially change the controller behavior. i.e. things * like totalCount etc */ $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(true); } $controller->moveFromSessionToTemplate(); }
function buildTagFilter() { require_once 'CRM/Core/BAO/Tag.php'; $contactTags = CRM_Core_BAO_Tag::getTags(); if (!empty($contactTags)) { $this->_columns['civicrm_tag'] = array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tagid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contactTags))); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { //this call is for show related cases. if ($this->_showRelatedCases) { return; } $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles'); $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); //adding case manager.CRM-4510. $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType); if (!empty($managerRoleId)) { $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')'; } $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', true); require_once 'CRM/Core/PseudoConstant.php'; $allActTypes = CRM_Core_PseudoConstant::activityType(true, true, false, 'name'); // remove Open Case activity type since we're inside an existing case if (($openActTypeId = array_search('Open Case', $allActTypes)) && array_key_exists($openActTypeId, $aTypes)) { unset($aTypes[$openActTypeId]); } //check for link cases. $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(null, array($this->_caseID)); if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes)) && array_key_exists($linkActTypeId, $aTypes)) { unset($aTypes[$linkActTypeId]); } asort($aTypes); $this->add('select', 'activity_type_id', ts('New Activity'), array('' => ts('- select activity type -')) + $aTypes); if ($this->_hasAccessToAllCases) { $this->add('select', 'report_id', ts('Run QA Audit / Redact'), array('' => ts('- select activity set -')) + $reports); $this->add('select', 'timeline_id', ts('Add Timeline'), array('' => ts('- select activity set -')) + $reports); } $this->addElement('submit', $this->getButtonName('next'), ts('Go'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );")); if ($this->_mergeCases) { $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID); $otherCases = array(); foreach ($allCases as $caseId => $details) { //filter current and own cases. if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) { continue; } $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date']; } if (empty($otherCases)) { $this->_mergeCases = false; $this->assign('mergeCases', $this->_mergeCases); } else { $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases); $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );")); } } $this->add('text', 'change_client_id', ts('Assign to another Client')); $this->add('hidden', 'contact_id', '', array('id' => 'contact_id')); $this->addElement('submit', $this->getButtonName('next', 'edit_client'), ts('Reassign Case'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );")); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus); // activity dates $this->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate')); $this->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate')); require_once "CRM/Core/Permission.php"; if (CRM_Core_Permission::check('administer CiviCRM')) { $this->add('checkbox', 'activity_deleted', ts('Deleted Activities')); } //get case related relationships (Case Role) $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID); //build reporter select $reporters = array("" => ts(' - any reporter - ')); foreach ($caseRelationships as $key => &$value) { $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )"; if ($managerRoleId == $value['relation_type']) { $value['relation'] = $caseRoles[$managerRoleId]; } //calculate roles that don't have relationships if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) { unset($caseRoles[$value['relation_type']]); } } // take all case activity types for search filter, CRM-7187 $aTypesFilter = array(); $allCaseActTypes = CRM_Case_PseudoConstant::activityType(); foreach ($allCaseActTypes as $typeDetails) { if (!in_array($typeDetails['name'], array('Open Case'))) { $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails); } } asort($aTypesFilter); $this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter); $this->assign('caseRelationships', $caseRelationships); //also add client as role. CRM-4438 $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID); $this->assign('caseRoles', $caseRoles); $this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters); // Retrieve ALL client relationships $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, null, null, false); // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles // so they don't show up twice. $clientRelationships = array(); foreach ($relClient as $r) { if (!array_key_exists($r['id'], $caseRelationships)) { $clientRelationships[] = $r; } } $this->assign('clientRelationships', $clientRelationships); // Now global contact list that appears on all cases. $globalGroupInfo = array(); $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); $this->assign('globalRelationships', $relGlobal); $this->assign('globalGroupInfo', $globalGroupInfo); // List of relationship types require_once 'CRM/Contact/BAO/Relationship.php'; $baoRel = new CRM_Contact_BAO_Relationship(); $relType = $baoRel->getRelationType('Individual'); $roleTypes = array(); foreach ($relType as $k => $v) { $roleTypes[substr($k, 0, strpos($k, '_'))] = $v; } $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes); require_once 'CRM/Utils/Hook.php'; $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID); if (is_array($hookCaseSummary)) { $this->assign('hookCaseSummary', $hookCaseSummary); } require_once 'CRM/Core/BAO/EntityTag.php'; require_once 'CRM/Core/BAO/Tag.php'; $allTags = CRM_Core_BAO_Tag::getTags('civicrm_case'); if (!empty($allTags)) { $this->add('select', 'case_tag', ts('Tags'), $allTags, false, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case'); $this->setDefaults(array('case_tag' => $tags)); foreach ($tags as $tid) { $tags[$tid] = $allTags[$tid]; } $this->assign('tags', implode(', ', array_filter($tags))); $this->assign('showTags', true); } else { $this->assign('showTags', false); } // build tagset widget require_once 'CRM/Core/Form/Tag.php'; // see if we have any tagsets which can be assigned to cases $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); if ($parentNames) { $this->assign('showTagsets', true); } else { $this->assign('showTagsets', false); } CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, false, true); $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => ' ', 'isDefault' => true))); }
/** * Build the form object. */ public function buildQuickForm() { //this call is for show related cases. if ($this->_showRelatedCases) { return; } $allowedRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactID); CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header')->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js', 2, 'html-header')->addVars('relationshipTypes', CRM_Contact_Form_Relationship::getRelationshipTypeMetadata($allowedRelationshipTypes)); $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles'); $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); //adding case manager.CRM-4510. $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType); if (!empty($managerRoleId)) { $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')'; } $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE); $allActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'); $emailActivityType = array_search('Email', $allActTypes); $pdfActivityType = array_search('Print PDF Letter', $allActTypes); if ($pdfActivityType) { $this->assign('exportDoc', CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$pdfActivityType}")); } // remove Open Case activity type since we're inside an existing case if ($openActTypeId = array_search('Open Case', $allActTypes)) { unset($aTypes[$openActTypeId]); } // Only show "link cases" activity if other cases exist. $linkActTypeId = array_search('Link Cases', $allActTypes); if ($linkActTypeId) { $count = civicrm_api3('Case', 'getcount', array('check_permissions' => TRUE, 'id' => array('!=' => $this->_caseID), 'is_deleted' => 0)); if (!$count) { unset($aTypes[$linkActTypeId]); } } if (!$xmlProcessor->getNaturalActivityTypeSort()) { asort($aTypes); } $activityLinks = array('' => ts('Add Activity')); foreach ($aTypes as $type => $label) { if ($type == $emailActivityType) { $url = CRM_Utils_System::url('civicrm/activity/email/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } elseif ($type == $pdfActivityType) { $url = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } else { $url = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } $activityLinks[$url] = $label; } $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu fa-calendar-check-o twenty')); if ($this->_hasAccessToAllCases) { $this->add('select', 'report_id', '', array('' => ts('Activity Audit')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu fa-list-alt')); $this->add('select', 'timeline_id', '', array('' => ts('Add Timeline')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu fa-list-ol')); } $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement')); $this->buildMergeCaseForm(); //call activity form self::activityForm($this, $aTypes); //get case related relationships (Case Role) $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID); //save special label because we unset it in the loop $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId]; foreach ($caseRelationships as $key => &$value) { if (!empty($managerRoleId)) { if ($managerRoleId == $value['relation_type']) { $value['relation'] = $managerLabel; } } //calculate roles that don't have relationships if (!empty($caseRoles[$value['relation_type']])) { unset($caseRoles[$value['relation_type']]); } } $this->assign('caseRelationships', $caseRelationships); //also add client as role. CRM-4438 $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID); $this->assign('caseRoles', $caseRoles); // Retrieve ALL client relationships $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE); // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles // so they don't show up twice. $clientRelationships = array(); foreach ($relClient as $r) { if (!array_key_exists($r['id'], $caseRelationships)) { $clientRelationships[] = $r; } } $this->assign('clientRelationships', $clientRelationships); // Now global contact list that appears on all cases. $globalGroupInfo = array(); CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); $this->assign('globalGroupInfo', $globalGroupInfo); // List relationship types for adding an arbitrary new role to the case $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $allowedRelationshipTypes, FALSE, array('class' => 'crm-select2 twenty', 'data-select-params' => '{"allowClear": false}')); $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID); if (is_array($hookCaseSummary)) { $this->assign('hookCaseSummary', $hookCaseSummary); } CRM_Core_BAO_Tag::getTags('civicrm_case', $allTags, NULL, ' ', TRUE); if (!empty($allTags)) { $this->add('select', 'case_tag', ts('Tags'), $allTags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2')); $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case'); $this->setDefaults(array('case_tag' => $tags)); foreach ($tags as $tid) { if (isset($allTags[$tid])) { $tags[$tid] = $allTags[$tid]; } else { unset($tags[$tid]); } } $this->assign('tags', implode(', ', array_filter($tags))); $this->assign('showTags', TRUE); } else { $this->assign('showTags', FALSE); } // build tagset widget // see if we have any tagsets which can be assigned to cases $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); $tagSetTags = array(); if ($parentNames) { $this->assign('showTags', TRUE); $tagSetItems = civicrm_api3('entityTag', 'get', array('entity_id' => $this->_caseID, 'entity_table' => 'civicrm_case', 'tag_id.parent_id.is_tagset' => 1, 'options' => array('limit' => 0), 'return' => array("tag_id.parent_id", "tag_id.parent_id.name", "tag_id.name"))); foreach ($tagSetItems['values'] as $tag) { $tagSetTags += array($tag['tag_id.parent_id'] => array('name' => $tag['tag_id.parent_id.name'], 'items' => array())); $tagSetTags[$tag['tag_id.parent_id']]['items'][] = $tag['tag_id.name']; } } $this->assign('tagSetTags', $tagSetTags); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE); $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => ' ', 'isDefault' => TRUE))); }
/** * takes an associative array and creates a contact tags object * * * @param array $params (reference ) an assoc array of name/value pairs * @param array $contactId contact id * * @return void * @access public * @static */ static function create(&$params, $entityTable, $entityID) { // get categories for the contact id $entityTag =& CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable); // get the list of all the categories require_once 'CRM/Core/BAO/Tag.php'; $allTag = CRM_Core_BAO_Tag::getTags($entityTable); // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!is_array($params)) { $params = array(); } // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!is_array($entityTag)) { $entityTag = array(); } // check which values has to be inserted/deleted for contact foreach ($allTag as $key => $varValue) { $tagParams['entity_table'] = $entityTable; $tagParams['entity_id'] = $entityID; $tagParams['tag_id'] = $key; if (array_key_exists($key, $params) && !array_key_exists($key, $entityTag)) { // insert a new record CRM_Core_BAO_EntityTag::add($tagParams); } else { if (!array_key_exists($key, $params) && array_key_exists($key, $entityTag)) { // delete a record for existing contact CRM_Core_BAO_EntityTag::del($tagParams); } } } }
public function buildQuickForm() { if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', false); $button = ts('Delete'); if ($this->_action & CRM_Core_Action::RENEW) { $button = ts('Restore'); } $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if (!$this->_single && !empty($this->_contactIds)) { $withArray = array(); require_once 'CRM/Contact/BAO/Contact.php'; foreach ($this->_contactIds as $contactId) { $withDisplayName = self::_getDisplayNameById($contactId); $withArray[] = "\"{$withDisplayName}\" "; } $this->assign('with', implode(', ', $withArray)); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //build other activity links require_once 'CRM/Activity/Form/ActivityLinks.php'; CRM_Activity_Form_ActivityLinks::buildQuickForm(); //enable form element (ActivityLinks sets this true) $this->assign('suppressForm', false); $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], false, array('onchange' => "buildCustomData( 'Activity', this.value );")); //freeze for update mode. if ($this->_action & CRM_Core_Action::UPDATE) { $element->freeze(); } foreach ($this->_fields as $field => $values) { if (CRM_Utils_Array::value($field, $this->_fields)) { $attribute = null; if (CRM_Utils_Array::value('attributes', $values)) { $attribute = $values['attributes']; } $required = false; if (CRM_Utils_Array::value('required', $values)) { $required = true; } if ($values['type'] == 'wysiwyg') { $this->addWysiwyg($field, $values['label'], $attribute, $required); } else { $this->add($values['type'], $field, $values['label'], $attribute, $required); } } } $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger'); $this->addRule('interval', ts('Please enter the follow-up interval as a number (integers only).'), 'positiveInteger'); $this->addDateTime('activity_date_time', ts('Date'), true, array('formatType' => 'activityDateTime')); //autocomplete url $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", false, null, false); $this->assign('dataUrl', $dataUrl); //tokeninput url $tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", false, null, false); $this->assign('tokenUrl', $tokenUrl); $admin = CRM_Core_Permission::check('administer CiviCRM'); //allow to edit sourcecontactfield field if context is civicase. if ($this->_context == 'caseActivity') { $admin = true; } $this->assign('admin', $admin); $sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], null, $admin); $hiddenSourceContactField =& $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid')); $targetContactField =& $this->add('text', 'target_contact_id', ts('target')); $assigneeContactField =& $this->add('text', 'assignee_contact_id', ts('assignee')); if ($sourceContactField->getValue()) { $this->assign('source_contact', $sourceContactField->getValue()); } else { if ($this->_currentUserId) { // we're setting currently LOGGED IN user as source for this activity $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId)); } } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Activity'); $this->assign('customDataSubType', $this->_activityTypeId); $this->assign('entityID', $this->_activityId); if ($this->_targetContactId) { $defaultTargetContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_targetContactId, 'sort_name'); $this->assign('target_contact_value', $defaultTargetContactName); } require_once 'CRM/Core/BAO/Tag.php'; $tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if (!empty($tags)) { $this->add('select', 'tag', ts('Tags'), $tags, false, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } // build tag widget require_once 'CRM/Core/Form/Tag.php'; $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId, false, true); // check for survey activity $this->_isSurveyActivity = false; if ($this->_activityId) { require_once 'CRM/Campaign/BAO/Survey.php'; $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId); if ($this->_isSurveyActivity) { $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id'); $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId); if ($responseOptions) { $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions)); } $surveyTitle = null; if ($surveyId) { $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title'); } $this->assign('surveyTitle', $surveyTitle); } } $this->assign('surveyActivity', $this->_isSurveyActivity); // if we're viewing, we're assigning different buttons than for adding/editing if ($this->_action & CRM_Core_Action::VIEW) { if (isset($this->_groupTree)) { CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree); } $buttons = array(); // do check for permissions require_once 'CRM/Case/BAO/Case.php'; if (CRM_Case_BAO_Case::checkPermission($this->_activityId, 'File On Case', $this->_activityTypeId)) { $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'subName' => 'file_on_case', 'js' => array('onClick' => "Javascript:fileOnCase( \"file\", {$this->_activityId} ); return false;")); } // form should be frozen for view mode $this->freeze(); $buttons[] = array('type' => 'cancel', 'name' => ts('Done')); $this->addButtons($buttons); } else { $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.')); $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");"); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); } if ($this->_activityTypeFile) { eval("CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );"); } if ($this->_activityTypeFile) { eval('$this->addFormRule' . "(array('CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}', 'formrule'), \$this);"); } $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { //this call is for show related cases. if ($this->_showRelatedCases) { return; } CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js')->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js'); $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles'); $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); //adding case manager.CRM-4510. $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType); if (!empty($managerRoleId)) { $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')'; } $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE); $allActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'); $emailActivityType = array_search('Email', $allActTypes); $pdfActivityType = array_search('Print PDF Letter', $allActTypes); // remove Open Case activity type since we're inside an existing case if ($openActTypeId = array_search('Open Case', $allActTypes)) { unset($aTypes[$openActTypeId]); } //check for link cases. $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(NULL, array($this->_caseID)); if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes))) { unset($aTypes[$linkActTypeId]); } if (!$xmlProcessor->getNaturalActivityTypeSort()) { asort($aTypes); } $activityLinks = array('' => ts('Add Activity')); foreach ($aTypes as $type => $label) { if ($type == $emailActivityType) { $url = CRM_Utils_System::url('civicrm/activity/email/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } else { if ($type == $pdfActivityType) { $url = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } else { $url = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE); } } $activityLinks[$url] = $label; } $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-plus twenty')); if ($this->_hasAccessToAllCases) { $this->add('select', 'report_id', '', array('' => ts('Activity Audit')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-clipboard')); $this->add('select', 'timeline_id', '', array('' => ts('Add Timeline')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-play')); } $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement')); if ($this->_mergeCases) { $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID); $otherCases = array(); foreach ($allCases as $caseId => $details) { //filter current and own cases. if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) { continue; } $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date']; } if (empty($otherCases)) { $this->_mergeCases = FALSE; $this->assign('mergeCases', $this->_mergeCases); } else { $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases, FALSE, array('class' => 'crm-select2 huge')); $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'crm-form-submit-inline hiddenElement')); } } //call activity form self::activityForm($this); //get case related relationships (Case Role) $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID); //save special label because we unset it in the loop $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId]; foreach ($caseRelationships as $key => &$value) { if (!empty($managerRoleId)) { if ($managerRoleId == $value['relation_type']) { $value['relation'] = $managerLabel; } } //calculate roles that don't have relationships if (!empty($caseRoles[$value['relation_type']])) { unset($caseRoles[$value['relation_type']]); } } $this->assign('caseRelationships', $caseRelationships); //also add client as role. CRM-4438 $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID); $this->assign('caseRoles', $caseRoles); // Retrieve ALL client relationships $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE); // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles // so they don't show up twice. $clientRelationships = array(); foreach ($relClient as $r) { if (!array_key_exists($r['id'], $caseRelationships)) { $clientRelationships[] = $r; } } $this->assign('clientRelationships', $clientRelationships); // Now global contact list that appears on all cases. $globalGroupInfo = array(); CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); $this->assign('globalGroupInfo', $globalGroupInfo); // List of relationship types $baoRel = new CRM_Contact_BAO_Relationship(); $relType = $baoRel->getRelationType('Individual'); $roleTypes = array(); foreach ($relType as $k => $v) { $roleTypes[substr($k, 0, strpos($k, '_'))] = $v; } $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes, FALSE, array('class' => 'crm-select2 twenty')); $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID); if (is_array($hookCaseSummary)) { $this->assign('hookCaseSummary', $hookCaseSummary); } $allTags = CRM_Core_BAO_Tag::getTags('civicrm_case'); if (!empty($allTags)) { $this->add('select', 'case_tag', ts('Tags'), $allTags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2')); $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case'); $this->setDefaults(array('case_tag' => $tags)); foreach ($tags as $tid) { if (isset($allTags[$tid])) { $tags[$tid] = $allTags[$tid]; } else { unset($tags[$tid]); } } $this->assign('tags', implode(', ', array_filter($tags))); $this->assign('showTags', TRUE); } else { $this->assign('showTags', FALSE); } // build tagset widget // see if we have any tagsets which can be assigned to cases $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); if ($parentNames) { $this->assign('showTagsets', TRUE); } else { $this->assign('showTagsets', FALSE); } CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE); $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => ' ', 'isDefault' => TRUE))); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { // text for sort_name $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $this->_group = CRM_Core_PseudoConstant::group(); // multiselect for groups if ($this->_group) { $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')); } // multiselect for tags $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2')); } CRM_Contribute_BAO_Query::buildSearchForm($this); /* * add form checkboxes for each row. This is needed out here to conform to QF protocol * of all elements being declared in builQuickForm */ $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row')); } } $total = $cancel = 0; $permission = CRM_Core_Permission::getPermission(); $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission); $this->add('select', 'task', ts('Actions:') . ' ', $tasks); $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);")); // need to perform tasks on all or selected items ? using radio_ts(task selection) for it $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked')); $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE))); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); // text for sort_name $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $this->_group = CRM_Core_PseudoConstant::nestedGroup(); // multiselect for groups if ($this->_group) { $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')); } // multiselect for tags $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2')); } CRM_Contribute_BAO_Query::buildSearchForm($this); $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addRowSelectors($rows); } $permission = CRM_Core_Permission::getPermission(); $queryParams = $this->get('queryParams'); $softCreditFiltering = FALSE; if (!empty($queryParams)) { $softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams); } $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering); $this->addTaskMenu($tasks); } }
static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE) { if (!$numAttachments) { $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments'); } // Assign maxAttachments count to template for help message $form->assign('maxAttachments', $numAttachments); $config = CRM_Core_Config::singleton(); // set default max file size as 2MB $maxFileSize = $config->maxFileSize ? $config->maxFileSize : 2; $currentAttachmentInfo = self::getEntityFile($entityTable, $entityID, TRUE); $totalAttachments = 0; if ($currentAttachmentInfo) { $totalAttachments = count($currentAttachmentInfo); $form->add('checkbox', 'is_delete_attachment', ts('Delete All Attachment(s)')); $form->assign('currentAttachmentInfo', $currentAttachmentInfo); } else { $form->assign('currentAttachmentInfo', NULL); } if ($totalAttachments) { if ($totalAttachments >= $numAttachments) { $numAttachments = 0; } else { $numAttachments -= $totalAttachments; } } $form->assign('numAttachments', $numAttachments); $tags = CRM_Core_BAO_Tag::getTags('civicrm_file'); // get tagset info $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_file'); // add attachments for ($i = 1; $i <= $numAttachments; $i++) { $form->addElement('file', "attachFile_{$i}", ts('Attach File'), 'size=30 maxlength=60'); $form->addUploadElement("attachFile_{$i}"); $form->setMaxFileSize($maxFileSize * 1024 * 1024); $form->addRule("attachFile_{$i}", ts('File size should be less than %1 MByte(s)', array(1 => $maxFileSize)), 'maxfilesize', $maxFileSize * 1024 * 1024); $form->addElement('text', "attachDesc_{$i}", ts('Description'), 'size=40 maxlength=255'); if (!empty($tags)) { $form->add('select', "tag_{$i}", ts('Tags'), $tags, FALSE, array('id' => "tags_{$i}", 'multiple' => 'multiple', 'title' => ts('- select -'))); } } // build tagset widget CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, TRUE, TRUE, FALSE); }
/** * This function is to build form elements * params object $form object of the form * * @param Object $form the form object that we are operating on * @param int $contactId contact id * @param int $type what components are we interested in * @param boolean $visibility visibility of the field * @param string $groupName if used for building group block * @param string $tagName if used for building tag block * @param string $fieldName this is used in batch profile(i.e to build multiple blocks) * * @static * @access public */ static function buildQuickForm(&$form, $contactId = 0, $type = CRM_Contact_Form_Edit_TagsandGroups::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL) { if (!isset($form->_tagGroup)) { $form->_tagGroup = array(); } // NYSS 5670 if (!$contactId && !empty($form->_contactId)) { $contactId = $form->_contactId; } $type = (int) $type; if ($type & CRM_Contact_Form_Edit_TagsandGroups::GROUP) { $fName = 'group'; if ($fieldName) { $fName = $fieldName; } $elements = array(); $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { $ids = "= {$groupID}"; } else { if ($visibility) { $group = CRM_Core_PseudoConstant::allGroup(); } else { $group = CRM_Core_PseudoConstant::group(); } $ids = implode(',', array_keys($group)); $ids = 'IN (' . $ids . ')'; } if ($groupID || !empty($group)) { $sql = "\n SELECT id, title, description, visibility\n FROM civicrm_group\n WHERE id {$ids}\n ORDER BY title\n "; $dao = CRM_Core_DAO::executeQuery($sql); $attributes['skiplabel'] = TRUE; while ($dao->fetch()) { // make sure that this group has public visibility if ($visibility && $dao->visibility == 'User and User Admin Only') { continue; } $form->_tagGroup[$fName][$dao->id]['description'] = $dao->description; $elements[] =& $form->addElement('advcheckbox', $dao->id, NULL, $dao->title, $attributes); } if (!empty($elements)) { $form->addGroup($elements, $fName, $groupName, ' <br />'); $form->assign('groupCount', count($elements)); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } } } if ($type & CRM_Contact_Form_Edit_TagsandGroups::TAG) { $fName = 'tag'; if ($fieldName) { $fName = $fieldName; } $form->_tagGroup[$fName] = 1; $elements = array(); $tag = CRM_Core_BAO_Tag::getTags(); foreach ($tag as $id => $name) { $elements[] = $form->createElement('checkbox', $id, NULL, $name); } if (!empty($elements)) { $form->addGroup($elements, $fName, $tagName, '<br />'); $form->assign('tagCount', count($elements)); } if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required'); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE); } $form->assign('tagGroup', $form->_tagGroup); }
/** * add all the elements shared between case activity search and advanaced search * * @access public * * @return void * @static */ static function buildSearchForm(&$form) { $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); asort($activityOptions); foreach ($activityOptions as $activityID => $activity) { $form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", NULL, $activity, array('onClick' => 'showCustomData( this.id );')); } CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE); $activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to')); $form->addRadio('activity_role', NULL, $activityRoles, NULL, '<br />'); $form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); foreach ($activityStatus as $activityStatusID => $activityStatusName) { $activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName); } $form->addGroup($activity_status, 'activity_status', ts('Activity Status')); $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1)); $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $form->addElement('checkbox', 'activity_test', ts('Find Test Activities?')); $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if ($activity_tags) { foreach ($activity_tags as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName); } } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE); $surveys = CRM_Campaign_BAO_Survey::getSurveys(); if ($surveys) { $form->add('select', 'activity_survey_id', ts('Survey'), array('' => ts('- none -')) + $surveys, FALSE); } $extends = array('Activity'); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends); if ($groupDetails) { $form->assign('activityGroupTree', $groupDetails); foreach ($groupDetails as $group) { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE); } } } CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id'); //add engagement level CRM-7775 $buildEngagementLevel = FALSE; if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) { $buildEngagementLevel = TRUE; $form->add('select', 'activity_engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel()); } $form->assign('buildEngagementLevel', $buildEngagementLevel); }
/** * Build the tag filter field to display on the filters tab. */ public function buildTagFilter() { $contactTags = CRM_Core_BAO_Tag::getTags($this->_tagFilterTable); if (!empty($contactTags)) { $this->_columns['civicrm_tag'] = array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tagid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contactTags))); } }
/** * @param CRM_Core_Form $form */ public static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title) $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, ' ', TRUE); $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')); $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type'); $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2')); $form->add('hidden', 'group_search_selected', 'group'); } } if ($form->_searchOptions['tags']) { // multiselect for categories $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;')); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE); $used_for = CRM_Core_OptionGroup::values('tag_used_for'); $tagsTypes = array(); $showAllTagTypes = FALSE; foreach ($used_for as $key => $value) { //check tags for every type and find if there are any defined $tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL); // check if there are tags other than contact type, if no - keep checkbox hidden on adv search // we will hide searching contact by attachments tags until it will be implemented in core if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') { //if tags exists then add type to display in adv search form help text $tagsTypes[] = ts($value); $showAllTagTypes = TRUE; } } $tagTypesText = implode(" or ", $tagsTypes); if ($showAllTagTypes) { $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText))); $form->add('hidden', 'tag_types_text', $tagTypesText); } } // add text box for last name, first name, street name, city $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // add text box for last name, first name, street name, city $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); //added contact source $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source')); //added job title $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title')); //added internal ID $form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id')); $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger'); //added external ID $form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier')); if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) { $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)')); } // add checkbox for cms users only $form->addYesNo('uf_user', ts('CMS User?'), TRUE); // tag all search $form->add('text', 'tag_search', ts('All Tags')); // add search profiles // FIXME: This is probably a part of profiles - need to be // FIXME: eradicated from here when profiles are reworked. $types = array('Participant', 'Contribution', 'Membership'); // get component profiles $componentProfiles = array(); $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types); $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1); $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW); $searchProfiles = array(); foreach ($ufGroups as $key => $var) { if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) { $searchProfiles[$key] = $var['title']; } } $form->add('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles, FALSE, array('class' => 'crm-select2')); $componentModes = CRM_Contact_Form_Search::getModeSelect(); // unset contributions or participants if user does not have // permission on them if (!CRM_Core_Permission::access('CiviContribute')) { unset($componentModes['2']); } if (!CRM_Core_Permission::access('CiviEvent')) { unset($componentModes['3']); } if (!CRM_Core_Permission::access('CiviMember')) { unset($componentModes['5']); } if (!CRM_Core_Permission::check('view all activities')) { unset($componentModes['4']); } if (count($componentModes) > 1) { $form->add('select', 'component_mode', ts('Display Results As'), $componentModes, FALSE, array('class' => 'crm-select2')); } $form->addRadio('operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')), array('allowClear' => FALSE)); // add the option to display relationships $rTypes = CRM_Core_PseudoConstant::relationshipType(); $rSelect = array('' => ts('- Select Relationship Type-')); foreach ($rTypes as $rid => $rValue) { if ($rValue['label_a_b'] == $rValue['label_b_a']) { $rSelect[$rid] = $rValue['label_a_b']; } else { $rSelect["{$rid}_a_b"] = $rValue['label_a_b']; $rSelect["{$rid}_b_a"] = $rValue['label_b_a']; } } $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect, array('class' => 'crm-select2')); // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'class' => 'crm-select2')); $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND'))); $options = array(1 => ts('Exclude'), 2 => ts('Include by Privacy Option(s)')); $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, array('allowClear' => FALSE)); // preferred communication method $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v); } $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ''); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search')); // Phone search $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2')); $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2')); }
/** * This function is to build form elements * params object $form object of the form * * @param Object $form the form object that we are operating on * @param int $contactId contact id * @param int $type what components are we interested in * @param boolean $visibility visibility of the field * @param string $groupName if used for building group block * @param string $tagName if used for building tag block * @param string $fieldName this is used in batch profile(i.e to build multiple blocks) * * @static * @access public */ static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox') { if (!isset($form->_tagGroup)) { $form->_tagGroup = array(); } // NYSS 5670 if (!$contactId && !empty($form->_contactId)) { $contactId = $form->_contactId; } $type = (int) $type; if ($type & self::GROUP) { $fName = 'group'; if ($fieldName) { $fName = $fieldName; } $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { $ids = array($groupID => $groupID); } else { if ($visibility) { $group = CRM_Core_PseudoConstant::allGroup(); } else { $group = CRM_Core_PseudoConstant::nestedGroup(); } $ids = $group; } if ($groupID || !empty($group)) { $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids); $attributes['skiplabel'] = TRUE; $elements = array(); $groupsOptions = array(); foreach ($groups as $id => $group) { // make sure that this group has public visibility if ($visibility && $group['visibility'] == 'User and User Admin Only') { continue; } if ($groupElementType == 'crmasmSelect') { $groupsOptions[$id] = $group['title']; } else { $form->_tagGroup[$fName][$id]['description'] = $group['description']; $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes); } } if ($groupElementType == 'crmasmSelect' && !empty($groupsOptions)) { $form->add('select', $fName, ts('%1', array(1 => $groupName)), $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'title' => ts('- select -'))); $form->assign('groupCount', count($groupsOptions)); } if ($groupElementType == 'checkbox' && !empty($elements)) { $form->addGroup($elements, $fName, $groupName, ' <br />'); $form->assign('groupCount', count($elements)); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } $form->assign('groupElementType', $groupElementType); } } if ($type & self::TAG) { $fName = 'tag'; if ($fieldName) { $fName = $fieldName; } $form->_tagGroup[$fName] = 1; $elements = array(); $tag = CRM_Core_BAO_Tag::getTags(); foreach ($tag as $id => $name) { $elements[] = $form->createElement('checkbox', $id, NULL, $name); } if (!empty($elements)) { $form->addGroup($elements, $fName, $tagName, '<br />'); $form->assign('tagCount', count($elements)); } if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required'); } // build tag widget $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, TRUE, TRUE); } $form->assign('tagGroup', $form->_tagGroup); }
/** * Method to get groups * * @return array * @access protected */ protected function getTags() { return CRM_Core_BAO_Tag::getTags(); }
/** * Processing needed for buildForm and later. */ public function preProcess() { // set the various class variables $this->_group = CRM_Core_PseudoConstant::group(); $this->_groupIterator = CRM_Core_PseudoConstant::groupIterator(); $this->_tag = CRM_Core_BAO_Tag::getTags(); $this->_done = FALSE; /* * we allow the controller to set force/reset externally, useful when we are being * driven by the wizard framework */ $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Positive', $this); $this->_amtgID = CRM_Utils_Request::retrieve('amtgID', 'Positive', $this); $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $this->_ufGroupID = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_componentMode = CRM_Utils_Request::retrieve('component_mode', 'Positive', $this, FALSE, 1, $_REQUEST); $this->_operator = CRM_Utils_Request::retrieve('operator', 'String', $this, FALSE, 1, $_REQUEST, 'AND'); /** * set the button names */ $this->_searchButtonName = $this->getButtonName('refresh'); $this->_actionButtonName = $this->getButtonName('next', 'action'); $this->assign('actionButtonName', $this->_actionButtonName); // reset from session, CRM-3526 $session = CRM_Core_Session::singleton(); if ($this->_force && $session->get('selectedSearchContactIds')) { $session->resetScope('selectedSearchContactIds'); } // if we dont get this from the url, use default if one exsts $config = CRM_Core_Config::singleton(); if ($this->_ufGroupID == NULL && $config->defaultSearchProfileID != NULL) { $this->_ufGroupID = $config->defaultSearchProfileID; } // assign context to drive the template display, make sure context is valid $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search'); if (!CRM_Utils_Array::value($this->_context, self::validContext())) { $this->_context = 'search'; } $this->set('context', $this->_context); $this->assign('context', $this->_context); $this->_modeValue = self::getModeValue($this->_componentMode); $this->assign($this->_modeValue); $this->set('selectorName', self::$_selectorName); // get user submitted values // get it from controller only if form has been submitted, else preProcess has set this // $this->controller->isModal( ) returns TRUE if page is // valid, i.e all the validations are TRUE if (!empty($_POST) && !$this->controller->isModal()) { $this->_formValues = $this->controller->exportValues($this->_name); $this->normalizeFormValues(); $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); // also get the uf group id directly from the post value $this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $_POST, $this->_ufGroupID); $this->_formValues['uf_group_id'] = $this->_ufGroupID; $this->set('id', $this->_ufGroupID); // also get the object mode directly from the post value $this->_componentMode = CRM_Utils_Array::value('component_mode', $_POST, $this->_componentMode); // also get the operator from the post value if set $this->_operator = CRM_Utils_Array::value('operator', $_POST, $this->_operator); $this->_formValues['operator'] = $this->_operator; $this->set('operator', $this->_operator); } else { $this->_formValues = $this->get('formValues'); $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); if (!empty($this->_ufGroupID)) { $this->set('id', $this->_ufGroupID); } } if (empty($this->_formValues)) { //check if group is a smart group (fix for CRM-1255) if ($this->_groupID) { if ($ssId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id')) { $this->_ssID = $ssId; } } // fix for CRM-1907 if (isset($this->_ssID) && $this->_context != 'smog') { // we only retrieve the saved search values if out current values are null $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); //fix for CRM-1505 if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id')) { $this->_params = CRM_Contact_BAO_SavedSearch::getSearchParams($this->_ssID); } else { $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); } $this->_returnProperties =& $this->returnProperties(); } else { if (isset($this->_ufGroupID)) { // also set the uf group id if not already present $this->_formValues['uf_group_id'] = $this->_ufGroupID; } if (isset($this->_componentMode)) { $this->_formValues['component_mode'] = $this->_componentMode; } if (isset($this->_operator)) { $this->_formValues['operator'] = $this->_operator; } // FIXME: we should generalise in a way that components could inject url-filters // just like they build their own form elements foreach (array('mailing_id', 'mailing_delivery_status', 'mailing_open_status', 'mailing_click_status', 'mailing_reply_status', 'mailing_optout', 'mailing_forward', 'mailing_unsubscribe', 'mailing_date_low', 'mailing_date_high') as $mailingFilter) { $type = 'String'; if ($mailingFilter == 'mailing_id' && ($filterVal = CRM_Utils_Request::retrieve('mailing_id', 'Positive', $this))) { $this->_formValues[$mailingFilter] = array($filterVal); } elseif ($filterVal = CRM_Utils_Request::retrieve($mailingFilter, $type, $this)) { $this->_formValues[$mailingFilter] = $filterVal; } if ($filterVal) { $this->_openedPanes['Mailings'] = 1; $this->_formValues['hidden_CiviMail'] = 1; } } } } $this->assign('id', CRM_Utils_Array::value('uf_group_id', $this->_formValues)); $operator = CRM_Utils_Array::value('operator', $this->_formValues, 'AND'); $this->set('queryOperator', $operator); if ($operator == 'OR') { $this->assign('operator', ts('OR')); } else { $this->assign('operator', ts('AND')); } // show the context menu only when we’re not searching for deleted contacts; CRM-5673 if (empty($this->_formValues['deleted_contacts'])) { $menuItems = CRM_Contact_BAO_Contact::contextMenu(); $primaryActions = CRM_Utils_Array::value('primaryActions', $menuItems, array()); $this->_contextMenu = CRM_Utils_Array::value('moreActions', $menuItems, array()); $this->assign('contextMenu', $primaryActions + $this->_contextMenu); } if (!isset($this->_componentMode)) { $this->_componentMode = CRM_Contact_BAO_Query::MODE_CONTACTS; } $modeValues = self::getModeValue($this->_componentMode); self::$_selectorName = $this->_modeValue['selectorName']; $setDynamic = FALSE; if (strpos(self::$_selectorName, 'CRM_Contact_Selector') !== FALSE) { $selector = new self::$_selectorName($this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, FALSE, TRUE, $this->_context, $this->_contextMenu); $setDynamic = TRUE; } else { $selector = new self::$_selectorName($this->_params, $this->_action, NULL, FALSE, NULL, "search", "advanced"); } $selector->setKey($this->controller->_key); $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(TRUE); $controller->setDynamicAction($setDynamic); if ($this->_force) { $this->postProcess(); /* * Note that we repeat this, since the search creates and stores * values that potentially change the controller behavior. i.e. things * like totalCount etc */ $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(TRUE); $controller->setDynamicAction($setDynamic); } $controller->moveFromSessionToTemplate(); }
static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { // add checkboxes for contact type $contact_type = array(); require_once 'CRM/Contact/BAO/ContactType.php'; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(); if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, false, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['groups']) { // multiselect for groups if ($form->_group) { $form->add('select', 'group', ts('Groups'), $form->_group, false, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -'))); } } if ($form->_searchOptions['tags']) { // multiselect for categories require_once 'CRM/Core/BAO/Tag.php'; $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $form->add('select', 'contact_tags', ts('Tags'), $contactTags, false, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -'))); } require_once 'CRM/Core/Form/Tag.php'; require_once 'CRM/Core/BAO/Tag.php'; $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact'); CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', null, true); } // add text box for last name, first name, street name, city $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // add text box for last name, first name, street name, city $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); //added contact source $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source')); //added job title $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); $config =& CRM_Core_Config::singleton(); if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) { $form->add('checkbox', 'deleted_contacts', ts('Search in Trash (deleted contacts)')); } // add checkbox for cms users only $form->addYesNo('uf_user', ts('CMS User?')); // add search profiles require_once 'CRM/Core/BAO/UFGroup.php'; // FIXME: This is probably a part of profiles - need to be // FIXME: eradicated from here when profiles are reworked. $types = array('Participant', 'Contribution', 'Membership'); // get component profiles $componentProfiles = array(); $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types); $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1); $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW); $searchProfiles = array(); foreach ($ufGroups as $key => $var) { if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) { $searchProfiles[$key] = $var['title']; } } $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles); require_once 'CRM/Contact/Form/Search.php'; $componentModes =& CRM_Contact_Form_Search::getModeSelect(); // unset contributions or participants if user does not have // permission on them if (!CRM_Core_Permission::access('CiviContribute')) { unset($componentModes['2']); } if (!CRM_Core_Permission::access('CiviEvent')) { unset($componentModes['3']); } if (!CRM_Core_Permission::check('view all activities')) { unset($componentModes['4']); } if (count($componentModes) > 1) { $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes); } // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $t = CRM_Core_SelectValues::privacy(); $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).'); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']); $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']); $form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>')); // preferred communication method require_once 'CRM/Core/PseudoConstant.php'; $comm = CRM_Core_PseudoConstant::pcm(); $commPreff = array(); foreach ($comm as $k => $v) { $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v); } $onHold[] = HTML_QuickForm::createElement('advcheckbox', 'on_hold', null, ts('')); $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold')); $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method')); //CRM-6138 Preferred Language $langPreff = CRM_Core_PseudoConstant::languages(); $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff); }