function __construct()
 {
     $this->customGroup = CRM_Volunteer_BAO_Assignment::getCustomGroup();
     $this->customFields = CRM_Volunteer_BAO_Assignment::getCustomFields();
     $this->activityTypeID = CRM_Volunteer_BAO_Assignment::getActivityTypeId();
     $this->_columns = array('project' => array('fields' => array('project' => array('name' => 'title', 'title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'no_repeat' => TRUE, 'default' => TRUE)), 'alias' => 'project', 'order_bys' => array('title' => array('title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'default' => 1)), 'grouping' => 'project-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_assignee' => array('name' => 'sort_name', 'title' => ts('Volunteer Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_contact_assignee_civireport', 'default' => TRUE, 'required' => TRUE), 'contact_source' => array('name' => 'sort_name', 'title' => ts('Source Contact Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_contact_source', 'no_repeat' => TRUE), 'contact_target' => array('name' => 'sort_name', 'title' => ts('Target Contact Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'contact_civireport')), 'filters' => array('contact_assignee' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_assignee_civireport', 'title' => ts('Volunteer Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_source' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_source', 'title' => ts('Source Contact Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_target' => array('name' => 'sort_name', 'alias' => 'contact_civireport', 'title' => ts('Target Contact Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'current_user' => array('name' => 'current_user', 'title' => ts('Limit To Current User', array('domain' => 'org.civicrm.volunteer')), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No', array('domain' => 'org.civicrm.volunteer')), '1' => ts('Yes', array('domain' => 'org.civicrm.volunteer'))))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name', array('domain' => 'org.civicrm.volunteer')), 'default' => '1')), 'alias' => 'civicrm_contact_assignee'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('contact_assignee_email' => array('name' => 'email', 'title' => ts('Volunteer Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_assignee'), 'contact_source_email' => array('name' => 'email', 'title' => ts('Source Contact Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_source'), 'contact_target_email' => array('name' => 'email', 'title' => ts('Target Contact Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_target'))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('contact_assignee_phone' => array('name' => 'phone', 'title' => ts('Volunteer Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_assignee'), 'contact_source_phone' => array('name' => 'phone', 'title' => ts('Source Contact Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_source'), 'contact_target_phone' => array('name' => 'phone', 'title' => ts('Target Contact Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_target'))), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'source_record_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_type_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_subject' => array('title' => ts('Subject', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE), 'activity_date_time' => array('title' => ts('Scheduled Date/Time', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'status_id' => array('title' => ts('Activity Status', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING)), 'filters' => array('activity_date_time' => array('default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE), 'activity_subject' => array('title' => ts('Activity Subject', array('domain' => 'org.civicrm.volunteer'))), 'id' => array('title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, 'attributes' => array('entity' => 'VolunteerProject', 'select' => array('minimumInputLength' => 0)), 'alias' => 'project_civireport'), 'status_id' => array('title' => ts('Activity Status', array('domain' => 'org.civicrm.volunteer')), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()))), 'civicrm_activity_assignment' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_assignment'), 'civicrm_activity_target' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_target'), 'civicrm_activity_source' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_source'), 'role' => array('fields' => array('role' => array('name' => $this->customFields['volunteer_role_id']['column_name'], 'title' => ts('Volunteer Role', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE)), 'order_bys' => array('name' => array('title' => ts('Volunteer Role', array('domain' => 'org.civicrm.volunteer')))), 'alias' => 'ov'), 'time_scheduled' => array('fields' => array('time_scheduled' => array('name' => $this->customFields['time_scheduled_minutes']['column_name'], 'title' => ts('Time Scheduled in Minutes', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE))), 'time_completed' => array('fields' => array('time_completed' => array('name' => $this->customFields['time_completed_minutes']['column_name'], 'title' => ts('Time Completed in Minutes', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE))), 'civicrm_case_activity' => array('dao' => 'CRM_Case_DAO_CaseActivity', 'fields' => array('case_id' => array('name' => 'case_id', 'no_display' => TRUE, 'required' => TRUE)), 'alias' => 'case_activity'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
Exemplo n.º 2
0
 function __construct()
 {
     $config = CRM_Core_Config::singleton();
     $this->customGroup = CRM_Volunteer_BAO_Assignment::getCustomGroup();
     $this->customFields = CRM_Volunteer_BAO_Assignment::getCustomFields();
     $this->activityTypeID = CRM_Volunteer_BAO_Assignment::volunteerActivityTypeId();
     $titleQuery = "SELECT e.id, e.title FROM civicrm_event e \n      INNER JOIN civicrm_volunteer_project p ON e.id = p.entity_id\n      WHERE p.is_active = 1";
     $titles = CRM_Core_DAO::executeQuery($titleQuery);
     $this->title = array();
     while ($titles->fetch()) {
         $this->title[$titles->id] = $titles->title;
     }
     asort($this->title);
     $this->_columns = array('project' => array('fields' => array('project' => array('name' => 'title', 'title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'no_repeat' => TRUE, 'default' => TRUE)), 'alias' => 'project', 'order_bys' => array('title' => array('title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'default' => 1)), 'grouping' => 'project-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_assignee' => array('name' => 'sort_name', 'title' => ts('Volunteer Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_contact_assignee_civireport', 'default' => TRUE, 'required' => TRUE), 'contact_source' => array('name' => 'sort_name', 'title' => ts('Source Contact Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_contact_source', 'no_repeat' => TRUE), 'contact_target' => array('name' => 'sort_name', 'title' => ts('Target Contact Name', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'contact_civireport')), 'filters' => array('contact_assignee' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_assignee_civireport', 'title' => ts('Volunteer Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_source' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_source', 'title' => ts('Source Contact Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_target' => array('name' => 'sort_name', 'alias' => 'contact_civireport', 'title' => ts('Target Contact Name', array('domain' => 'org.civicrm.volunteer')), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'current_user' => array('name' => 'current_user', 'title' => ts('Limit To Current User', array('domain' => 'org.civicrm.volunteer')), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No', array('domain' => 'org.civicrm.volunteer')), '1' => ts('Yes', array('domain' => 'org.civicrm.volunteer'))))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name', array('domain' => 'org.civicrm.volunteer')), 'default' => '1')), 'alias' => 'civicrm_contact_assignee'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('contact_assignee_email' => array('name' => 'email', 'title' => ts('Volunteer Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_assignee'), 'contact_source_email' => array('name' => 'email', 'title' => ts('Source Contact Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_source'), 'contact_target_email' => array('name' => 'email', 'title' => ts('Target Contact Email', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_email_target'))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('contact_assignee_phone' => array('name' => 'phone', 'title' => ts('Volunteer Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_assignee'), 'contact_source_phone' => array('name' => 'phone', 'title' => ts('Source Contact Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_source'), 'contact_target_phone' => array('name' => 'phone', 'title' => ts('Target Contact Phone', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'civicrm_phone_target'))), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'source_record_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_type_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_subject' => array('title' => ts('Subject', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE), 'activity_date_time' => array('title' => ts('Scheduled Date/Time', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'status_id' => array('title' => ts('Activity Status', array('domain' => 'org.civicrm.volunteer')), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING)), 'filters' => array('activity_date_time' => array('default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE), 'activity_subject' => array('title' => ts('Activity Subject', array('domain' => 'org.civicrm.volunteer'))), 'id' => array('title' => ts('Project', array('domain' => 'org.civicrm.volunteer')), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->title, 'alias' => 'project_civireport', 'type' => CRM_Utils_Type::T_INT), 'status_id' => array('title' => ts('Activity Status', array('domain' => 'org.civicrm.volunteer')), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()))), 'civicrm_activity_assignment' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_assignment'), 'civicrm_activity_target' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_target'), 'civicrm_activity_source' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('no_display' => TRUE, 'required' => TRUE)), 'alias' => 'activity_source'), 'role' => array('fields' => array('role' => array('name' => $this->customFields['volunteer_role_id']['column_name'], 'title' => ts('Volunteer Role', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE)), 'order_bys' => array('name' => array('title' => ts('Volunteer Role', array('domain' => 'org.civicrm.volunteer')))), 'alias' => 'ov'), 'time_scheduled' => array('fields' => array('time_scheduled' => array('name' => $this->customFields['time_scheduled_minutes']['column_name'], 'title' => ts('Time Scheduled in Minutes', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE))), 'time_completed' => array('fields' => array('time_completed' => array('name' => $this->customFields['time_completed_minutes']['column_name'], 'title' => ts('Time Completed in Minutes', array('domain' => 'org.civicrm.volunteer')), 'alias' => 'cg', 'no_repeat' => TRUE, 'default' => TRUE))), 'civicrm_case_activity' => array('dao' => 'CRM_Case_DAO_CaseActivity', 'fields' => array('case_id' => array('name' => 'case_id', 'no_display' => TRUE, 'required' => TRUE)), 'alias' => 'case_activity'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
/**
 * Callback for core Activity view and form
 *
 * Display user-friendly label for Need ID rather than an integer, or hide
 * the field altogether, depending on context.
 */
function _volunteer_civicrm_buildForm_CRM_Activity_Form_Activity($formName, &$form)
{
    // determine name that the Volunteer Need ID field would be given in this form
    $custom_group = CRM_Volunteer_BAO_Assignment::getCustomGroup();
    $custom_fields = CRM_Volunteer_BAO_Assignment::getCustomFields();
    $group_id = $custom_group['id'];
    $field_id = $custom_fields['volunteer_need_id']['id'];
    // element name varies depending on context
    $possible_element_names = array('custom_' . $field_id . '_1', 'custom_' . $field_id . '_-1');
    $element_name = NULL;
    foreach ($possible_element_names as $name) {
        if ($form->elementExists($name)) {
            $element_name = $name;
            break;
        }
    }
    // If it contains the Volunteer Need ID field, this is an edit form
    if (isset($element_name)) {
        $field = $form->getElement($element_name);
        $form->removeElement($element_name);
        // If need_id isn't set, do not re-add need_id field as a dropdown.
        // See http://issues.civicrm.org/jira/browse/VOL-24?focusedCommentId=53836#comment-53836
        if ($need_id = $field->_attributes['value']) {
            $need = civicrm_api3('VolunteerNeed', 'getsingle', array('id' => $need_id, 'return' => 'project_id'));
            $Project = CRM_Volunteer_BAO_Project::retrieveByID($need['project_id']);
            $needs = array();
            foreach ($Project->needs as $key => $value) {
                $needs[$key] = $value['role_label'] . ': ' . $value['display_time'];
            }
            asort($needs);
            $form->add('select', $element_name, $field->_label, $needs, TRUE);
        }
    } elseif (isset($form->_activityTypeName) && $form->_activityTypeName == 'Volunteer') {
        $custom = $form->get_template_vars('viewCustomData');
        if (!empty($custom[$group_id])) {
            $index = key($custom[$group_id]);
            if (!empty($custom[$group_id][$index]['fields'][$field_id]['field_value'])) {
                $value =& $custom[$group_id][$index]['fields'][$field_id]['field_value'];
                $need = civicrm_api3('VolunteerNeed', 'getsingle', array('id' => $value));
                $value = $need['role_label'] . ': ' . $need['display_time'];
                $form->assign('viewCustomData', $custom);
            }
        }
    }
}