static function preProcess(&$form) { if (!isset($form->_caseId)) { CRM_Core_Error::fatal(ts('Case Id not found.')); } $form->assign('clientID', $form->_currentlyViewedContactId); $form->assign('caseTypeLabel', CRM_Case_BAO_Case::getCaseType($form->_caseId)); // get the related cases for given case. $relatedCases = $form->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($form->_caseId, $form->_currentlyViewedContactId); $form->set('relatedCases', empty($relatedCases) ? FALSE : $relatedCases); } $excludeCaseIds = array($form->_caseId); if (is_array($relatedCases) && !empty($relatedCases)) { $excludeCaseIds = array_merge($excludeCaseIds, array_keys($relatedCases)); } $form->assign('excludeCaseIds', implode(',', $excludeCaseIds)); }
/** * @param CRM_Core_Form $form * * @throws Exception */ public static function preProcess(&$form) { if (empty($form->_caseId)) { CRM_Core_Error::fatal(ts('Case Id not found.')); } if (count($form->_caseId) != 1) { CRM_Core_Resources::fatal(ts('Expected one case-type')); } $caseId = CRM_Utils_Array::first($form->_caseId); $form->assign('clientID', $form->_currentlyViewedContactId); $form->assign('sortName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $form->_currentlyViewedContactId, 'sort_name')); $form->assign('caseTypeLabel', CRM_Case_BAO_Case::getCaseType($caseId)); // get the related cases for given case. $relatedCases = $form->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $form->_currentlyViewedContactId); $form->set('relatedCases', empty($relatedCases) ? FALSE : $relatedCases); } }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); $this->assign('multiClient', $isMultiClient); //pull the related cases. $this->assign('showRelatedCases', FALSE); if ($this->_showRelatedCases) { $relatedCases = $this->get('relatedCases'); if (!isset($relatedCases)) { $cId = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $caseId = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject); $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $cId); } $this->assign('relatedCases', $relatedCases); $this->assign('showRelatedCases', TRUE); CRM_Utils_System::setTitle(ts('Related Cases')); return; } //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } $this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities'); $this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases); $this->_contactID = $this->get('cid'); $this->_caseID = $this->get('id'); $fulltext = CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject); if ($fulltext == 'fulltext') { $this->assign('fulltext', $fulltext); } $this->assign('caseID', $this->_caseID); $this->assign('contactID', $this->_contactID); //validate case id. $this->_userCases = array(); $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); if (!$this->_hasAccessToAllCases) { $this->_userCases = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'any'); if (!array_key_exists($this->_caseID, $this->_userCases)) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } } $this->assign('userID', $userID); if (CRM_Case_BAO_Case::caseCount($this->_contactID) >= 2) { $this->_mergeCases = TRUE; } $this->assign('mergeCases', $this->_mergeCases); //retrieve details about case $params = array('id' => $this->_caseID); $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date'); CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties); $statuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE); $caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name'); $caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID); $this->_caseDetails = array('case_type' => $caseType, 'case_status' => CRM_Utils_Array::value($values['case_status_id'], $statuses), 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']); $this->_caseType = $caseTypeName; $this->assign('caseDetails', $this->_caseDetails); $reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", FALSE, NULL, FALSE); $this->assign('reportUrl', $reportUrl); // add to recently viewed $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home"); $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); $this->assign('displayName', $displayName); CRM_Utils_System::setTitle($displayName . ' - ' . $caseType); $recentOther = array(); if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home"); } // Add the recently viewed case CRM_Utils_Recent::add($displayName . ' - ' . $caseType, $url, $this->_caseID, 'Case', $this->_contactID, NULL, $recentOther); //get the related cases for given case. $relatedCases = $this->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($this->_caseID, $this->_contactID); $relatedCases = empty($relatedCases) ? FALSE : $relatedCases; $this->set('relatedCases', $relatedCases); } $this->assign('hasRelatedCases', (bool) $relatedCases); if ($relatedCases) { $this->assign('relatedCaseLabel', ts('%1 Related Case', array('count' => count($relatedCases), 'plural' => '%1 Related Cases'))); $this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', array('id' => $this->_caseID, 'cid' => $this->_contactID, 'relatedCases' => 1, 'action' => 'view'))); } $entitySubType = !empty($values['case_type_id']) ? $values['case_type_id'] : NULL; $this->assign('caseTypeID', $entitySubType); $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Case', $this, $this->_caseID, NULL, $entitySubType); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); require_once 'CRM/Case/XMLProcessor/Process.php'; $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); $this->assign('multiClient', $isMultiClient); //pull the related cases. $this->assign('showRelatedCases', false); if ($this->_showRelatedCases) { $relatedCases = $this->get('relatedCases'); if (!isset($relatedCases)) { $cId = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $caseId = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject); $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $cId); } $this->assign('relatedCases', $relatedCases); $this->assign('showRelatedCases', true); return; } //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } $this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities'); $this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases); $this->_contactID = $this->get('cid'); $this->_caseID = $this->get('id'); $fulltext = CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject); if ($fulltext == 'fulltext') { $this->assign('fulltext', $fulltext); } $this->assign('caseID', $this->_caseID); $this->assign('contactID', $this->_contactID); //validate case id. $this->_userCases = array(); $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); if (!$this->_hasAccessToAllCases) { $this->_userCases = CRM_Case_BAO_Case::getCases(false, $userID); if (!array_key_exists($this->_caseID, $this->_userCases)) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } } $this->assign('userID', $userID); if (CRM_Case_BAO_Case::caseCount($this->_contactID) >= 2) { $this->_mergeCases = true; } $this->assign('mergeCases', $this->_mergeCases); //retrieve details about case $params = array('id' => $this->_caseID); $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date'); CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties); $values['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $values)); require_once 'CRM/Case/PseudoConstant.php'; $statuses = CRM_Case_PseudoConstant::caseStatus('label', false); $caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name'); $caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID); $this->_caseDetails = array('case_type' => $caseType, 'case_status' => $statuses[$values['case_status_id']], 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']); $this->_caseType = $caseTypeName; $this->assign('caseDetails', $this->_caseDetails); $newActivityUrl = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=", false, null, false); $this->assign('newActivityUrl', $newActivityUrl); // Send Email activity requires a different URL format from all other activities $newActivityEmailUrl = CRM_Utils_System::url('civicrm/activity/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype=", false, null, false); $this->assign('newActivityEmailUrl', $newActivityEmailUrl); $reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", false, null, false); $this->assign('reportUrl', $reportUrl); // add to recently viewed require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Contact/BAO/Contact.php'; $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home"); $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); $this->assign('displayName', $displayName); $title = $displayName . ' - ' . $caseType; $recentOther = array(); if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home"); } // add the recently created case CRM_Utils_Recent::add($displayName . ' - ' . $caseType, $url, $this->_caseID, 'Case', $this->_contactID, null, $recentOther); //get the related cases for given case. $relatedCases = $this->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($this->_caseID, $this->_contactID); $relatedCases = empty($relatedCases) ? false : $relatedCases; $this->set('relatedCases', $relatedCases); } $this->assign('hasRelatedCases', $relatedCases); }