コード例 #1
0
ファイル: AJAX.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Retrieve unclosed cases.
  */
 public static function unclosedCases()
 {
     $params = array('limit' => Civi::settings()->get('search_autocomplete_count'), 'sort_name' => CRM_Utils_Type::escape(CRM_Utils_Array::value('term', $_GET, ''), 'String'));
     $excludeCaseIds = array();
     if (!empty($_GET['excludeCaseIds'])) {
         $excludeCaseIds = explode(',', CRM_Utils_Type::escape($_GET['excludeCaseIds'], 'String'));
     }
     $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds, TRUE, TRUE);
     $results = array();
     foreach ($unclosedCases as $caseId => $details) {
         $results[] = array('id' => $caseId, 'label' => $details['sort_name'] . ' - ' . $details['case_type'] . ($details['end_date'] ? ' (' . ts('closed') . ')' : ''), 'label_class' => $details['end_date'] ? 'strikethrough' : '', 'description' => array("#{$caseId}: " . $details['case_subject'] . ' (' . $details['case_status'] . ')'), 'extra' => $details);
     }
     CRM_Utils_JSON::output($results);
 }
コード例 #2
0
ファイル: AJAX.php プロジェクト: hguru/224Civi
 /**
  * Retrieve unclosed cases.
  */
 static function unclosedCases()
 {
     $criteria = explode('-', CRM_Utils_Type::escape(CRM_Utils_Array::value('s', $_GET), 'String'));
     $limit = NULL;
     if ($limit = CRM_Utils_Array::value('limit', $_GET)) {
         $limit = CRM_Utils_Type::escape($limit, 'Integer');
     }
     $params = array('limit' => $limit, 'case_type' => trim(CRM_Utils_Array::value(1, $criteria)), 'sort_name' => trim(CRM_Utils_Array::value(0, $criteria)));
     $excludeCaseIds = array();
     if ($caseIdStr = CRM_Utils_Array::value('excludeCaseIds', $_GET)) {
         $excludeIdStr = CRM_Utils_Type::escape($caseIdStr, 'String');
         $excludeCaseIds = explode(',', $excludeIdStr);
     }
     $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds);
     foreach ($unclosedCases as $caseId => $details) {
         echo $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ') ' . "|{$caseId}|" . $details['contact_id'] . '|' . $details['case_type'] . '|' . $details['sort_name'] . "\n";
     }
     CRM_Utils_System::civiExit();
 }
コード例 #3
0
 /**
  * Set default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array('id' => $this->_activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $defaults['file_on_case_activity_subject'] = $defaults['subject'];
     $defaults['file_on_case_target_contact_id'] = $defaults['target_contact'];
     // If this contact has an open case, supply it as a default
     $cid = CRM_Utils_Request::retrieve('cid', 'Integer');
     if ($cid) {
         $cases = CRM_Case_BAO_Case::getUnclosedCases(array('contact_id' => $cid), $this->_currentCaseId);
         foreach ($cases as $id => $details) {
             $defaults['file_on_case_unclosed_case_id'] = $id;
             $value = array('label' => $details['sort_name'] . ' - ' . $details['case_type'], 'extra' => array('contact_id' => $cid));
             $this->updateElementAttr('file_on_case_unclosed_case_id', array('data-value' => json_encode($value)));
             break;
         }
     }
     return $defaults;
 }
コード例 #4
0
 /**
  * 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' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
 }
コード例 #5
0
ファイル: CaseTest.php プロジェクト: hyebahi/civicrm-core
 public function testGetUnclosedCases()
 {
     $params = array('case_type' => 'ousing Suppor');
     $cases = CRM_Case_BAO_Case::getUnclosedCases($params);
     $this->assertEquals('Housing Support', $cases[1]['case_type']);
 }
コード例 #6
0
ファイル: Activity.php プロジェクト: bhirsch/voipdev
 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' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', '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;
             }
             $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/contactlist", "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);
     }
     // 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();
         $config =& CRM_Core_Config::singleton();
         require_once 'CRM/Core/OptionGroup.php';
         $emailActivityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name');
         if (in_array('CiviCase', $config->enableComponents) && $this->_activityTypeId == $emailActivityTypeID) {
             $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'js' => array('onClick' => "Javascript:fileOnCase(); return false;"));
             require_once 'CRM/Case/BAO/Case.php';
             $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases();
             $caseList = array();
             foreach ($unclosedCases as $case_id => $case_data) {
                 $caseList[$case_id . '_' . $case_data['contact_id']] = $case_data['display_name'] . ' - ' . $case_data['case_type'];
             }
             // Don't want to freeze the whole form since then this select gets frozen too,
             // so get the current list of elements, add our element, then freeze the previous list.
             $temp_elementList = array();
             foreach ($this->_elements as $e) {
                 $temp_elementList[] = $e->getName();
             }
             $this->add('select', 'case_select', ts('Open Cases'), array('' => ts('- select case -')) + $caseList, true);
             $this->add('text', 'case_subject', ts('New Subject'), array('size' => 50));
             $this->freeze($temp_elementList);
         } else {
             $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);
 }
コード例 #7
0
 /**
  * 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' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true)));
 }