Esempio n. 1
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_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();
 }
Esempio n. 2
0
 /**
  */
 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();
 }
Esempio n. 3
0
 /**
  * @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'));
 }
Esempio n. 4
0
 /**
  */
 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();
 }
Esempio n. 5
0
  /**
   *
   */
  function __construct() {
    $this->_customGroupExtended['civicrm_case'] = array(
      'extends' => array('Case'),
      'filters' => TRUE,
      'title' => ts('Case'),
    );

    $this->_columns = $this->getColumns('Case', array(
          'fields' => FALSE,
        )
      )
      + $this->getColumns('Contact', array());
    $this->_columns['civicrm_case']['fields']['id']['required'] = TRUE;
    $this->_columns['civicrm_contact']['fields']['id']['required'] = TRUE;
    //  $this->_columns['civicrm_case']['fields']['id']['alter_display'] = 'alterCaseID';
    $this->_columns['civicrm_case']['fields']['id']['title'] = 'Case';
    $this->_columns['civicrm_contact']['fields']['gender_id']['no_display'] = TRUE;
    $this->_columns['civicrm_contact']['fields']['gender_id']['title'] = 'Gender';
    $this->_columns['civicrm_contact']['fields']['gender_id']['alter_display'] = 'alterGenderID';
    $this->_columns['civicrm_case']['fields']['case_status_id']['title'] = ts('Case Status');
    $this->_columns['civicrm_case']['fields']['case_status_id']['options'] = CRM_Case_BAO_Case::buildOptions('status_id');
    $this->_columns['civicrm_contact']['fields']['case_status_id']['no_display'] = TRUE;
    $this->_columns['civicrm_case']['fields']['case_status_id']['name'] = 'status_id';
    $this->_columns['civicrm_case']['filters']['case_is_deleted']['default'] = 0;


    $this->_aggregateRowFields = array(
      'case_civireport:id' => 'Case',
      'case_civireport:case_status_id' => 'Case Status',
      'civicrm_contact_civireport:gender_id' => 'Gender',
    );
    $this->_aggregateColumnHeaderFields = array(
      'civicrm_contact_civireport:gender_id' => 'Gender',
      'case_civireport:case_status_id' => 'Case Status',
    );
    $this->_tagFilter = TRUE;
    $this->_groupFilter = TRUE;
    parent::__construct();
  }
