Exemplo n.º 1
0
 public function testCaseType()
 {
     CRM_Core_PseudoConstant::flush();
     $caseTypes = CRM_Case_PseudoConstant::caseType();
     $expectedTypes = array(1 => 'Housing Support', 2 => 'Adult Day Care Referral');
     $this->assertEquals($expectedTypes, $caseTypes);
 }
Exemplo n.º 2
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     $this->_contactID = $this->get('cid');
     $this->_caseID = $this->get('id');
     $this->assign('caseID', $this->_caseID);
     $this->assign('contactID', $this->_contactID);
     //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));
     $statuses = CRM_Case_PseudoConstant::caseStatus();
     $caseTypeName = CRM_Case_PseudoConstant::caseTypeName($this->_caseID);
     $caseType = CRM_Core_OptionGroup::getLabel('case_type', $caseTypeName['id']);
     $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['name'];
     $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);
     $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;
     // add the recently created case
     CRM_Utils_Recent::add($title, $url, $this->_caseID, 'Case', $this->_contactID, null);
 }
Exemplo n.º 3
0
 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;
     }
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     // contact id is not mandatory for case form. If not found, don't call
     // parent's pre-process and proceed further.
     if ($this->_contactId) {
         parent::preProcess();
     } else {
         // we would need action to proceed further.
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
         if ($this->_action & CRM_Core_Action::VIEW) {
             CRM_Core_Error::fatal('Contact Id is required for view action.');
         }
         $this->assign('action', $this->_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']);
 }
Exemplo n.º 4
0
 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;
     }
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     if ($this->_contactId) {
         $this->assign('contactId', $this->_contactId);
         // check logged in url permission
         require_once 'CRM/Contact/Page/View.php';
         CRM_Contact_Page_View::checkUserPermission($this);
     } 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']);
 }
Exemplo n.º 5
0
 /**
  * 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_PseudoConstant::caseType('title', FALSE))));
     $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();
 }
 function &allActivityTypes($indexName = TRUE, $all = FALSE)
 {
     static $activityTypes = NULL;
     if (!$activityTypes) {
         $activityTypes = CRM_Case_PseudoConstant::caseActivityType($indexName, $all);
     }
     return $activityTypes;
 }
Exemplo n.º 7
0
 public function setUp()
 {
     parent::setUp();
     // create a logged in USER since the code references it for source_contact_id
     $this->createLoggedInUser();
     $caseTypes = CRM_Case_PseudoConstant::caseType();
     self::mocktest($caseTypes);
 }
Exemplo n.º 8
0
 function &allActivityTypes($indexName = true, $all = false)
 {
     static $activityTypes = null;
     if (!$activityTypes) {
         require_once 'CRM/Case/PseudoConstant.php';
         $activityTypes = CRM_Case_PseudoConstant::activityType($indexName, $all);
     }
     return $activityTypes;
 }
Exemplo n.º 9
0
 /**
  * Constructor method
  */
 function __construct()
 {
     $this->_caseTypes = CRM_Case_PseudoConstant::caseType();
     $this->_caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $this->setUserSelectList();
     $this->_deletedLabels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'));
     $this->_columns = array('pum_main' => array('fields' => array('case_id' => array('no_display' => TRUE, 'required' => TRUE), 'customer_name' => array('name' => 'customer_name', 'title' => ts('Client'), 'required' => TRUE), 'customer_id' => array('name' => 'customer_id', 'no_display' => TRUE, 'required' => TRUE), 'country_name' => array('name' => 'country_name', 'title' => ts('Country'), 'default' => TRUE), 'representative' => array('name' => 'representative', 'title' => ts('Representative'), 'default' => TRUE), 'representative_id' => array('name' => 'representative_id', 'no_display' => TRUE, 'required' => TRUE), 'case_type' => array('name' => 'case_type_id', 'title' => ts('Case Type'), 'default' => TRUE), 'case_status' => array('name' => 'case_status_id', 'title' => ts('Case Status'), 'default' => TRUE), 'expert' => array('name' => 'expert', 'title' => ts('Expert'), 'default' => TRUE), 'expert_id' => array('name' => 'expert_id', 'no_display' => TRUE, 'required' => TRUE), 'start_date' => array('name' => 'start_date', 'title' => ts('Activity Start Date'), 'default' => TRUE), 'end_date' => array('name' => 'end_date', 'title' => ts('Activity End Date'), 'default' => TRUE), 'ma_expert_approval' => array('name' => 'ma_expert_approval', 'title' => ts('Expert approves Main. Act'), 'default' => TRUE), 'pq_approved_sc' => array('name' => 'pq_approved_sc', 'title' => ts('PQ approved by SC'), 'default' => TRUE), 'pq_approved_cc' => array('name' => 'pq_approved_cc', 'title' => ts('PQ approved by CC'), 'default' => TRUE), 'cust_approves_expert' => array('name' => 'cust_approves_expert', 'title' => ts('Customer approves Expert'), 'default' => TRUE), 'briefing_date' => array('name' => 'briefing_date', 'title' => ts('Briefing Date'), 'default' => TRUE), 'briefing_status' => array('name' => 'briefing_status', 'title' => ts('Briefing Status'), 'default' => TRUE)), 'filters' => array('user_id' => array('title' => ts('Main Activities for User'), 'default' => 0, 'pseudofield' => 1, 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->_userSelectList), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_caseTypes), 'case_status_id' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_caseStatus)), 'order_bys' => array('start_date' => array('title' => ts('Activity Start Date'), 'name' => 'start_date', 'default' => 1))), 'case_status_weight' => array('dao' => 'CRM_Core_DAO_OptionValue', 'fields' => array('case_status_label' => array('name' => 'label', 'no_display' => TRUE, 'required' => TRUE), 'weight' => array('no_display' => TRUE, 'required' => TRUE)), 'order_bys' => array('case_status_label' => array('title' => ts('Case Status'), 'name' => 'label', 'default' => 1))));
     parent::__construct();
 }
