/** * @param $rev */ public function upgrade_4_1_alpha1($rev) { $config = CRM_Core_Config::singleton(); if (in_array('CiviCase', $config->enableComponents)) { if (!CRM_Case_BAO_Case::createCaseViews()) { $template = CRM_Core_Smarty::singleton(); $afterUpgradeMessage = ''; if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) { $afterUpgradeMessage .= "<br/><br/>"; } $afterUpgradeMessage .= '<div class="crm-upgrade-case-views-error" style="background-color: #E43D2B; padding: 10px;">' . ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:"); $afterUpgradeMessage .= '<div class="crm-upgrade-case-views-query"><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '</div><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '</div>' . '</div></div>'; $template->assign('afterUpgradeMessage', $afterUpgradeMessage); } } $upgrade = new CRM_Upgrade_Form(); $upgrade->processSQL($rev); $this->transferPreferencesToSettings(); $this->createNewSettings(); // now modify the config so that the directories are now stored in the settings table // CRM-8780 $params = array(); CRM_Core_BAO_ConfigSetting::add($params); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); }
/** * Trigger a rule for this trigger * * @param $op * @param $objectName * @param $objectId * @param $objectRef */ public function triggerTrigger($op, $objectName, $objectId, $objectRef) { $t = $this->getTriggerDataFromPost($op, $objectName, $objectId, $objectRef); //trigger for each client $clients = CRM_Case_BAO_Case::getCaseClients($objectId); foreach ($clients as $client) { $triggerData = clone $t; $triggerData->setEntityData('Relationship', null); $triggerData->setContactId($client); CRM_Civirules_Engine::triggerRule($this, $triggerData); } //trigger for each case role $relatedContacts = CRM_Case_BAO_Case::getRelatedContacts($objectId); foreach ($relatedContacts as $contact) { $triggerData = clone $t; $relationshipData = null; $relationship = new CRM_Contact_BAO_Relationship(); $relationship->contact_id_b = $contact['contact_id']; $relationship->case_id = $objectId; if ($relationship->find(true)) { CRM_Core_DAO::storeValues($relationship, $relationshipData); } $triggerData->setEntityData('Relationship', $relationshipData); $triggerData->setContactId($contact['contact_id']); CRM_Civirules_Engine::triggerRule($this, $triggerData); } }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { $formparams = $this->exportValues(); $caseId = $formparams['unclosed_case_id']; $filedActivities = 0; foreach ($this->_activityHolderIds as $key => $id) { $targetContactValues = $defaults = array(); $params = array('id' => $id); CRM_Activity_BAO_Activity::retrieve($params, $defaults); if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) { if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) { $targetContactValues = array_combine(array_unique($defaults['target_contact']), explode(';', trim($defaults['target_contact_value']))); $targetContactValues = implode(',', array_keys($targetContactValues)); } $params = array('caseID' => $caseId, 'activityID' => $id, 'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'], 'targetContactIds' => $targetContactValues, 'mode' => 'file'); $error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params); if (empty($error_msg['error_msg'])) { $filedActivities++; } else { CRM_Core_Session::setStatus($error_msg['error_msg'], ts("Error"), "error"); } } else { CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array(1 => empty($defaults['subject']) ? '' : $defaults['subject'], 2 => $defaults['activity_date_time'])), ts("Error"), "error"); } } CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success"); CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info"); }
static function getCaseActivity() { $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer'); $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); $userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer'); $context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String'); $sortMapper = array(0 => 'display_date', 1 => 'ca.subject', 2 => 'ca.activity_type_id', 3 => 'acc.sort_name', 4 => 'cc.sort_name', 5 => 'ca.status_id'); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $params = $_POST; if ($sort && $sortOrder) { $params['sortname'] = $sort; $params['sortorder'] = $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; // get the activities related to given case $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID); $iFilteredTotal = $iTotal = $params['total']; $selectorElements = array('display_date', 'subject', 'type', 'with_contacts', 'reporter', 'status', 'links', 'class'); echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * 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() { // Make sure case types have been configured for the component require_once 'CRM/Core/OptionGroup.php'; $caseType = CRM_Core_OptionGroup::values('case_type'); if (empty($caseType)) { $this->assign('notConfigured', 1); 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'); if (!$allCases) { $this->assign('myCases', true); } else { $this->assign('myCases', false); } $this->assign('newClient', false); if (CRM_Core_Permission::check('add contacts')) { $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); } }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::DELETE) { return; } CRM_Utils_System::setTitle(ts('Dropdown Options')); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id)); $this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title')); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description')); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) { static $caseCount = NULL; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE); } if ($caseCount > 0) { $element->freeze(); } } if (!empty($this->_values['is_reserved'])) { $this->freeze(array('name', 'is_active')); } } $this->assign('id', $this->_id); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), true); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id)); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description')); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) { static $caseCount = null; require_once 'CRM/Case/BAO/Case.php'; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(null, false); } if ($caseCount > 0) { $element->freeze(); } } if ($this->_values['is_reserved']) { $this->freeze(array('name', 'description', 'is_active')); } } $this->assign('id', $this->_id); }
/** * Class constructor. */ public function __construct() { // don’t display the ‘Add these Contacts to Group’ button $this->_add2groupSupported = FALSE; $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN); $this->loggingDB = $dsn['database']; // used for redirect back to contact summary $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search')))); $logging = new CRM_Logging_Schema(); // build _logTables for contact custom tables $customTables = $logging->entityCustomDataLogTables('Contact'); foreach ($customTables as $table) { $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact'); } // build _logTables for address custom tables $customTables = $logging->entityCustomDataLogTables('Address'); foreach ($customTables as $table) { $this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact'); } // Allow log tables to be extended via report hooks. CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables); parent::__construct(); }
public function testPipeline() { $contact = $this->callAPISuccess('contact', 'create', array('first_name' => 'JohnHR', 'contact_type' => 'Individual', 'last_name' => 'Smith', 'email' => '*****@*****.**')); // create case $newParams = array('case_type_id' => $this->casetype_id, 'creator_id' => $contact['id'], 'status_id' => 1, 'subject' => 'Case for HR Unit Test', 'contact_id' => $contact['id'], 'version' => 3, 'label' => 'test', 'name' => 'test'); // assign case to contact $caseBAO = CRM_Case_BAO_Case::create($newParams); $newParams['id'] = $caseBAO->id; $caseContact = new CRM_Case_DAO_CaseContact(); $caseContact->case_id = $caseBAO->id; $caseContact->contact_id = $contact['id']; $caseContact->find(TRUE); $caseContact->save(); // create activity $paramsActivity = array('source_contact_id' => $contact['id'], 'activity_type_id' => $this->opencase_activityId, 'subject' => 'Open Case', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 1, 'priority_id' => 2, 'duration' => 120, 'location' => 'Pensulvania', 'details' => 'A test activity', 'case_id' => $caseBAO->id, 'is_current_revision' => 1); $resultActivity = civicrm_api3('activity', 'create', $paramsActivity); $opencase_activityIds = $resultActivity['id']; $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivity['id']); $analyzer->case_id = $caseBAO->id; $caseStatus = $caseBAO->status_id; $activityStatus = $resultActivity['values'][$resultActivity['id']]['status_id']; $activityTypeId = $resultActivity['values'][$resultActivity['id']]['activity_type_id']; $this->assertEquals('1', $caseStatus); // Check case stauts id $activityCheck = $analyzer->getSingleActivity($activityTypeId); $this->assertEquals('1', $activityCheck[1]['status_id']); // Check activity stauts id $this->assertFalse($analyzer->hasActivity('Interview Prospect')); $this->assertFalse($analyzer->hasActivity('Background Check')); $paramsActivity = array('id' => $opencase_activityIds, 'source_contact_id' => $contact['id'], 'activity_type_id' => $this->opencase_activityId, 'subject' => 'Open Case', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, 'priority_id' => 2, 'duration' => 120, 'location' => 'Pensulvania', 'details' => 'A test activity', 'case_id' => $caseBAO->id, 'is_current_revision' => 1, 'original_id' => $opencase_activityIds); $resultActivity = civicrm_api3('activity', 'create', $paramsActivity); $paramsActivityGet = array('activity_type_id' => $this->activityIds['Interview Prospect'], 'version' => 3); $resultActivityGet = civicrm_api3('activity', 'get', $paramsActivityGet); $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivityGet['values'][$resultActivityGet['id']]['id']); $ActivityIP = $analyzer->getSingleActivity($this->activityIds['Interview Prospect']); $this->assertEquals('2', $resultActivity['values'][$resultActivity['id']]['status_id']); $this->assertEquals('1', $ActivityIP[1]['status_id']); $this->assertFalse($analyzer->hasActivity('Background Check')); // get second activity $params = array('activity_type_id' => $this->activityIds['Interview Prospect'], 'sequential' => 1, 'version' => 3); $result = civicrm_api3('activity', 'get', $params); $paramsActivity2 = array('id' => $result['id'], 'status_id' => 'Completed', 'version' => 3, 'case_id' => $caseBAO->id, 'activity_type_id' => $this->activityIds['Interview Prospect'], 'original_id' => $result['id']); $resultActivity2 = civicrm_api3('activity', 'create', $paramsActivity2); $paramsActivityGet1 = array('activity_type_id' => $this->activityIds['Background Check'], 'version' => 3); $resultActivityGet1 = civicrm_api3('activity', 'get', $paramsActivityGet1); $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivityGet1['values'][$resultActivityGet1['id']]['id']); $ActivityIP1 = $analyzer->getSingleActivity($this->activityIds['Background Check']); $this->assertEquals('2', $resultActivity2['values'][$resultActivity2['id']]['status_id']); $this->assertEquals('1', $ActivityIP1[1]['status_id']); // get second activity $params = array('activity_type_id' => $this->activityIds['Background Check'], 'sequential' => 1, 'version' => 3); $result = civicrm_api3('activity', 'get', $params); $paramsActivity3 = array('id' => $result['id'], 'status_id' => 'Completed', 'version' => 3, 'case_id' => $caseBAO->id, 'activity_type_id' => $this->activityIds['Background Check'], 'original_id' => $result['id']); $resultActivity3 = civicrm_api3('activity', 'create', $paramsActivity3); $this->assertEquals('2', $resultActivity3['values'][$resultActivity3['id']]['status_id']); }
static function &getFields() { require_once 'CRM/Case/BAO/Case.php'; $fields = array(); $fields = CRM_Case_BAO_Case::exportableFields(); // add activity related fields require_once 'CRM/Activity/BAO/Activity.php'; $fields = array_merge($fields, CRM_Activity_BAO_Activity::exportableFields()); return $fields; }
/** * process the form after the input has been submitted and validated * * @access public * * @return None */ public function postProcess() { $restoredCases = 0; foreach ($this->_caseIds as $caseId) { if (CRM_Case_BAO_Case::restoreCase($caseId)) { $restoredCases++; } } CRM_Core_Session::setStatus($restoredCases, ts('Restored Cases'), 'success'); CRM_Core_Session::setStatus('', ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds))), 'info'); }
/** */ public function __construct() { $this->case_types = CRM_Case_PseudoConstant::caseType(); $this->case_statuses = CRM_Core_OptionGroup::values('case_status'); $rels = CRM_Core_PseudoConstant::relationshipType(); foreach ($rels as $relid => $v) { $this->rel_types[$relid] = $v['label_b_a']; } $this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes')); $this->_columns = array('civicrm_c2' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('client_name' => array('name' => 'sort_name', 'title' => ts('Client'), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => TRUE), 'subject' => array('title' => ts('Case Subject'), 'default' => TRUE), 'status_id' => array('title' => ts('Status'), 'default' => TRUE), 'case_type_id' => array('title' => ts('Case Type'), 'default' => TRUE), 'start_date' => array('title' => ts('Start Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE), 'duration' => array('title' => ts('Duration (Days)'), 'default' => FALSE), 'is_deleted' => array('title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT)), 'filters' => array('start_date' => array('title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search')), 'status_id' => array('title' => ts('Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('status_id', 'search')), 'is_deleted' => array('title' => ts('Deleted?'), 'type' => CRM_Report_Form::OP_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, 'default' => 0))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Staff Member'), 'default' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Staff Member')))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'filters' => array('relationship_type_id' => array('title' => ts('Staff Relationship'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types))), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_b_a' => array('title' => ts('Relationship'), 'default' => TRUE))), 'civicrm_case_contact' => array('dao' => 'CRM_Case_DAO_CaseContact')); parent::__construct(); }
/** * process the form after the input has been submitted and validated * * @access public * @return None */ public function postProcess() { $restoredCases = 0; require_once 'CRM/Case/BAO/Case.php'; foreach ($this->_caseIds as $caseId) { if (CRM_Case_BAO_Case::restoreCase($caseId)) { $restoredCases++; } } $status = array(ts('Restored Case(s): %1', array(1 => $restoredCases)), ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds)))); CRM_Core_Session::setStatus($status); }
/** * process the form after the input has been submitted and validated * * @access public * * @return void */ public function postProcess() { $deletedActivities = 0; foreach ($this->_activityHolderIds as $activityId['id']) { $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']); if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) { $deletedActivities++; } } CRM_Core_Session::setStatus($deletedActivities, ts('Deleted Activities'), "success"); CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info"); }
/** * process the form after the input has been submitted and validated * * @access public * @return None */ public function postProcess() { $deletedActivities = 0; foreach ($this->_activityHolderIds as $activityId['id']) { require_once 'CRM/Case/BAO/Case.php'; $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']); if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) { $deletedActivities++; } } $status = array(ts('Deleted Activities: %1', array(1 => $deletedActivities)), ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds)))); CRM_Core_Session::setStatus($status); }
/** * Case dashboard as dashlet * * @return void * * @access public */ function run() { //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } $session =& CRM_Core_Session::singleton(); $userID = $session->get('userID'); $summary = CRM_Case_BAO_Case::getCasesSummary(TRUE, $userID); if (!empty($summary)) { $this->assign('casesSummary', $summary); } return parent::run(); }
static function getCaseActivity() { $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer'); $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); $params = $_POST; // get the activities related to given case require_once "CRM/Case/BAO/Case.php"; $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID); $page = CRM_Utils_Array::value('page', $_POST); $total = $params['total']; require_once "CRM/Utils/JSON.php"; $selectorElements = array('display_date', 'subject', 'type', 'reporter', 'status', 'links', 'class'); echo CRM_Utils_JSON::encodeSelector($activities, $page, $total, $selectorElements); exit; }
/** * @param CRM_Core_Form $form */ public static function buildQuickForm(&$form) { $form->removeElement('status_id'); $form->removeElement('priority_id'); $caseId = CRM_Utils_Array::first($form->_caseId); $form->_caseType = CRM_Case_BAO_Case::buildOptions('case_type_id', 'create'); $form->_caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'case_type_id'); if (!in_array($form->_caseTypeId, $form->_caseType)) { $form->_caseType[$form->_caseTypeId] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $form->_caseTypeId, 'title'); } $form->addField('case_type_id', array('context' => 'create', 'entity' => 'Case')); // timeline $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE, array('onclick' => "return showHideByValue('is_reset_timeline','','resetTimeline','table-row','radio',false);")); $form->addDateTime('reset_date_time', ts('Reset Start Date'), FALSE, array('formatType' => 'activityDateTime')); }
/** * List activities as dashlet * * @return void * * @access public */ function run() { $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet'); $this->assign('context', $context); //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); $upcoming = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'upcoming', $context); if (!empty($upcoming)) { $this->assign('upcomingCases', $upcoming); } return parent::run(); }
/** * List activities as dashlet * * @return none * * @access public */ function run() { require_once 'CRM/Case/BAO/Case.php'; //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } require_once 'CRM/Core/OptionGroup.php'; $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); $upcoming = CRM_Case_BAO_Case::getCases(true, $userID, 'upcoming'); if (!empty($upcoming)) { $this->assign('AllCases', $upcoming); } return parent::run(); }
/** * 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); } }
/** * Implementation of hook_civicrm_uninstall */ function hrcaseutils_civicrm_uninstall() { //delete all activity type CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE name IN ('Interview Prospect', 'Background_Check', 'ID badge')"); $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE); $value = array_search('Hrdata', $caseTypes); //Delete cases and related contact of type Hrdata on uninstall if ($value) { $caseDAO = new CRM_Case_DAO_Case(); $caseDAO->case_type_id = $value; $caseDAO->find(); while ($caseDAO->fetch()) { CRM_Case_BAO_Case::deleteCase($caseDAO->id); } } return _hrcaseutils_civix_civicrm_uninstall(); }
/** */ public function __construct() { $this->case_statuses = CRM_Core_OptionGroup::values('case_status'); $this->case_types = CRM_Case_PseudoConstant::caseType(); $rels = CRM_Core_PseudoConstant::relationshipType(); foreach ($rels as $relid => $v) { $this->rel_types[$relid] = $v['label_b_a']; } $this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes')); $this->caseActivityTypes = array(); foreach (CRM_Case_PseudoConstant::caseActivityType() as $typeDetail) { $this->caseActivityTypes[$typeDetail['id']] = $typeDetail['label']; } $this->_columns = array('civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'no_display' => TRUE, 'required' => TRUE), 'subject' => array('title' => ts('Subject'), 'required' => TRUE), 'start_date' => array('title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Case Status')), 'case_type_id' => array('title' => ts('Case Type')), 'is_deleted' => array('title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT)), 'filters' => array('start_date' => array('title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Case Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('status_id', 'search')), 'case_type_id' => array('title' => ts('Case Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search')), 'is_deleted' => array('title' => ts('Deleted?'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, 'default' => 0))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('client_sort_name' => array('name' => 'sort_name', 'title' => ts('Client Name'), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Client Name')))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('case_role' => array('name' => 'relationship_type_id', 'title' => ts('Case Role(s)'))), 'filters' => array('case_role' => array('name' => 'relationship_type_id', 'title' => ts('Case Role(s)'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'))), 'grouping' => 'contact-fields', 'filters' => array('country_id' => array('title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()))), 'civicrm_worldregion' => array('dao' => 'CRM_Core_DAO_Worldregion', 'filters' => array('worldregion_id' => array('name' => 'id', 'title' => ts('World Region'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion()))), 'civicrm_country' => array('dao' => 'CRM_Core_DAO_Country'), 'civicrm_activity_last' => array('dao' => 'CRM_Activity_DAO_Activity', 'filters' => array('last_activity_date_time' => array('name' => 'activity_date_time', 'title' => ts('Last Action Date'), 'operatorType' => CRM_Report_Form::OP_DATE)), 'alias' => 'civireport_activity_last'), 'civicrm_activity_last_completed' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('last_completed_activity_subject' => array('name' => 'subject', 'title' => ts('Subject of the last completed activity in the case')), 'last_completed_activity_type' => array('name' => 'activity_type_id', 'title' => ts('Activity type of the last completed activity'))))); $this->_options = array('my_cases' => array('title' => ts('My Cases'), 'type' => 'checkbox')); parent::__construct(); }
/** * Create case contact record. * * @param array $params * case_id, contact_id * * @return CRM_Case_BAO_CaseContact */ public static function create($params) { $caseContact = new self(); $caseContact->copyValues($params); $caseContact->save(); // add to recently viewed $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id); $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"); $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $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={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"); } // add the recently created case CRM_Utils_Recent::add($title, $url, $caseContact->case_id, 'Case', $caseContact->contact_id, NULL, $recentOther); return $caseContact; }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { $restoredCases = $failed = 0; foreach ($this->_caseIds as $caseId) { if (CRM_Case_BAO_Case::restoreCase($caseId)) { $restoredCases++; } else { $failed++; } } if ($restoredCases) { $msg = ts('%count case restored from trash.', array('plural' => '%count cases restored from trash.', 'count' => $restoredCases)); CRM_Core_Session::setStatus($msg, ts('Restored'), 'success'); } if ($failed) { CRM_Core_Session::setStatus(ts('1 could not be restored.', array('plural' => '%count could not be restored.', 'count' => $failed)), ts('Error'), 'error'); } }
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']); }
/** * 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); } }
public function onChange(CRM_HRCaseUtils_Analyzer $analyzer, $objectRef) { if (isset($objectRef->activity_type_id)) { // Get activity type name & status of the activity being completed $activityTypeGroup = civicrm_api3('option_group', 'get', array('name' => 'activity_type')); $activityType = array('value' => $objectRef->activity_type_id, 'option_group_id' => $activityTypeGroup['id']); $activityTypeID = civicrm_api3('option_value', 'get', $activityType); $activityTypeID = $activityTypeID['values'][$activityTypeID['id']]['name']; $activityStatusGroup = civicrm_api3('option_group', 'get', array('name' => 'activity_status')); $activityStatus = array('value' => $objectRef->status_id, 'option_group_id' => $activityStatusGroup['id']); $activityStatusID = civicrm_api3('option_value', 'get', $activityStatus); $activityStatusID = $activityStatusID['values'][$activityStatusID['id']]['name']; // Schedule Interview Prospect activity if ($activityTypeID == 'Open Case' && $activityStatusID == 'Completed') { if ($analyzer->hasActivity($activityTypeID, $activityStatusID)) { $nextActivity = 'Interview Prospect'; // Get the activity ID for Interview Prospect $activityID = array('name' => $nextActivity, 'option_group_id' => $activityTypeGroup['id']); $activityTypeID = civicrm_api3('option_value', 'get', $activityID); $activityTypeID = $activityTypeID['values'][$activityTypeID['id']]['value']; $params = self::buildParams($activityTypeID, $nextActivity, $objectRef); } } elseif ($activityTypeID == 'Interview Prospect' && $activityStatusID == 'Completed') { if ($analyzer->hasActivity($activityTypeID, $activityStatusID)) { $nextActivity = 'Background Check'; // Get the activity ID for Background Check $activityID = array('name' => $nextActivity, 'option_group_id' => $activityTypeGroup['id']); $activityTypeID = civicrm_api3('option_value', 'get', $activityID); $activityTypeID = $activityTypeID['values'][$activityTypeID['id']]['value']; $params = self::buildParams($activityTypeID, $nextActivity, $objectRef); } } elseif ($activityTypeID == 'Background Check' && $activityStatusID == 'Completed') { return; } if (isset($params)) { $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($objectRef->original_id, $params); if ($followupActivity) { $caseParams = array('activity_id' => $followupActivity->id, 'case_id' => $objectRef->case_id); CRM_Case_BAO_Case::processCaseActivity($caseParams); $analyzer->flush(); } } } }
/** * 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); } }
/** * Process the form after the input has been submitted and validated. * * * @return void */ public function postProcess() { $deleted = $failed = 0; foreach ($this->_activityHolderIds as $activityId['id']) { $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']); if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) { $deleted++; } else { $failed++; } } if ($deleted) { $msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted)); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); } }