Esempio n. 6
0
 /**
  * Get all cases with no end dates
  *
  * @param array $params
  * @param array $excludeCaseIds
  * @param bool $excludeDeleted
  *
  * @return array of case and related data keyed on case id
  */
 static function getUnclosedCases($params = array(), $excludeCaseIds = array(), $excludeDeleted = TRUE, $includeClosed = FALSE)
 {
     //params from ajax call.
     $where = array($includeClosed ? '(1)' : '(ca.end_date is null)');
     if ($caseType = CRM_Utils_Array::value('case_type', $params)) {
         $where[] = "( civicrm_case_type.title LIKE '%{$caseType}%' )";
     }
     if ($sortName = CRM_Utils_Array::value('sort_name', $params)) {
         $config = CRM_Core_Config::singleton();
         $search = $config->includeWildCardInName ? "%{$sortName}%" : "{$sortName}%";
         $where[] = "( sort_name LIKE '{$search}' )";
     }
     if ($cid = CRM_Utils_Array::value('contact_id', $params)) {
         $where[] = " c.id = {$cid} ";
     }
     if (is_array($excludeCaseIds) && !CRM_Utils_System::isNull($excludeCaseIds)) {
         $where[] = ' ( ca.id NOT IN ( ' . implode(',', $excludeCaseIds) . ' ) ) ';
     }
     if ($excludeDeleted) {
         $where[] = ' ( ca.is_deleted = 0 OR ca.is_deleted IS NULL ) ';
     }
     //filter for permissioned cases.
     $filterCases = array();
     $doFilterCases = FALSE;
     if (!CRM_Core_Permission::check('access all cases and activities')) {
         $doFilterCases = TRUE;
         $session = CRM_Core_Session::singleton();
         $filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
     }
     $whereClause = implode(' AND ', $where);
     $limitClause = '';
     if ($limit = CRM_Utils_Array::value('limit', $params)) {
         $limitClause = "LIMIT 0, {$limit}";
     }
     $query = "\n    SELECT  c.id as contact_id,\n            c.sort_name,\n            ca.id,\n            ca.subject as case_subject,\n            civicrm_case_type.title as case_type,\n            ca.start_date as start_date,\n            ca.end_date as end_date,\n            ca.status_id\n      FROM  civicrm_case ca INNER JOIN civicrm_case_contact cc ON ca.id=cc.case_id\n INNER JOIN  civicrm_contact c ON cc.contact_id=c.id\n INNER JOIN  civicrm_case_type ON ca.case_type_id = civicrm_case_type.id\n     WHERE  {$whereClause}\n  ORDER BY  c.sort_name, ca.end_date\n            {$limitClause}\n";
     $dao = CRM_Core_DAO::executeQuery($query);
     $statuses = CRM_Case_BAO_Case::buildOptions('status_id', 'create');
     $unclosedCases = array();
     while ($dao->fetch()) {
         if ($doFilterCases && !array_key_exists($dao->id, $filterCases)) {
             continue;
         }
         $unclosedCases[$dao->id] = array('sort_name' => $dao->sort_name, 'case_type' => $dao->case_type, 'contact_id' => $dao->contact_id, 'start_date' => $dao->start_date, 'end_date' => $dao->end_date, 'case_subject' => $dao->case_subject, 'case_status' => $statuses[$dao->status_id]);
     }
     $dao->free();
     return $unclosedCases;
 }