Exemplo n.º 10
0
 /**
  * Constructor method
  */
 function __construct()
 {
     $this->_caseStatusList = CRM_Case_PseudoConstant::caseStatus();
     $this->setUserSelectList();
     $this->setSectorList();
     $this->_deletedLabels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'));
     $this->_columns = array('pum_expert' => array('fields' => array('case_id' => array('no_display' => TRUE, 'required' => TRUE), 'expert_name' => array('name' => 'expert_name', 'title' => ts('Expert'), 'required' => TRUE), 'sector_coordinator_name' => array('name' => 'sector_coordinator_name', 'title' => ts('Sector Coordinator'), 'required' => TRUE), 'status' => array('name' => 'status', 'title' => ts('Status'), 'default' => TRUE), 'sector_coordinator_id' => array('no_display' => TRUE, 'required' => TRUE), 'expert_id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('user_id' => array('title' => ts('Expert Applications for User'), 'default' => 0, 'pseudofield' => 1, 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->_userSelectList), 'status_id' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_caseStatusList)), 'order_bys' => array('status' => array('title' => ts('Case Status'), 'name' => 'status', 'default' => 1))));
     parent::__construct();
 }
Exemplo n.º 11
0
 /**
  * CRM_Casereports_Form_Report_Opportunities constructor.
  */
 function __construct()
 {
     $this->setUserSelectList();
     $this->_caseStatusList = CRM_Case_PseudoConstant::caseStatus();
     $this->_columns = array('pum_opportunity' => array('alias' => 'opp', 'fields' => array('case_id' => array('required' => TRUE, 'no_display' => TRUE, 'no_repeat' => TRUE), 'status_id' => array('no_display' => TRUE, 'required' => TRUE), 'client_id' => array('no_display' => TRUE, 'required' => TRUE), 'account_id' => array('no_display' => TRUE, 'required' => TRUE), 'client_name' => array('title' => ts("Client"), 'default' => TRUE), 'account_name' => array('title' => ts("Case Manager"), 'default' => TRUE), 'subject' => array('title' => ts('Subject'), 'no_repeat' => TRUE, 'default' => TRUE), 'status' => array('title' => ts('Status'), 'no_repeat' => TRUE, 'default' => TRUE), 'deadline' => array('title' => ts('Deadline'), 'no_repeat' => TRUE, 'type' => CRM_Utils_Type::T_DATE, 'default' => TRUE), 'quote_amount' => array('title' => ts('Quote Amount'), 'no_repeat' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE)), 'filters' => array('account_id' => array('title' => ts('Opportunities for User'), 'default' => 0, 'pseudofield' => 1, 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_userSelectList), 'status_id' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_caseStatusList)), 'order_bys' => array('case_status' => array('title' => ts('Case Status'), 'name' => 'status', 'default' => 1))));
     $this->_groupFilter = FALSE;
     $this->_tagFilter = FALSE;
     parent::__construct();
 }
Exemplo n.º 12
0
 public function testSequence()
 {
     $actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
     $caseStatuses = array_flip(\CRM_Case_PseudoConstant::caseStatus('name'));
     // Create case; schedule first activity
     \CRM_Utils_Time::setTime('2013-11-30 01:00:00');
     $case = $this->callAPISuccess('case', 'create', $this->_params);
     $analyzer = new \Civi\CCase\Analyzer($case['id']);
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Edit details of first activity -- but don't finish it yet!
     \CRM_Utils_Time::setTime('2013-11-30 01:30:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'subject' => 'This is the new subject'));
     $analyzer = new \Civi\CCase\Analyzer($case['id']);
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Complete first activity; schedule second
     \CRM_Utils_Time::setTime('2013-11-30 02:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Complete second activity; schedule third
     \CRM_Utils_Time::setTime('2013-11-30 03:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
     // Complete third activity; close case
     \CRM_Utils_Time::setTime('2013-11-30 04:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
     $this->assertEquals($caseStatuses['Closed'], self::ag($analyzer->getCase(), 'status_id'));
     // */
 }
Exemplo n.º 13
0
 static function buildQuickForm(&$form)
 {
     require_once 'CRM/Case/PseudoConstant.php';
     $form->_caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->_defaultCaseStatus = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $form->_caseId, 'status_id');
     if (!array_key_exists($form->_defaultCaseStatus, $form->_caseStatus)) {
         $form->_caseStatus[$form->_defaultCaseStatus] = CRM_Core_OptionGroup::getLabel('case_status', $form->_defaultCaseStatus, false);
     }
     $form->add('select', 'case_status_id', ts('Case Status'), $form->_caseStatus, true);
 }
Exemplo n.º 14
0
 static function buildQuickForm(&$form)
 {
     $form->removeElement('status_id');
     $form->removeElement('priority_id');
     $form->_caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->_defaultCaseStatus = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $form->_caseId, 'status_id');
     if (!array_key_exists($form->_defaultCaseStatus, $form->_caseStatus)) {
         $form->_caseStatus[$form->_defaultCaseStatus] = CRM_Core_OptionGroup::getLabel('case_status', $form->_defaultCaseStatus, FALSE);
     }
     $form->add('select', 'case_status_id', ts('Case Status'), $form->_caseStatus, TRUE);
 }
Exemplo n.º 15
0
 function __construct()
 {
     $this->case_statuses = CRM_Case_PseudoConstant::caseStatus();
     $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('display_name' => array('title' => ts('Client'), 'required' => true))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => true), 'start_date' => array('title' => ts('Start Date'), 'default' => true), 'end_date' => array('title' => ts('End Date'), 'default' => true), 'status_id' => array('title' => ts('Status'), 'default' => true), '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), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'status_id' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), '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'), '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();
 }
 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' => FALSE), 'status_id' => array('title' => ts('Status'), 'default' => FALSE), 'case_type_id' => array('title' => ts('Case Type'), 'default' => FALSE), 'start_date' => array('title' => ts('Start Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'default' => FALSE, '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' => $this->case_types), 'status_id' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), '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' => FALSE)), 'filters' => array('my_cases' => array('title' => ts('My cases'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No'), '1' => ts('Yes')), 'pseudofield' => TRUE))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'filters' => array('relationship_type_id' => array('title' => ts('Staff Relationship'), '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' => FALSE))), 'civicrm_case_contact' => array('dao' => 'CRM_Case_DAO_CaseContact'), 'civicrm_activity' => array('filters' => array('activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'pseudofield' => TRUE))));
     parent::__construct();
 }
