protected function getContributionStatus()
 {
     return array('' => ts('-- please select --')) + CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('contribution_status');
 }
Beispiel #2
0
 /**
  * @param $rev
  */
 public function upgrade_4_4_1($rev)
 {
     $config = CRM_Core_Config::singleton();
     // CRM-13327 upgrade handling for the newly added name badges
     $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'name_badge', 'id', 'name');
     $nameBadges = array_flip(array_values(CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('name_badge')));
     unset($nameBadges['Avery 5395']);
     if (!empty($nameBadges)) {
         $dimension = '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}';
         $query = "UPDATE civicrm_option_value\n        SET value = '{$dimension}'\n        WHERE option_group_id = %1 AND name = 'Fattorini Name Badge 100x65'";
         CRM_Core_DAO::executeQuery($query, array(1 => array($ogID, 'Integer')));
     } else {
         $dimensions = array(1 => '{"paper-size":"a4","orientation":"landscape","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":1,"metric":"mm","lMargin":25,"tMargin":27,"SpaceX":0,"SpaceY":35,"width":106,"height":150,"lPadding":5,"tPadding":5}', 2 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}', 3 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":2,"metric":"mm","lMargin":10,"tMargin":28,"SpaceX":0,"SpaceY":0,"width":96,"height":121,"lPadding":5,"tPadding":5}');
         $insertStatements = array(1 => "({$ogID}, %1, '{$dimensions[1]}', %1, NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL)", 2 => "({$ogID}, %2, '{$dimensions[2]}', %2, NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL)", 3 => "({$ogID}, %3, '{$dimensions[3]}', %3, NULL, 0, NULL, 4, NULL, 0, 0, 1, NULL, NULL)");
         $queryParams = array(1 => array('A6 Badge Portrait 150x106', 'String'), 2 => array('Fattorini Name Badge 100x65', 'String'), 3 => array('Hanging Badge 3-3/4" x 4-3"/4', 'String'));
         foreach ($insertStatements as $values) {
             $query = 'INSERT INTO civicrm_option_value (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES' . $values;
             CRM_Core_DAO::executeQuery($query, $queryParams);
         }
     }
     // CRM-12578 - Prior to this version a CSS file under drupal would disable core css
     if (!empty($config->customCSSURL) && strpos($config->userFramework, 'Drupal') === 0) {
         // The new setting doesn't exist yet - need to create it first
         $sql = '
     INSERT INTO civicrm_setting (group_name, name , value , domain_id , is_domain , created_date)
     VALUES (%1, %2, %3, %4, %5, now())';
         CRM_Core_DAO::executeQuery($sql, array(1 => array(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'String'), 2 => array('disable_core_css', 'String'), 3 => array(serialize(1), 'String'), 4 => array(CRM_Core_Config::domainID(), 'Positive'), 5 => array(1, 'Int')));
         Civi::service('settings_manager')->flush();
     }
     // CRM-13701 - Fix $config->timeInputFormat
     $sql = "\n      SELECT time_format\n      FROM   civicrm_preferences_date\n      WHERE  time_format IS NOT NULL\n      AND    time_format <> ''\n      LIMIT  1\n    ";
     $timeInputFormat = CRM_Core_DAO::singleValueQuery($sql);
     if ($timeInputFormat && $timeInputFormat != $config->timeInputFormat) {
         $params = array('timeInputFormat' => $timeInputFormat);
         CRM_Core_BAO_ConfigSetting::add($params);
     }
     // CRM-13698 - add 'Available' and 'No-show' activity statuses
     $insertStatus = array();
     $nsinc = $avinc = $inc = 0;
     if (!CRM_Core_OptionGroup::getValue('activity_status', 'Available', 'name')) {
         $insertStatus[] = "(%1, 'Available', %2, 'Available',  NULL, 0, NULL, %3, 0, 0, 1, NULL, NULL)";
         $avinc = $inc = 1;
     }
     if (!CRM_Core_OptionGroup::getValue('activity_status', 'No_show', 'name')) {
         $insertStatus[] = "(%1, 'No-show', %4, 'No_show',  NULL, 0, NULL, %5, 0, 0, 1, NULL, NULL)";
         $nsinc = $inc + 1;
     }
     if (!empty($insertStatus)) {
         $acOptionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_status', 'id', 'name');
         $maxVal = CRM_Core_DAO::singleValueQuery("SELECT MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id  = {$acOptionGroupID}");
         $maxWeight = CRM_Core_DAO::singleValueQuery("SELECT MAX(weight) FROM civicrm_option_value WHERE option_group_id = {$acOptionGroupID}");
         $p[1] = array($acOptionGroupID, 'Integer');
         if ($avinc) {
             $p[2] = array($avinc + $maxVal, 'Integer');
             $p[3] = array($avinc + $maxWeight, 'Integer');
         }
         if ($nsinc) {
             $p[4] = array($nsinc + $maxVal, 'Integer');
             $p[5] = array($nsinc + $maxWeight, 'Integer');
         }
         $insertStatus = implode(',', $insertStatus);
         $sql = "\nINSERT INTO\n   civicrm_option_value (`option_group_id`, label, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)\nVALUES {$insertStatus}";
         CRM_Core_DAO::executeQuery($sql, $p);
     }
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.1')), 'runSql', $rev);
     $this->addTask('Patch word-replacement schema', 'wordReplacements_patch', $rev);
 }
