/** * Heart of the viewing process. * * The runner gets all the meta data for the contact and calls the appropriate type of page to view. */ public function preProcess() { //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } //validate case configuration. $configured = CRM_Case_BAO_Case::isCaseConfigured(); $this->assign('notConfigured', !$configured['configured']); $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); if (!$configured['configured']) { return; } $session = CRM_Core_Session::singleton(); $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session); CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); $userID = $session->get('userID'); //validate access for all cases. if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { $allCases = FALSE; CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); } if (!$allCases) { $this->assign('myCases', TRUE); } else { $this->assign('myCases', FALSE); } $this->assign('newClient', FALSE); if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) { $this->assign('newClient', TRUE); } $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID); $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming'); $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent'); foreach ($upcoming as $key => $value) { if (strtotime($value['case_scheduled_activity_date']) < time()) { $upcoming[$key]['activity_status'] = 'status-overdue'; } } $this->assign('casesSummary', $summary); if (!empty($upcoming)) { $this->assign('upcomingCases', $upcoming); } if (!empty($recent)) { $this->assign('recentCases', $recent); } }
/** * Heart of the viewing process. The runner gets all the meta data for * the contact and calls the appropriate type of page to view. * * @return void * @access public * */ function preProcess() { //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } //validate case configuration. require_once 'CRM/Case/BAO/Case.php'; $configured = CRM_Case_BAO_Case::isCaseConfigured(); $this->assign('notConfigured', !$configured['configured']); $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); if (!$configured['configured']) { return; } $session =& CRM_Core_Session::singleton(); $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session); CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); $userID = $session->get('userID'); //validate access for all cases. if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { $allCases = false; CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.')); } if (!$allCases) { $this->assign('myCases', true); } else { $this->assign('myCases', false); } $this->assign('newClient', false); if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) { $this->assign('newClient', true); } require_once 'CRM/Case/BAO/Case.php'; $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID); $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming'); $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent'); $this->assign('casesSummary', $summary); if (!empty($upcoming)) { $this->assign('upcomingCases', $upcoming); } if (!empty($recent)) { $this->assign('recentCases', $recent); } }
/** * Heart of the viewing process. The runner gets all the meta data for * the contact and calls the appropriate type of page to view. * * @return void * @access public * */ function preProcess() { // js for changing activity status CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } //validate case configuration. $configured = CRM_Case_BAO_Case::isCaseConfigured(); $this->assign('notConfigured', !$configured['configured']); $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); if (!$configured['configured']) { return; } $session = CRM_Core_Session::singleton(); $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session); CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); $userID = $session->get('userID'); //validate access for all cases. if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { $allCases = FALSE; CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); } if (!$allCases) { $this->assign('myCases', TRUE); } else { $this->assign('myCases', FALSE); } $this->assign('newClient', FALSE); if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) { $this->assign('newClient', TRUE); } $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID); $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming'); $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent'); $this->assign('casesSummary', $summary); if (!empty($upcoming)) { $this->assign('upcomingCases', $upcoming); } if (!empty($recent)) { $this->assign('recentCases', $recent); } }
function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse'); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); //validate case configuration. require_once 'CRM/Case/BAO/Case.php'; $configured = CRM_Case_BAO_Case::isCaseConfigured($this->_contactId); $this->assign('notConfigured', !$configured['configured']); $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); $this->assign('redirectToCaseAdmin', $configured['redirectToCaseAdmin']); if (!$configured['configured'] || $configured['redirectToCaseAdmin']) { return; } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); if ($this->_contactId) { $this->assign('contactId', $this->_contactId); // check logged in user permission require_once 'CRM/Contact/Page/View.php'; if ($this->_id && $this->_action & CRM_Core_Action::VIEW) { //user might have special permissions to view this case, CRM-5666 if (!CRM_Core_Permission::check('access all cases and activities')) { $session = CRM_Core_Session::singleton(); $userCases = CRM_Case_BAO_Case::getCases(false, $session->get('userID')); if (!array_key_exists($this->_id, $userCases)) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } } } else { CRM_Contact_Page_View::checkUserPermission($this); } // set page title CRM_Contact_Page_View::setTitle($this->_contactId); } else { if ($this->_action & CRM_Core_Action::VIEW) { CRM_Core_Error::fatal('Contact Id is required for view action.'); } } $activityTypes = CRM_Case_PseudoConstant::activityType(); $this->assign('openCaseId', $activityTypes['Open Case']['id']); $this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']); $this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']); $this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']); }
/** * Processing needed for buildForm and later. */ public function preProcess() { $this->set('searchFormName', 'Search'); //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } //validate case configuration. $configured = CRM_Case_BAO_Case::isCaseConfigured(); $this->assign('notConfigured', !$configured['configured']); if (!$configured['configured']) { return; } /** * set the button names */ $this->_searchButtonName = $this->getButtonName('refresh'); $this->_actionButtonName = $this->getButtonName('next', 'action'); $this->_done = FALSE; $this->defaults = array(); /* * 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', $this, FALSE); $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search'); $this->assign('context', $this->_context); // get user submitted values // get it from controller only if form has been submitted, else preProcess has set this if (!empty($_POST) && !$this->controller->isModal()) { $this->_formValues = $this->controller->exportValues($this->_name); } else { $this->_formValues = $this->get('formValues'); } if (empty($this->_formValues)) { if (isset($this->_ssID)) { $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } } if ($this->_force) { $this->postProcess(); $this->set('force', 0); } $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)); } $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Case_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context); $prefix = NULL; if ($this->_context == 'user') { $prefix = $this->_prefix; } $this->assign("{$prefix}limit", $this->_limit); $this->assign("{$prefix}single", $this->_single); $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER, $prefix); $controller->setEmbedded(TRUE); $controller->moveFromSessionToTemplate(); $this->assign('summary', $this->get('summary')); }
/** * 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)); }
/** * add all the elements shared between case search and advanaced search * * @access public * @return void * @static */ static function buildSearchForm(&$form) { $config = CRM_Core_Config::singleton(); //validate case configuration. require_once 'CRM/Case/BAO/Case.php'; $configured = CRM_Case_BAO_Case::isCaseConfigured(); $form->assign('notConfigured', !$configured['configured']); require_once "CRM/Case/PseudoConstant.php"; $caseTypes = CRM_Case_PseudoConstant::caseType('label', false); foreach ($caseTypes as $id => $Name) { $form->addElement('checkbox', "case_type_id[{$id}]", null, $Name); } $statuses = CRM_Case_PseudoConstant::caseStatus('label', false); $form->add('select', 'case_status_id', ts('Case Status'), array('' => ts('- any status -')) + $statuses); $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); require_once 'CRM/Core/BAO/Tag.php'; $caseTags = CRM_Core_BAO_Tag::getTagsUsedFor(array('civicrm_case')); if ($caseTags) { foreach ($caseTags as $tagID => $tagName) { $form->_tagElement =& $form->addElement('checkbox', "case_tags[{$tagID}]", null, $tagName); } } require_once "CRM/Core/Permission.php"; if (CRM_Core_Permission::check('administer CiviCRM')) { $form->addElement('checkbox', 'case_deleted', ts('Deleted Cases')); } }