Exemplo n.º 17
0
 function __construct()
 {
     $this->case_statuses = CRM_Case_PseudoConstant::caseStatus();
     $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->_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')), 'end_date' => array('title' => ts('End Date')), 'status_id' => array('title' => ts('Case Status')), 'case_type_id' => array('title' => ts('Case Type'))), '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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Client Name'), 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('display_name' => array('title' => ts('Client Name')))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('relationship_type_id' => array('title' => ts('Case Role'))), 'filters' => array('relationship_type_id' => array('title' => ts('Case Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types))), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType'), '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('WorldRegion'), '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' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('activity_subject' => array('name' => 'subject', 'title' => ts('Activity Subject'), 'no_display' => true)), 'filters' => array('activity_date_time' => array('title' => ts('Last Action Date'), 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_case_contact' => array('dao' => 'CRM_Case_DAO_CaseContact'));
     $this->_options = array('my_cases' => array('title' => ts('My Cases'), 'type' => 'checkbox'));
     parent::__construct();
 }
Exemplo n.º 18
0
 /**
  *
  */
 function __construct()
 {
     $this->case_statuses = CRM_Case_PseudoConstant::caseStatus();
     $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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses), 'case_type_id' => array('title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types), '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)'), '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('WorldRegion'), '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();
 }