Beispiel #3
0
function hrcase_civicrm_buildForm($formName, &$form)
{
    //change pageTitle for adding Case/Assignment Activity
    if ($formName == 'CRM_Case_Form_Activity') {
        $contactDisplayName = CRM_Contact_BAO_Contact::displayName($form->getVar('_targetContactId'));
        $viewedContactDisplayName = CRM_Contact_BAO_Contact::displayName($form->_currentlyViewedContactId);
        if ($form->_activityTypeName == 'Created New Assignment') {
            CRM_Utils_System::setTitle($viewedContactDisplayName . ' - ' . ts('Created New Assignment'));
        }
        if ($form->_activityTypeName == 'Change Assignment Type') {
            CRM_Utils_System::setTitle($contactDisplayName . ' - ' . ts('Change Assignment Type'));
        } elseif ($form->_activityTypeName == 'Change Assignment Status') {
            CRM_Utils_System::setTitle($contactDisplayName . ' - ' . ts('Change Assignment Status'));
        } elseif ($form->_activityTypeName == 'Change Assignment Start Date') {
            CRM_Utils_System::setTitle($contactDisplayName . ' - ' . ts('Change Assignment Start Date'));
        } elseif ($form->_activityTypeName == 'Link Assignments') {
            CRM_Utils_System::setTitle($contactDisplayName . ' - ' . ts('Link Assignments'));
        }
    }
    //change label and page title
    if ($formName == 'CRM_Case_Form_Case') {
        CRM_Utils_System::setTitle(ts('Create New Assignment'));
    }
    //remove Run QA Audit/Redact dropdown,
    if ($formName == 'CRM_Case_Form_CaseView') {
        if ($form->elementExists('report_id') || $form->elementExists('activity_type_filter_id')) {
            $check = $form->getElement('report_id');
            $check->_attributes = array();
            array_push($check->_attributes, 'display:none');
        }
    }
    if ($form instanceof CRM_Case_Form_Activity or $form instanceof CRM_Case_Form_Case or $form instanceof CRM_Case_Form_CaseView) {
        $optionID = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('activity_status');
        $completed = array_search('Completed', $optionID);
        CRM_Core_Resources::singleton()->addSetting(array('hrcase' => array('statusID' => $completed)));
        if ($form instanceof CRM_Case_Form_CaseView) {
            CRM_Core_Resources::singleton()->addSetting(array('hrcase' => array('manageScreen' => 1)));
        }
        CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrcase', 'js/hrcase.js');
    }
}
Beispiel #4
0
 /**
  * @param CRM_Core_Form $form
  */
 public static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
         // this is loaded onto then replace with something like '__' & test
         $separator = CRM_Core_DAO::VALUE_SEPARATOR;
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
             $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '&nbsp;&nbsp;', TRUE);
             $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
             $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
             $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
             $form->add('hidden', 'group_search_selected', 'group');
         }
     }
     if ($form->_searchOptions['tags']) {
         // multiselect for categories
         $contactTags = CRM_Core_BAO_Tag::getTags();
         if ($contactTags) {
             $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
         }
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE);
         $used_for = CRM_Core_OptionGroup::values('tag_used_for');
         $tagsTypes = array();
         $showAllTagTypes = FALSE;
         foreach ($used_for as $key => $value) {
             //check tags for every type and find if there are any defined
             $tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL);
             // check if there are tags other than contact type, if no - keep checkbox hidden on adv search
             // we will hide searching contact by attachments tags until it will be implemented in core
             if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') {
                 //if tags exists then add type to display in adv search form help text
                 $tagsTypes[] = ts($value);
                 $showAllTagTypes = TRUE;
             }
         }
         $tagTypesText = implode(" or ", $tagsTypes);
         if ($showAllTagTypes) {
             $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText)));
             $form->add('hidden', 'tag_types_text', $tagTypesText);
         }
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source'));
     //added job title
     $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title'));
     //added internal ID
     $form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id'));
     $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger');
     //added external ID
     $form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'));
     if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) {
         $form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
     }
     // add checkbox for cms users only
     $form->addYesNo('uf_user', ts('CMS User?'), TRUE);
     // tag all search
     $form->add('text', 'tag_search', ts('All Tags'));
     // add search profiles
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->add('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles, FALSE, array('class' => 'crm-select2'));
     $componentModes = CRM_Contact_Form_Search::getModeSelect();
     // unset contributions or participants if user does not have
     // permission on them
     if (!CRM_Core_Permission::access('CiviContribute')) {
         unset($componentModes['2']);
     }
     if (!CRM_Core_Permission::access('CiviEvent')) {
         unset($componentModes['3']);
     }
     if (!CRM_Core_Permission::access('CiviMember')) {
         unset($componentModes['5']);
     }
     if (!CRM_Core_Permission::check('view all activities')) {
         unset($componentModes['4']);
     }
     if (count($componentModes) > 1) {
         $form->add('select', 'component_mode', ts('Display Results As'), $componentModes, FALSE, array('class' => 'crm-select2'));
     }
     $form->addRadio('operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')), array('allowClear' => FALSE));
     // add the option to display relationships
     $rTypes = CRM_Core_PseudoConstant::relationshipType();
     $rSelect = array('' => ts('- Select Relationship Type-'));
     foreach ($rTypes as $rid => $rValue) {
         if ($rValue['label_a_b'] == $rValue['label_b_a']) {
             $rSelect[$rid] = $rValue['label_a_b'];
         } else {
             $rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
             $rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
         }
     }
     $form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect, array('class' => 'crm-select2'));
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND')));
     $options = array(1 => ts('Exclude'), 2 => ts('Include by Privacy Option(s)'));
     $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, array('allowClear' => FALSE));
     // preferred communication method
     $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
     }
     $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, '');
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search'));
     // Phone search
     $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
     $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2'));
     $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2'));
 }
 /**
  * Returns an array with all possible options for the field, in
  * case the field is a select field, e.g. gender, or financial type
  * Return false when the field is a select field
  *
  * This method could be overriden by child classes to return the option
  *
  * The return is an array with the field option value as key and the option label as value
  *
  * @return bool
  */
 public function getFieldOptions()
 {
     return CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('case_status');
 }