Esempio n. 7
0
 /**
  * Build the form object.
  */
 public function preProcess()
 {
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
     }
     //CRM-4418
     if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         return TRUE;
     }
     if (!$this->_caseId) {
         $caseAttributes = array('case_type_id' => ts('Case Type'), 'status_id' => ts('Case Status'), 'medium_id' => ts('Activity Medium'));
         foreach ($caseAttributes as $key => $label) {
             if (!CRM_Case_BAO_Case::buildOptions($key, 'create')) {
                 CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => $label)));
             }
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         if (!$this->_activityTypeId) {
             CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.'));
         }
     }
     //check for case permissions.
     if (!CRM_Case_BAO_Case::accessCiviCase()) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
     }
     $details = CRM_Case_PseudoConstant::caseActivityType(FALSE);
     CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
     $this->assign('activityType', $details[$this->_activityTypeId]['label']);
     $this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']);
     if (isset($this->_currentlyViewedContactId)) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_currentlyViewedContactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId)));
         }
         $this->assign('clientName', $contact->display_name);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     //when custom data is included in this page
     CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity');
     $className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}";
     $className::preProcess($this);
     $activityGroupTree = $this->_groupTree;
     // for case custom fields to populate with defaults
     if (!empty($_POST['hidden_custom'])) {
         $params = CRM_Utils_Request::exportValues();
         CRM_Custom_Form_CustomData::preProcess($this, NULL, CRM_Utils_Array::value('case_type_id', $params, $this->_caseTypeId), 1, 'Case', $this->_caseId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     // so that grouptree is not populated with case fields, since the grouptree is used
     // for populating activity custom fields.
     $this->_groupTree = $activityGroupTree;
 }
Esempio n. 8
0
  /**
   * @return array
   */
  function getCaseColumns($options) {
    $config = CRM_Core_Config::singleton();
    if (!in_array('CiviCase', $config->enableComponents)) {
      return array();
    }

    $spec = array(
      'civicrm_case' => array(
        'fields' => array(
          'case_id' => array(
            'title' => ts('Case ID'),
            'required' => FALSE,
            'name' => 'id',
            'is_fields' => TRUE,
          ),
          'subject' => array(
            'title' => ts('Case Subject'),
            'default' => TRUE,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
          ),
          'case_status_id' => array(
            'title' => ts('Case Status'),
            'default' => TRUE,
            'name' => 'status_id',
            'is_fields' => TRUE,
            'is_filters' => TRUE,
            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
            'options' => CRM_Case_BAO_Case::buildOptions('case_status_id'),
          ),
          'case_type_id' => array(
            'title' => ts('Case Type'),
            'default' => TRUE,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
            'options' => CRM_Case_BAO_Case::buildOptions('case_type_id'),
            'name' => 'case_type_id',
          ),
          'case_start_date' => array(
            'title' => ts('Case Start Date'),
            'name' => 'start_date',
            'operatorType' => CRM_Report_Form::OP_DATE,
            'type' => CRM_Utils_Type::T_DATE,
            'default' => TRUE,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
          ),
          'case_end_date' => array(
            'title' => ts('Case End Date'),
            'name' => 'end_date',
            'default' => TRUE,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
            'operatorType' => CRM_Report_Form::OP_DATE,
            'type' => CRM_Utils_Type::T_DATE,
          ),
          'case_duration' => array(
            'name' => 'duration',
            'title' => ts('Duration (Days)'),
            'default' => FALSE,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
          ),
          'case_is_deleted' => array(
            'name' => 'is_deleted',
            'title' => ts('Case Deleted?'),
            'default' => FALSE,
            'type' => CRM_Utils_Type::T_INT,
            'is_fields' => TRUE,
            'is_filters' => TRUE,
            'operatorType' => CRM_Report_Form::OP_SELECT,
            'options' => array('' => '--select--') + CRM_Case_BAO_Case::buildOptions('is_deleted'),
            )
          )
        ),

    );
    return $this->buildColumns($spec['civicrm_case']['fields'], $options['prefix'] . 'civicrm_case', 'CRM_Case_DAO_Case');

  }
Esempio n. 9
0
 /**
  * Set default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @param CRM_Core_Form $form
  */
 public static function setDefaultValues(&$form)
 {
     $defaults = array();
     if ($form->_context == 'caseActivity') {
         return $defaults;
     }
     list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
     // set default case status, case type, encounter medium, location type and phone type defaults are set in DB
     if ($form->_caseStatusId) {
         $caseStatus = $form->_caseStatusId;
     } else {
         $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1');
         if (count($caseStatus) == 1) {
             $caseStatus = key($caseStatus);
             //$defaults['status_id'] = key($caseStatus);
         }
     }
     $defaults['status_id'] = $caseStatus;
     // set default case type passed in url
     if ($form->_caseTypeId) {
         $defaults['case_type_id'] = $form->_caseTypeId;
     } else {
         // TODO: Not possible yet to set a default case type in the system
         // For now just add the convenience of auto-selecting if there is only one option
         $caseTypes = CRM_Case_BAO_Case::buildOptions('case_type_id', 'create');
         if (count($caseTypes) == 1) {
             reset($caseTypes);
             $defaults['case_type_id'] = key($caseTypes);
         }
     }
     $medium = CRM_Core_OptionGroup::values('encounter_medium', FALSE, FALSE, FALSE, 'AND is_default = 1');
     if (count($medium) == 1) {
         $defaults['medium_id'] = key($medium);
     }
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     if ($defaultLocationType->id) {
         $defaults['location[1][location_type_id]'] = $defaultLocationType->id;
     }
     $phoneType = CRM_Core_OptionGroup::values('phone_type', FALSE, FALSE, FALSE, 'AND is_default = 1');
     if (count($phoneType) == 1) {
         $defaults['location[1][phone][1][phone_type_id]'] = key($phoneType);
     }
     return $defaults;
 }