Exemplo n.º 19
0
/**
 * 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();
}
Exemplo n.º 20
0
 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.
     $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
         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'), 'any');
                 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::caseActivityType();
     $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']);
 }
Exemplo n.º 21
0
 /**
  * @param CRM_Core_Form $form
  */
 public static function buildQuickForm(&$form)
 {
     $form->removeElement('status_id');
     $form->removeElement('priority_id');
     $form->_caseStatus = CRM_Case_PseudoConstant::caseStatus();
     foreach ($form->_caseId as $key => $val) {
         $form->_oldCaseStatus[] = $form->_defaultCaseStatus[] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $val, 'status_id');
     }
     foreach ($form->_defaultCaseStatus as $keydefault => $valdefault) {
         if (!array_key_exists($valdefault, $form->_caseStatus)) {
             $form->_caseStatus[$valdefault] = CRM_Core_OptionGroup::getLabel('case_status', $valdefault, FALSE);
         }
     }
     $element = $form->add('select', 'case_status_id', ts('Case Status'), $form->_caseStatus, TRUE);
     // check if the case status id passed in url is a valid one, set as default and freeze
     if (CRM_Utils_Request::retrieve('case_status_id', 'Positive', $form)) {
         $caseStatusId = CRM_Utils_Request::retrieve('case_status_id', 'Positive', $form);
         $caseStatus = CRM_Case_PseudoConstant::caseStatus();
         $form->_defaultCaseStatus = array_key_exists($caseStatusId, $caseStatus) ? $caseStatusId : NULL;
         $element->freeze();
     }
 }
Exemplo n.º 22
0
/**
 * Internal function to format create params for processing.
 *
 * @param array $params
 */
function _civicrm_api3_case_format_params(&$params)
{
    // figure out case type id from case type and vice-versa
    $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE);
    if (empty($params['case_type_id'])) {
        $params['case_type_id'] = array_search($params['case_type'], $caseTypes);
        // DEPRECATED: lookup by label for backward compatibility
        if (!$params['case_type_id']) {
            $caseTypeLabels = CRM_Case_PseudoConstant::caseType('title', FALSE);
            $params['case_type_id'] = array_search($params['case_type'], $caseTypeLabels);
            $params['case_type'] = $caseTypes[$params['case_type_id']];
        }
    } elseif (empty($params['case_type'])) {
        $params['case_type'] = $caseTypes[$params['case_type_id']];
    }
}
Exemplo n.º 23
0
 /**
  * @throws \CiviCRM_API3_Exception
  */
 public function caseDetails()
 {
     $caseId = CRM_Utils_Type::escape($_GET['caseId'], 'Positive');
     $case = civicrm_api3('Case', 'getsingle', array('id' => $caseId, 'check_permissions' => TRUE, 'return' => array('subject', 'case_type_id', 'status_id', 'start_date', 'end_date')));
     $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
     $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
     $caseDetails = "<table><tr><td>" . ts('Case Subject') . "</td><td>{$case['subject']}</td></tr>\n                                  <tr><td>" . ts('Case Type') . "</td><td>{$caseTypes[$case['case_type_id']]}</td></tr>\n                                  <tr><td>" . ts('Case Status') . "</td><td>{$caseStatuses[$case['status_id']]}</td></tr>\n                                  <tr><td>" . ts('Case Start Date') . "</td><td>" . CRM_Utils_Date::customFormat($case['start_date']) . "</td></tr>\n                                  <tr><td>" . ts('Case End Date') . "</td><td></td></tr>" . CRM_Utils_Date::customFormat($case['end_date']) . "</table>";
     if (CRM_Utils_Array::value('snippet', $_GET) == 'json') {
         CRM_Core_Page_AJAX::returnJsonResponse($caseDetails);
     }
     echo $caseDetails;
     CRM_Utils_System::civiExit();
 }
Exemplo n.º 24
0
 /**
  * Function to check case configuration.
  *
  * @param null $contactId
  *
  * @return array $configured
  */
 static function isCaseConfigured($contactId = NULL)
 {
     $configured = array_fill_keys(array('configured', 'allowToAddNewCase', 'redirectToCaseAdmin'), FALSE);
     //lets check for case configured.
     $allCasesCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
     $configured['configured'] = $allCasesCount ? TRUE : FALSE;
     if (!$configured['configured']) {
         //do check for case type and case status.
         $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
         if (!empty($caseTypes)) {
             $configured['configured'] = TRUE;
             if (!$configured['configured']) {
                 $caseStatuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE);
                 if (!empty($caseStatuses)) {
                     $configured['configured'] = TRUE;
                 }
             }
         }
     }
     if ($configured['configured']) {
         //do check for active case type and case status.
         $caseTypes = CRM_Case_PseudoConstant::caseType();
         if (!empty($caseTypes)) {
             $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
             if (!empty($caseStatuses)) {
                 $configured['allowToAddNewCase'] = TRUE;
             }
         }
         //do we need to redirect user to case admin.
         if (!$configured['allowToAddNewCase'] && $contactId) {
             //check for current contact case count.
             $currentContatCasesCount = CRM_Case_BAO_Case::caseCount($contactId);
             //redirect user to case admin page.
             if (!$currentContatCasesCount) {
                 $configured['redirectToCaseAdmin'] = TRUE;
             }
         }
     }
     return $configured;
 }
Exemplo n.º 25
0
 /**
  * @param CRM_Case_XMLRepository $xmlRepo
  * @param array <string> $caseTypeNames
  */
 public function __construct()
 {
     $this->caseTypeNames = CRM_Case_PseudoConstant::caseType('name');
     $this->xmlRepo = CRM_Case_XMLRepository::singleton();
 }
Exemplo n.º 26
0
/**
 * Internal function to format create params for processing
 */
function _civicrm_api3_case_format_params(&$params)
{
    if (!array_key_exists('creator_id', $params)) {
        $session = CRM_Core_Session::singleton();
        $params['creator_id'] = $session->get('userID');
    }
    if (empty($params['start_date'])) {
        $params['start_date'] = date('YmdHis');
    }
    // figure out case type id from case type and vice-versa
    $caseTypes = CRM_Case_PseudoConstant::caseType('label', FALSE);
    if (empty($params['case_type_id'])) {
        $params['case_type_id'] = array_search($params['case_type'], $caseTypes);
    } elseif (empty($params['case_type'])) {
        $params['case_type'] = $caseTypes[$params['case_type_id']];
    }
    // format input with value separators
    $sep = CRM_Core_DAO::VALUE_SEPARATOR;
    $params['case_type_id'] = $sep . implode($sep, (array) $params['case_type_id']) . $sep;
}
Exemplo n.º 27
0
 /**
  * Get all the redaction rules.
  *
  *
  * @param null $filter
  *
  * @return array
  *   array reference of all redaction rules
  */
 public static function redactionRule($filter = NULL)
 {
     // if ( ! self::$redactionRule ) {
     self::$redactionRule = array();
     if ($filter === 0) {
         $condition = "  AND (v.filter = 0 OR v.filter IS NULL)";
     } elseif ($filter === 1) {
         $condition = "  AND  v.filter = 1";
     } elseif ($filter === NULL) {
         $condition = NULL;
     }
     self::$redactionRule = CRM_Core_OptionGroup::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
     // }
     return self::$redactionRule;
 }
Exemplo n.º 28
0
 public function caseDetails()
 {
     $caseId = CRM_Utils_Type::escape($_GET['caseId'], 'Positive');
     if (!CRM_Case_BAO_Case::accessCase($caseId, FALSE)) {
         CRM_Utils_System::permissionDenied();
     }
     $sql = "SELECT civicrm_case.*, civicrm_case_type.title as case_type\n        FROM civicrm_case\n        INNER JOIN civicrm_case_type ON civicrm_case.case_type_id = civicrm_case_type.id\n        WHERE civicrm_case.id = %1";
     $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($caseId, 'Integer')));
     if ($dao->fetch()) {
         $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
         $cs = $caseStatuses[$dao->status_id];
         $caseDetails = "<table><tr><td>" . ts('Case Subject') . "</td><td>{$dao->subject}</td></tr>\n                                    <tr><td>" . ts('Case Type') . "</td><td>{$dao->case_type}</td></tr>\n                                    <tr><td>" . ts('Case Status') . "</td><td>{$cs}</td></tr>\n                                    <tr><td>" . ts('Case Start Date') . "</td><td>" . CRM_Utils_Date::customFormat($dao->start_date) . "</td></tr>\n                                    <tr><td>" . ts('Case End Date') . "</td><td></td></tr>" . CRM_Utils_Date::customFormat($dao->end_date) . "</table>";
         if (CRM_Utils_Array::value('snippet', $_GET) == 'json') {
             CRM_Core_Page_AJAX::returnJsonResponse($caseDetails);
         } else {
             echo $caseDetails;
         }
     } else {
         CRM_Core_Error::fatal('Could not find valid Case.');
     }
     CRM_Utils_System::civiExit();
 }
Exemplo n.º 29
0
 /**
  * Get Activity specific File according activity type Id.
  *
  * @param int $activityTypeId
  *   Activity id.
  * @param string $crmDir
  *
  * @return string|bool
  *   if file exists returns $activityTypeFile activity filename otherwise false.
  */
 public static function getFileForActivityTypeId($activityTypeId, $crmDir = 'Activity')
 {
     $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
     if ($activityTypes[$activityTypeId]['name']) {
         $activityTypeFile = CRM_Utils_String::munge(ucwords($activityTypes[$activityTypeId]['name']), '', 0);
     } else {
         return FALSE;
     }
     global $civicrm_root;
     $config = CRM_Core_Config::singleton();
     if (!file_exists(rtrim($civicrm_root, '/') . "/CRM/{$crmDir}/Form/Activity/{$activityTypeFile}.php")) {
         if (empty($config->customPHPPathDir)) {
             return FALSE;
         } elseif (!file_exists(rtrim($config->customPHPPathDir, '/') . "/CRM/{$crmDir}/Form/Activity/{$activityTypeFile}.php")) {
             return FALSE;
         }
     }
     return $activityTypeFile;
 }
Exemplo n.º 30
0
 public function upgrade_1300()
 {
     $this->ctx->log->info('Applying update 1300');
     $sql = "Update civicrm_case_type SET is_active = 0 where name IN ('AdultDayCareReferral', 'HousingSupport', 'adult_day_care_referral', 'housing_support')";
     CRM_Core_DAO::executeQuery($sql);
     $values = NULL;
     $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE);
     foreach (array('Exiting', 'Joining', 'Probation', 'Hrdata') as $caseName) {
         if ($caseID = array_search($caseName, $caseTypes)) {
             $values .= " WHEN '{$caseName}' THEN '{$caseID}'";
         }
     }
     if ($values) {
         $query = "UPDATE civicrm_managed\n        SET entity_id = CASE name\n        {$values}\n        END, entity_type = 'caseType' WHERE name IN ('Exiting', 'Joining', 'Probation', 'Hrdata');";
         CRM_Core_DAO::executeQuery($query);
         CRM_Core_BAO_Navigation::resetNavigation();
     }
     return TRUE;
 }