Ejemplo n.º 1
0
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     // add select for tag
     $this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     foreach ($this->_tags as $tagID => $tagName) {
         $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", NULL, $tagName);
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
     $this->addDefaultButtons(ts('Remove Tags from activities'));
 }
Ejemplo n.º 2
0
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     // add select for tag
     $this->_tags = CRM_Core_BAO_Tag::getTags();
     foreach ($this->_tags as $tagID => $tagName) {
         $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", NULL, $tagName);
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_contact');
     $this->addDefaultButtons(ts('Tag Contacts'));
 }
Ejemplo n.º 3
0
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     // add select for tag
     $this->_tags = CRM_Core_BAO_Tag::getTags();
     foreach ($this->_tags as $tagID => $tagName) {
         $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
     }
     require_once 'CRM/Core/Form/Tag.php';
     require_once 'CRM/Core/BAO/Tag.php';
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_contact', null, true);
     $this->addDefaultButtons(ts('Remove Tag Contacts'));
 }
Ejemplo n.º 4
0
 /**
  * Add all the elements shared between case activity search and advanced search.
  *
  *
  * @param CRM_Core_Form $form
  * @return void
  */
 public static function buildSearchForm(&$form)
 {
     $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     $form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
     CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
     $followUpActivity = array(1 => ts('Yes'), 2 => ts('No'));
     $form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
     $form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
     $activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'));
     $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
     $form->setDefaults(array('activity_role' => 3));
     $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
     $form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
     $form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
     $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $form->addYesNo('activity_test', ts('Activity is a Test?'));
     $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if ($activity_tags) {
         foreach ($activity_tags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
         }
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
     $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
     if ($surveys) {
         $form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2'));
     }
     $extends = array('Activity');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
         $form->assign('activityGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     $buildSurveyResult = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
         // Add survey result field.
         $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
         $resultOptions = array();
         foreach ($optionGroups as $gid => $name) {
             if ($name) {
                 $value = array();
                 $value = CRM_Core_OptionGroup::values($name);
                 if (!empty($value)) {
                     while (list($k, $v) = each($value)) {
                         $resultOptions[$v] = $v;
                     }
                 }
             }
         }
         // If no survey result options have been created, don't build
         // the field to avoid clutter.
         if (count($resultOptions) > 0) {
             $buildSurveyResult = TRUE;
             asort($resultOptions);
             $form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2'));
         }
     }
     $form->assign('buildEngagementLevel', $buildEngagementLevel);
     $form->assign('buildSurveyResult', $buildSurveyResult);
     $form->setDefaults(array('activity_test' => 0));
 }
Ejemplo n.º 5
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, '  ', 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'));
 }
 /**
  * This function is to build form elements
  * params object $form object of the form
  *
  * @param Object  $form        the form object that we are operating on
  * @param int     $contactId   contact id
  * @param int     $type        what components are we interested in
  * @param boolean $visibility  visibility of the field
  * @param string  $groupName   if used for building group block
  * @param string  $tagName     if used for building tag block
  * @param string  $fieldName   this is used in batch profile(i.e to build multiple blocks)
  *
  * @static
  * @access public
  */
 static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox')
 {
     if (!isset($form->_tagGroup)) {
         $form->_tagGroup = array();
     }
     // NYSS 5670
     if (!$contactId && !empty($form->_contactId)) {
         $contactId = $form->_contactId;
     }
     $type = (int) $type;
     if ($type & self::GROUP) {
         $fName = 'group';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $groupID = isset($form->_grid) ? $form->_grid : NULL;
         if ($groupID && $visibility) {
             $ids = array($groupID => $groupID);
         } else {
             if ($visibility) {
                 $group = CRM_Core_PseudoConstant::allGroup();
             } else {
                 $group = CRM_Core_PseudoConstant::nestedGroup();
             }
             $ids = $group;
         }
         if ($groupID || !empty($group)) {
             $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
             $attributes['skiplabel'] = TRUE;
             $elements = array();
             $groupsOptions = array();
             foreach ($groups as $id => $group) {
                 // make sure that this group has public visibility
                 if ($visibility && $group['visibility'] == 'User and User Admin Only') {
                     continue;
                 }
                 if ($groupElementType == 'crmasmSelect') {
                     $groupsOptions[$id] = $group['title'];
                 } else {
                     $form->_tagGroup[$fName][$id]['description'] = $group['description'];
                     $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes);
                 }
             }
             if ($groupElementType == 'crmasmSelect' && !empty($groupsOptions)) {
                 $form->add('select', $fName, ts('%1', array(1 => $groupName)), $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'title' => ts('- select -')));
                 $form->assign('groupCount', count($groupsOptions));
             }
             if ($groupElementType == 'checkbox' && !empty($elements)) {
                 $form->addGroup($elements, $fName, $groupName, '&nbsp;<br />');
                 $form->assign('groupCount', count($elements));
                 if ($isRequired) {
                     $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required');
                 }
             }
             $form->assign('groupElementType', $groupElementType);
         }
     }
     if ($type & self::TAG) {
         $fName = 'tag';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $form->_tagGroup[$fName] = 1;
         $elements = array();
         $tag = CRM_Core_BAO_Tag::getTags();
         foreach ($tag as $id => $name) {
             $elements[] = $form->createElement('checkbox', $id, NULL, $name);
         }
         if (!empty($elements)) {
             $form->addGroup($elements, $fName, $tagName, '<br />');
             $form->assign('tagCount', count($elements));
         }
         if ($isRequired) {
             $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required');
         }
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, TRUE, TRUE);
     }
     $form->assign('tagGroup', $form->_tagGroup);
 }
Ejemplo n.º 7
0
 /**
  * add all the elements shared between case activity search  and advanaced search
  *
  * @access public
  *
  * @return void
  * @static
  */
 static function buildSearchForm(&$form)
 {
     $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     asort($activityOptions);
     foreach ($activityOptions as $activityID => $activity) {
         $form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", NULL, $activity, array('onClick' => 'showCustomData( this.id );'));
     }
     CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
     $activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to'));
     $form->addRadio('activity_role', NULL, $activityRoles, NULL, '<br />');
     $form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     foreach ($activityStatus as $activityStatusID => $activityStatusName) {
         $activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName);
     }
     $form->addGroup($activity_status, 'activity_status', ts('Activity Status'));
     $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
     $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $form->addElement('checkbox', 'activity_test', ts('Find Test Activities?'));
     $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if ($activity_tags) {
         foreach ($activity_tags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
         }
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
     $surveys = CRM_Campaign_BAO_Survey::getSurveys();
     if ($surveys) {
         $form->add('select', 'activity_survey_id', ts('Survey'), array('' => ts('- none -')) + $surveys, FALSE);
     }
     $extends = array('Activity');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
         $form->assign('activityGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $form->add('select', 'activity_engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
     }
     $form->assign('buildEngagementLevel', $buildEngagementLevel);
 }
Ejemplo n.º 8
0
 public function buildQuickForm()
 {
     $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
     $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
     $this->assign('multiClient', $isMultiClient);
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         $title = 'Delete';
         if ($this->_action & CRM_Core_Action::RENEW) {
             $title = 'Restore';
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $title, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Case');
     CRM_Custom_Form_CustomData::buildQuickForm($this);
     // we don't want to show button on top of custom form
     $this->assign('noPreCustomButton', TRUE);
     $s = CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject');
     if (!is_array($s)) {
         $s = array();
     }
     $this->add('text', 'activity_subject', ts('Subject'), array_merge($s, array('maxlength' => '128')), TRUE);
     $tags = CRM_Core_BAO_Tag::getTags('civicrm_case');
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Select Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
     }
     // build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );");
 }
Ejemplo n.º 9
0
 /**
  * Add all the elements shared between case search and advanaced search.
  *
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildSearchForm(&$form)
 {
     $config = CRM_Core_Config::singleton();
     //validate case configuration.
     $configured = CRM_Case_BAO_Case::isCaseConfigured();
     $form->assign('notConfigured', !$configured['configured']);
     $form->add('select', 'case_type_id', ts('Case Type'), CRM_Case_PseudoConstant::caseType('title', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
     $form->add('select', 'case_status_id', ts('Case Status'), CRM_Case_PseudoConstant::caseStatus('label', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
     CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE);
     CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE);
     $form->assign('validCiviCase', TRUE);
     //give options when all cases are accessible.
     $accessAllCases = FALSE;
     if (CRM_Core_Permission::check('access all cases and activities')) {
         $accessAllCases = TRUE;
         $caseOwner = array(1 => ts('Search All Cases'), 2 => ts('Only My Cases'));
         $form->addRadio('case_owner', ts('Cases'), $caseOwner);
     }
     $form->assign('accessAllCases', $accessAllCases);
     $caseTags = CRM_Core_BAO_Tag::getTags('civicrm_case');
     if ($caseTags) {
         foreach ($caseTags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "case_tags[{$tagID}]", NULL, $tagName);
         }
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_case', NULL, TRUE, FALSE);
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $form->addElement('checkbox', 'case_deleted', ts('Deleted Cases'));
     }
     // add all the custom  searchable fields
     $extends = array('Case');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
         $form->assign('caseGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     $form->setDefaults(array('case_owner' => 1));
 }
Ejemplo n.º 10
0
 public function buildQuickForm()
 {
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         //enable form element (ActivityLinks sets this true)
         $this->assign('suppressForm', false);
         $button = ts('Delete');
         if ($this->_action & CRM_Core_Action::RENEW) {
             $button = ts('Restore');
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if (!$this->_single && !empty($this->_contactIds)) {
         $withArray = array();
         require_once 'CRM/Contact/BAO/Contact.php';
         foreach ($this->_contactIds as $contactId) {
             $withDisplayName = self::_getDisplayNameById($contactId);
             $withArray[] = "\"{$withDisplayName}\" ";
         }
         $this->assign('with', implode(', ', $withArray));
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //build other activity links
     require_once 'CRM/Activity/Form/ActivityLinks.php';
     CRM_Activity_Form_ActivityLinks::buildQuickForm();
     //enable form element (ActivityLinks sets this true)
     $this->assign('suppressForm', false);
     $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], false, array('onchange' => "buildCustomData( 'Activity', this.value );"));
     //freeze for update mode.
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $element->freeze();
     }
     foreach ($this->_fields as $field => $values) {
         if (CRM_Utils_Array::value($field, $this->_fields)) {
             $attribute = null;
             if (CRM_Utils_Array::value('attributes', $values)) {
                 $attribute = $values['attributes'];
             }
             $required = false;
             if (CRM_Utils_Array::value('required', $values)) {
                 $required = true;
             }
             if ($values['type'] == 'wysiwyg') {
                 $this->addWysiwyg($field, $values['label'], $attribute, $required);
             } else {
                 $this->add($values['type'], $field, $values['label'], $attribute, $required);
             }
         }
     }
     $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     $this->addRule('interval', ts('Please enter the follow-up interval as a number (integers only).'), 'positiveInteger');
     $this->addDateTime('activity_date_time', ts('Date'), true, array('formatType' => 'activityDateTime'));
     //autocomplete url
     $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", false, null, false);
     $this->assign('dataUrl', $dataUrl);
     //tokeninput url
     $tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", false, null, false);
     $this->assign('tokenUrl', $tokenUrl);
     $admin = CRM_Core_Permission::check('administer CiviCRM');
     //allow to edit sourcecontactfield field if context is civicase.
     if ($this->_context == 'caseActivity') {
         $admin = true;
     }
     $this->assign('admin', $admin);
     $sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], null, $admin);
     $hiddenSourceContactField =& $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
     $targetContactField =& $this->add('text', 'target_contact_id', ts('target'));
     $assigneeContactField =& $this->add('text', 'assignee_contact_id', ts('assignee'));
     if ($sourceContactField->getValue()) {
         $this->assign('source_contact', $sourceContactField->getValue());
     } else {
         if ($this->_currentUserId) {
             // we're setting currently LOGGED IN user as source for this activity
             $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId));
         }
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Activity');
     $this->assign('customDataSubType', $this->_activityTypeId);
     $this->assign('entityID', $this->_activityId);
     if ($this->_targetContactId) {
         $defaultTargetContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_targetContactId, 'sort_name');
         $this->assign('target_contact_value', $defaultTargetContactName);
     }
     require_once 'CRM/Core/BAO/Tag.php';
     $tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Tags'), $tags, false, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
     }
     // build tag widget
     require_once 'CRM/Core/Form/Tag.php';
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId, false, true);
     // check for survey activity
     $this->_isSurveyActivity = false;
     if ($this->_activityId) {
         require_once 'CRM/Campaign/BAO/Survey.php';
         $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
         if ($this->_isSurveyActivity) {
             $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
             $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
             if ($responseOptions) {
                 $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
             }
             $surveyTitle = null;
             if ($surveyId) {
                 $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
             }
             $this->assign('surveyTitle', $surveyTitle);
         }
     }
     $this->assign('surveyActivity', $this->_isSurveyActivity);
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
         if (isset($this->_groupTree)) {
             CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
         }
         $buttons = array();
         // do check for permissions
         require_once 'CRM/Case/BAO/Case.php';
         if (CRM_Case_BAO_Case::checkPermission($this->_activityId, 'File On Case', $this->_activityTypeId)) {
             $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'subName' => 'file_on_case', 'js' => array('onClick' => "Javascript:fileOnCase( \"file\", {$this->_activityId} ); return false;"));
         }
         // form should be frozen for view mode
         $this->freeze();
         $buttons[] = array('type' => 'cancel', 'name' => ts('Done'));
         $this->addButtons($buttons);
     } else {
         $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'));
         $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
     if ($this->_activityTypeFile) {
         eval("CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );");
     }
     if ($this->_activityTypeFile) {
         eval('$this->addFormRule' . "(array('CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}', 'formrule'), \$this);");
     }
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
 }
Ejemplo n.º 11
0
 public function buildQuickForm()
 {
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         //enable form element (ActivityLinks sets this true)
         $this->assign('suppressForm', FALSE);
         $button = ts('Delete');
         if ($this->_action & CRM_Core_Action::RENEW) {
             $button = ts('Restore');
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if (!$this->_single && !empty($this->_contactIds)) {
         $withArray = array();
         foreach ($this->_contactIds as $contactId) {
             $withDisplayName = self::_getDisplayNameById($contactId);
             $withArray[] = "\"{$withDisplayName}\" ";
         }
         $this->assign('with', implode(', ', $withArray));
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //build other activity links
     CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
     //enable form element (ActivityLinks sets this true)
     $this->assign('suppressForm', FALSE);
     $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );"));
     //freeze for update mode.
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $element->freeze();
     }
     foreach ($this->_fields as $field => $values) {
         if (CRM_Utils_Array::value($field, $this->_fields)) {
             $attribute = NULL;
             if (CRM_Utils_Array::value('attributes', $values)) {
                 $attribute = $values['attributes'];
             }
             $required = FALSE;
             if (CRM_Utils_Array::value('required', $values)) {
                 $required = TRUE;
             }
             if ($values['type'] == 'wysiwyg') {
                 $this->addWysiwyg($field, $values['label'], $attribute, $required);
             } else {
                 $this->add($values['type'], $field, $values['label'], $attribute, $required);
             }
         }
     }
     //CRM-7362 --add campaigns.
     CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $this->add('select', 'engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
         $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
     }
     $this->assign('buildEngagementLevel', $buildEngagementLevel);
     // check for survey activity
     $this->_isSurveyActivity = FALSE;
     if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
         if ($this->_isSurveyActivity) {
             $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
             $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
             if ($responseOptions) {
                 $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
             }
             $surveyTitle = NULL;
             if ($surveyId) {
                 $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
             }
             $this->assign('surveyTitle', $surveyTitle);
         }
     }
     $this->assign('surveyActivity', $this->_isSurveyActivity);
     // this option should be available only during add mode
     if ($this->_action != CRM_Core_Action::UPDATE) {
         $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
     }
     $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
     //add followup date
     $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
     //autocomplete url
     $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE);
     $this->assign('dataUrl', $dataUrl);
     //tokeninput url
     $tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", FALSE, NULL, FALSE);
     $this->assign('tokenUrl', $tokenUrl);
     $admin = CRM_Core_Permission::check('administer CiviCRM');
     //allow to edit source contact field field if context is civicase.
     if ($this->_context == 'caseActivity') {
         $admin = TRUE;
     }
     $this->assign('admin', $admin);
     $sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], NULL, $admin);
     $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
     CRM_Contact_Form_NewContact::buildQuickForm($this);
     $this->add('text', 'assignee_contact_id', ts('assignee'));
     if ($sourceContactField->getValue()) {
         $this->assign('source_contact', $sourceContactField->getValue());
     } elseif ($this->_currentUserId) {
         // we're setting currently LOGGED IN user as source for this activity
         $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId));
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Activity');
     $this->assign('customDataSubType', $this->_activityTypeId);
     $this->assign('entityID', $this->_activityId);
     $tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
     }
     // we need to hide activity tagset for special activities
     $specialActivities = array('Open Case');
     if (!in_array($this->_activityTypeName, $specialActivities)) {
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
         CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId, TRUE, TRUE);
     }
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
         if (isset($this->_groupTree)) {
             CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
         }
         $buttons = array();
         // do check for permissions
         if (CRM_Case_BAO_Case::checkPermission($this->_activityId, 'File On Case', $this->_activityTypeId)) {
             $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'subName' => 'file_on_case', 'js' => array('onClick' => "javascript:fileOnCase( \"file\", {$this->_activityId} ); return false;"));
         }
         // form should be frozen for view mode
         $this->freeze();
         $buttons[] = array('type' => 'cancel', 'name' => ts('Done'));
         $this->addButtons($buttons);
     } else {
         $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'));
         $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::buildQuickForm($this);
         $this->addFormRule(array($className, 'formRule'), $this);
     }
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $this->assign('activityAssigneeNotification', TRUE);
     } else {
         $this->assign('activityAssigneeNotification', FALSE);
     }
 }
Ejemplo n.º 12
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     // get categories for the contact id
     $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
     $this->assign('tree', $tree);
     $this->assign('tag', $allTag);
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
     if ($this->_action & CRM_Core_Action::BROWSE) {
         $this->freeze();
     } else {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
Ejemplo n.º 13
0
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
     // get categories for the contact id
     $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
     $this->assign('tree', $tree);
     $this->assign('tag', $allTag);
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
     if ($this->_action & CRM_Core_Action::BROWSE) {
         $this->freeze();
     } else {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
 /**
  * This function is to build form elements
  * params object $form object of the form
  *
  * @param Object  $form        the form object that we are operating on
  * @param int     $contactId   contact id
  * @param int     $type        what components are we interested in
  * @param boolean $visibility  visibility of the field
  * @param string  $groupName   if used for building group block
  * @param string  $tagName     if used for building tag block
  * @param string  $fieldName   this is used in batch profile(i.e to build multiple blocks)
  *
  * @static
  * @access public
  */
 static function buildQuickForm(&$form, $contactId = 0, $type = CRM_Contact_Form_Edit_TagsandGroups::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL)
 {
     if (!isset($form->_tagGroup)) {
         $form->_tagGroup = array();
     }
     // NYSS 5670
     if (!$contactId && !empty($form->_contactId)) {
         $contactId = $form->_contactId;
     }
     $type = (int) $type;
     if ($type & CRM_Contact_Form_Edit_TagsandGroups::GROUP) {
         $fName = 'group';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $elements = array();
         $groupID = isset($form->_grid) ? $form->_grid : NULL;
         if ($groupID && $visibility) {
             $ids = "= {$groupID}";
         } else {
             if ($visibility) {
                 $group = CRM_Core_PseudoConstant::allGroup();
             } else {
                 $group = CRM_Core_PseudoConstant::group();
             }
             $ids = implode(',', array_keys($group));
             $ids = 'IN (' . $ids . ')';
         }
         if ($groupID || !empty($group)) {
             $sql = "\n    SELECT   id, title, description, visibility\n    FROM     civicrm_group\n    WHERE    id {$ids}\n    ORDER BY title\n    ";
             $dao = CRM_Core_DAO::executeQuery($sql);
             $attributes['skiplabel'] = TRUE;
             while ($dao->fetch()) {
                 // make sure that this group has public visibility
                 if ($visibility && $dao->visibility == 'User and User Admin Only') {
                     continue;
                 }
                 $form->_tagGroup[$fName][$dao->id]['description'] = $dao->description;
                 $elements[] =& $form->addElement('advcheckbox', $dao->id, NULL, $dao->title, $attributes);
             }
             if (!empty($elements)) {
                 $form->addGroup($elements, $fName, $groupName, '&nbsp;<br />');
                 $form->assign('groupCount', count($elements));
                 if ($isRequired) {
                     $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required');
                 }
             }
         }
     }
     if ($type & CRM_Contact_Form_Edit_TagsandGroups::TAG) {
         $fName = 'tag';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $form->_tagGroup[$fName] = 1;
         $elements = array();
         $tag = CRM_Core_BAO_Tag::getTags();
         foreach ($tag as $id => $name) {
             $elements[] = $form->createElement('checkbox', $id, NULL, $name);
         }
         if (!empty($elements)) {
             $form->addGroup($elements, $fName, $tagName, '<br />');
             $form->assign('tagCount', count($elements));
         }
         if ($isRequired) {
             $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required');
         }
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
     }
     $form->assign('tagGroup', $form->_tagGroup);
 }
Ejemplo n.º 15
0
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     //this call is for show related cases.
     if ($this->_showRelatedCases) {
         return;
     }
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js')->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
     $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
     //adding case manager.CRM-4510.
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE);
     $allActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
     $emailActivityType = array_search('Email', $allActTypes);
     $pdfActivityType = array_search('Print PDF Letter', $allActTypes);
     // remove Open Case activity type since we're inside an existing case
     if ($openActTypeId = array_search('Open Case', $allActTypes)) {
         unset($aTypes[$openActTypeId]);
     }
     //check for link cases.
     $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(NULL, array($this->_caseID));
     if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes))) {
         unset($aTypes[$linkActTypeId]);
     }
     if (!$xmlProcessor->getNaturalActivityTypeSort()) {
         asort($aTypes);
     }
     $activityLinks = array('' => ts('Add Activity'));
     foreach ($aTypes as $type => $label) {
         if ($type == $emailActivityType) {
             $url = CRM_Utils_System::url('civicrm/activity/email/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
         } else {
             if ($type == $pdfActivityType) {
                 $url = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
             } else {
                 $url = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
             }
         }
         $activityLinks[$url] = $label;
     }
     $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-plus twenty'));
     if ($this->_hasAccessToAllCases) {
         $this->add('select', 'report_id', '', array('' => ts('Activity Audit')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-clipboard'));
         $this->add('select', 'timeline_id', '', array('' => ts('Add Timeline')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu action-icon-play'));
     }
     $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement'));
     if ($this->_mergeCases) {
         $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID);
         $otherCases = array();
         foreach ($allCases as $caseId => $details) {
             //filter current and own cases.
             if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) {
                 continue;
             }
             $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date'];
         }
         if (empty($otherCases)) {
             $this->_mergeCases = FALSE;
             $this->assign('mergeCases', $this->_mergeCases);
         } else {
             $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases, FALSE, array('class' => 'crm-select2 huge'));
             $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'crm-form-submit-inline hiddenElement'));
         }
     }
     //call activity form
     self::activityForm($this);
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
     //save special label because we unset it in the loop
     $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId];
     foreach ($caseRelationships as $key => &$value) {
         if (!empty($managerRoleId)) {
             if ($managerRoleId == $value['relation_type']) {
                 $value['relation'] = $managerLabel;
             }
         }
         //calculate roles that don't have relationships
         if (!empty($caseRoles[$value['relation_type']])) {
             unset($caseRoles[$value['relation_type']]);
         }
     }
     $this->assign('caseRelationships', $caseRelationships);
     //also add client as role. CRM-4438
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID);
     $this->assign('caseRoles', $caseRoles);
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE);
     // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
     // so they don't show up twice.
     $clientRelationships = array();
     foreach ($relClient as $r) {
         if (!array_key_exists($r['id'], $caseRelationships)) {
             $clientRelationships[] = $r;
         }
     }
     $this->assign('clientRelationships', $clientRelationships);
     // Now global contact list that appears on all cases.
     $globalGroupInfo = array();
     CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
     $this->assign('globalGroupInfo', $globalGroupInfo);
     // List of relationship types
     $baoRel = new CRM_Contact_BAO_Relationship();
     $relType = $baoRel->getRelationType('Individual');
     $roleTypes = array();
     foreach ($relType as $k => $v) {
         $roleTypes[substr($k, 0, strpos($k, '_'))] = $v;
     }
     $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes, FALSE, array('class' => 'crm-select2 twenty'));
     $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID);
     if (is_array($hookCaseSummary)) {
         $this->assign('hookCaseSummary', $hookCaseSummary);
     }
     $allTags = CRM_Core_BAO_Tag::getTags('civicrm_case');
     if (!empty($allTags)) {
         $this->add('select', 'case_tag', ts('Tags'), $allTags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2'));
         $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case');
         $this->setDefaults(array('case_tag' => $tags));
         foreach ($tags as $tid) {
             if (isset($allTags[$tid])) {
                 $tags[$tid] = $allTags[$tid];
             } else {
                 unset($tags[$tid]);
             }
         }
         $this->assign('tags', implode(', ', array_filter($tags)));
         $this->assign('showTags', TRUE);
     } else {
         $this->assign('showTags', FALSE);
     }
     // build tagset widget
     // see if we have any tagsets which can be assigned to cases
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
     if ($parentNames) {
         $this->assign('showTagsets', TRUE);
     } else {
         $this->assign('showTagsets', FALSE);
     }
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE);
     $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
 }
Ejemplo n.º 16
0
 /**
  * build form elements.
  * params object $form object of the form
  *
  * @param CRM_Core_Form $form
  *   The form object that we are operating on.
  * @param int $contactId
  *   Contact id.
  * @param int $type
  *   What components are we interested in.
  * @param bool $visibility
  *   Visibility of the field.
  * @param null $isRequired
  * @param string $groupName
  *   If used for building group block.
  * @param string $tagName
  *   If used for building tag block.
  * @param string $fieldName
  *   This is used in batch profile(i.e to build multiple blocks).
  *
  * @param string $groupElementType
  *
  */
 public static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox')
 {
     if (!isset($form->_tagGroup)) {
         $form->_tagGroup = array();
     }
     // NYSS 5670
     if (!$contactId && !empty($form->_contactId)) {
         $contactId = $form->_contactId;
     }
     $type = (int) $type;
     if ($type & self::GROUP) {
         $fName = 'group';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $groupID = isset($form->_grid) ? $form->_grid : NULL;
         if ($groupID && $visibility) {
             $ids = array($groupID => $groupID);
         } else {
             if ($visibility) {
                 $group = CRM_Core_PseudoConstant::allGroup();
             } else {
                 $group = CRM_Core_PseudoConstant::group();
             }
             $ids = $group;
         }
         if ($groupID || !empty($group)) {
             $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
             $attributes['skiplabel'] = TRUE;
             $elements = array();
             $groupsOptions = array();
             foreach ($groups as $id => $group) {
                 // make sure that this group has public visibility
                 if ($visibility && $group['visibility'] == 'User and User Admin Only') {
                     continue;
                 }
                 if ($groupElementType == 'select') {
                     $groupsOptions[$id] = $group['title'];
                 } else {
                     $form->_tagGroup[$fName][$id]['description'] = $group['description'];
                     $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes);
                 }
             }
             if ($groupElementType == 'select' && !empty($groupsOptions)) {
                 $form->add('select', $fName, $groupName, $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2'));
                 $form->assign('groupCount', count($groupsOptions));
             }
             if ($groupElementType == 'checkbox' && !empty($elements)) {
                 $form->addGroup($elements, $fName, $groupName, '&nbsp;<br />');
                 $form->assign('groupCount', count($elements));
                 if ($isRequired) {
                     $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required');
                 }
             }
             $form->assign('groupElementType', $groupElementType);
         }
     }
     if ($type & self::TAG) {
         $fName = 'tag';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $form->_tagGroup[$fName] = 1;
         // get the list of all the categories
         $tags = new CRM_Core_BAO_Tag();
         $tree = $tags->getTree('civicrm_contact', TRUE);
         // let's not load jstree if there are not children. This also fixes blank
         // display at the beginning of checkboxes
         $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
         $form->assign('loadjsTree', FALSE);
         if (!empty($loadJsTree)) {
             // CODE FROM CRM/Tag/Form/Tag.php //
             CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
             $form->assign('loadjsTree', TRUE);
         }
         $elements = array();
         self::climbtree($form, $tree, $elements);
         $form->addGroup($elements, $fName, $tagName, '<br />');
         $form->assign('tagCount', count($elements));
         $form->assign('tree', $tree);
         $form->assign('tag', $tree);
         $form->assign('entityID', $contactId);
         $form->assign('entityTable', 'civicrm_contact');
         if ($isRequired) {
             $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required');
         }
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
     }
     $form->assign('tagGroup', $form->_tagGroup);
 }
Ejemplo n.º 17
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     //this call is for show related cases.
     if ($this->_showRelatedCases) {
         return;
     }
     $allowedRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactID);
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header')->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js', 2, 'html-header')->addVars('relationshipTypes', CRM_Contact_Form_Relationship::getRelationshipTypeMetadata($allowedRelationshipTypes));
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
     $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
     //adding case manager.CRM-4510.
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE);
     $allActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
     $emailActivityType = array_search('Email', $allActTypes);
     $pdfActivityType = array_search('Print PDF Letter', $allActTypes);
     if ($pdfActivityType) {
         $this->assign('exportDoc', CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$pdfActivityType}"));
     }
     // remove Open Case activity type since we're inside an existing case
     if ($openActTypeId = array_search('Open Case', $allActTypes)) {
         unset($aTypes[$openActTypeId]);
     }
     // Only show "link cases" activity if other cases exist.
     $linkActTypeId = array_search('Link Cases', $allActTypes);
     if ($linkActTypeId) {
         $count = civicrm_api3('Case', 'getcount', array('check_permissions' => TRUE, 'id' => array('!=' => $this->_caseID), 'is_deleted' => 0));
         if (!$count) {
             unset($aTypes[$linkActTypeId]);
         }
     }
     if (!$xmlProcessor->getNaturalActivityTypeSort()) {
         asort($aTypes);
     }
     $activityLinks = array('' => ts('Add Activity'));
     foreach ($aTypes as $type => $label) {
         if ($type == $emailActivityType) {
             $url = CRM_Utils_System::url('civicrm/activity/email/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
         } elseif ($type == $pdfActivityType) {
             $url = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=add&context=standalone&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
         } else {
             $url = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype={$type}", FALSE, NULL, FALSE);
         }
         $activityLinks[$url] = $label;
     }
     $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu fa-calendar-check-o twenty'));
     if ($this->_hasAccessToAllCases) {
         $this->add('select', 'report_id', '', array('' => ts('Activity Audit')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu fa-list-alt'));
         $this->add('select', 'timeline_id', '', array('' => ts('Add Timeline')) + $reports, FALSE, array('class' => 'crm-select2 crm-action-menu fa-list-ol'));
     }
     $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement'));
     $this->buildMergeCaseForm();
     //call activity form
     self::activityForm($this, $aTypes);
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
     //save special label because we unset it in the loop
     $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId];
     foreach ($caseRelationships as $key => &$value) {
         if (!empty($managerRoleId)) {
             if ($managerRoleId == $value['relation_type']) {
                 $value['relation'] = $managerLabel;
             }
         }
         //calculate roles that don't have relationships
         if (!empty($caseRoles[$value['relation_type']])) {
             unset($caseRoles[$value['relation_type']]);
         }
     }
     $this->assign('caseRelationships', $caseRelationships);
     //also add client as role. CRM-4438
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID);
     $this->assign('caseRoles', $caseRoles);
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE);
     // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
     // so they don't show up twice.
     $clientRelationships = array();
     foreach ($relClient as $r) {
         if (!array_key_exists($r['id'], $caseRelationships)) {
             $clientRelationships[] = $r;
         }
     }
     $this->assign('clientRelationships', $clientRelationships);
     // Now global contact list that appears on all cases.
     $globalGroupInfo = array();
     CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
     $this->assign('globalGroupInfo', $globalGroupInfo);
     // List relationship types for adding an arbitrary new role to the case
     $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $allowedRelationshipTypes, FALSE, array('class' => 'crm-select2 twenty', 'data-select-params' => '{"allowClear": false}'));
     $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID);
     if (is_array($hookCaseSummary)) {
         $this->assign('hookCaseSummary', $hookCaseSummary);
     }
     CRM_Core_BAO_Tag::getTags('civicrm_case', $allTags, NULL, '&nbsp;&nbsp;', TRUE);
     if (!empty($allTags)) {
         $this->add('select', 'case_tag', ts('Tags'), $allTags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2'));
         $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case');
         $this->setDefaults(array('case_tag' => $tags));
         foreach ($tags as $tid) {
             if (isset($allTags[$tid])) {
                 $tags[$tid] = $allTags[$tid];
             } else {
                 unset($tags[$tid]);
             }
         }
         $this->assign('tags', implode(', ', array_filter($tags)));
         $this->assign('showTags', TRUE);
     } else {
         $this->assign('showTags', FALSE);
     }
     // build tagset widget
     // see if we have any tagsets which can be assigned to cases
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
     $tagSetTags = array();
     if ($parentNames) {
         $this->assign('showTags', TRUE);
         $tagSetItems = civicrm_api3('entityTag', 'get', array('entity_id' => $this->_caseID, 'entity_table' => 'civicrm_case', 'tag_id.parent_id.is_tagset' => 1, 'options' => array('limit' => 0), 'return' => array("tag_id.parent_id", "tag_id.parent_id.name", "tag_id.name")));
         foreach ($tagSetItems['values'] as $tag) {
             $tagSetTags += array($tag['tag_id.parent_id'] => array('name' => $tag['tag_id.parent_id.name'], 'items' => array()));
             $tagSetTags[$tag['tag_id.parent_id']]['items'][] = $tag['tag_id.name'];
         }
     }
     $this->assign('tagSetTags', $tagSetTags);
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE);
     $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
 }
Ejemplo n.º 18
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     //this call is for show related cases.
     if ($this->_showRelatedCases) {
         return;
     }
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
     $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
     //adding case manager.CRM-4510.
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', true);
     require_once 'CRM/Core/PseudoConstant.php';
     $allActTypes = CRM_Core_PseudoConstant::activityType(true, true, false, 'name');
     // remove Open Case activity type since we're inside an existing case
     if (($openActTypeId = array_search('Open Case', $allActTypes)) && array_key_exists($openActTypeId, $aTypes)) {
         unset($aTypes[$openActTypeId]);
     }
     //check for link cases.
     $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(null, array($this->_caseID));
     if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes)) && array_key_exists($linkActTypeId, $aTypes)) {
         unset($aTypes[$linkActTypeId]);
     }
     asort($aTypes);
     $this->add('select', 'activity_type_id', ts('New Activity'), array('' => ts('- select activity type -')) + $aTypes);
     if ($this->_hasAccessToAllCases) {
         $this->add('select', 'report_id', ts('Run QA Audit / Redact'), array('' => ts('- select activity set -')) + $reports);
         $this->add('select', 'timeline_id', ts('Add Timeline'), array('' => ts('- select activity set -')) + $reports);
     }
     $this->addElement('submit', $this->getButtonName('next'), ts('Go'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
     if ($this->_mergeCases) {
         $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID);
         $otherCases = array();
         foreach ($allCases as $caseId => $details) {
             //filter current and own cases.
             if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) {
                 continue;
             }
             $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date'];
         }
         if (empty($otherCases)) {
             $this->_mergeCases = false;
             $this->assign('mergeCases', $this->_mergeCases);
         } else {
             $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases);
             $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
         }
     }
     $this->add('text', 'change_client_id', ts('Assign to another Client'));
     $this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
     $this->addElement('submit', $this->getButtonName('next', 'edit_client'), ts('Reassign Case'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     $this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus);
     // activity dates
     $this->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate'));
     $this->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate'));
     require_once "CRM/Core/Permission.php";
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
     }
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
     //build reporter select
     $reporters = array("" => ts(' - any reporter - '));
     foreach ($caseRelationships as $key => &$value) {
         $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
         if ($managerRoleId == $value['relation_type']) {
             $value['relation'] = $caseRoles[$managerRoleId];
         }
         //calculate roles that don't have relationships
         if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
             unset($caseRoles[$value['relation_type']]);
         }
     }
     // take all case activity types for search filter, CRM-7187
     $aTypesFilter = array();
     $allCaseActTypes = CRM_Case_PseudoConstant::activityType();
     foreach ($allCaseActTypes as $typeDetails) {
         if (!in_array($typeDetails['name'], array('Open Case'))) {
             $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
         }
     }
     asort($aTypesFilter);
     $this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
     $this->assign('caseRelationships', $caseRelationships);
     //also add client as role. CRM-4438
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID);
     $this->assign('caseRoles', $caseRoles);
     $this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, null, null, false);
     // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
     // so they don't show up twice.
     $clientRelationships = array();
     foreach ($relClient as $r) {
         if (!array_key_exists($r['id'], $caseRelationships)) {
             $clientRelationships[] = $r;
         }
     }
     $this->assign('clientRelationships', $clientRelationships);
     // Now global contact list that appears on all cases.
     $globalGroupInfo = array();
     $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
     $this->assign('globalRelationships', $relGlobal);
     $this->assign('globalGroupInfo', $globalGroupInfo);
     // List of relationship types
     require_once 'CRM/Contact/BAO/Relationship.php';
     $baoRel = new CRM_Contact_BAO_Relationship();
     $relType = $baoRel->getRelationType('Individual');
     $roleTypes = array();
     foreach ($relType as $k => $v) {
         $roleTypes[substr($k, 0, strpos($k, '_'))] = $v;
     }
     $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes);
     require_once 'CRM/Utils/Hook.php';
     $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID);
     if (is_array($hookCaseSummary)) {
         $this->assign('hookCaseSummary', $hookCaseSummary);
     }
     require_once 'CRM/Core/BAO/EntityTag.php';
     require_once 'CRM/Core/BAO/Tag.php';
     $allTags = CRM_Core_BAO_Tag::getTags('civicrm_case');
     if (!empty($allTags)) {
         $this->add('select', 'case_tag', ts('Tags'), $allTags, false, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
         $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case');
         $this->setDefaults(array('case_tag' => $tags));
         foreach ($tags as $tid) {
             $tags[$tid] = $allTags[$tid];
         }
         $this->assign('tags', implode(', ', array_filter($tags)));
         $this->assign('showTags', true);
     } else {
         $this->assign('showTags', false);
     }
     // build tagset widget
     require_once 'CRM/Core/Form/Tag.php';
     // see if we have any tagsets which can be assigned to cases
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
     if ($parentNames) {
         $this->assign('showTagsets', true);
     } else {
         $this->assign('showTagsets', false);
     }
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, false, true);
     $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true)));
 }
Ejemplo n.º 19
0
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             $form->add('select', 'group', ts('Groups'), $form->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     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', 'title' => ts('- select -')));
         }
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE);
     }
     // 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', 'source'));
     //added job title
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
     //added internal ID
     $attributes['id']['size'] = 30;
     $form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"');
     //added external ID
     $attributes['external_identifier']['size'] = 30;
     $form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"');
     $config = CRM_Core_Config::singleton();
     if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
         $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?'));
     // 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->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     $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->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
     }
     $form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')));
     // 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);
     // 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', 'title' => ts('- select -')));
     $form->addElement('select', 'privacy_operator', ts('Operator'), array('OR' => ts('OR'), 'AND' => ts('AND')));
     $toggleChoice = array();
     $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Exclude'), '1');
     $toggleChoice[] = $form->createElement('radio', NULL, '', ' ' . ts('Include by Privacy Option(s)'), '2');
     $form->addGroup($toggleChoice, 'privacy_toggle', 'Privacy Options');
     // preferred communication method
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
     }
     $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $langPreff = CRM_Core_PseudoConstant::languages();
     $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
 }
Ejemplo n.º 20
0
 public function buildQuickForm()
 {
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         //enable form element (ActivityLinks sets this true)
         $this->assign('suppressForm', FALSE);
         $button = ts('Delete');
         if ($this->_action & CRM_Core_Action::RENEW) {
             $button = ts('Restore');
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     // Build other activity links.
     CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
     // Enable form element (ActivityLinks sets this true).
     $this->assign('suppressForm', FALSE);
     $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required'));
     // Freeze for update mode.
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $element->freeze();
     }
     // Call to RecurringEntity buildQuickForm for add/update mode.
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         CRM_Core_Form_RecurringEntity::buildQuickForm($this);
     }
     foreach ($this->_fields as $field => $values) {
         if (!empty($this->_fields[$field])) {
             $attribute = CRM_Utils_Array::value('attributes', $values);
             $required = !empty($values['required']);
             if ($values['type'] == 'select' && empty($attribute)) {
                 $this->addSelect($field, array('entity' => 'activity'), $required);
             } elseif ($values['type'] == 'entityRef') {
                 $this->addEntityRef($field, $values['label'], $attribute, $required);
             } else {
                 $this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
             }
         }
     }
     // CRM-7362 --add campaigns.
     CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
     // Add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $this->addSelect('engagement_level', array('entity' => 'activity'));
         $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
     }
     $this->assign('buildEngagementLevel', $buildEngagementLevel);
     // check for survey activity
     $this->_isSurveyActivity = FALSE;
     if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
         if ($this->_isSurveyActivity) {
             $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
             $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
             if ($responseOptions) {
                 $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
             }
             $surveyTitle = NULL;
             if ($surveyId) {
                 $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
             }
             $this->assign('surveyTitle', $surveyTitle);
         }
     }
     $this->assign('surveyActivity', $this->_isSurveyActivity);
     // this option should be available only during add mode
     if ($this->_action != CRM_Core_Action::UPDATE) {
         $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
     }
     $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
     // Add followup date.
     $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
     // Only admins and case-workers can change the activity source
     if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
         $this->getElement('source_contact_id')->freeze();
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Activity');
     $this->assign('customDataSubType', $this->_activityTypeId);
     $this->assign('entityID', $this->_activityId);
     CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, '&nbsp;&nbsp;', TRUE);
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge'));
     }
     // we need to hide activity tagset for special activities
     $specialActivities = array('Open Case');
     if (!in_array($this->_activityTypeName, $specialActivities)) {
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
         CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId);
     }
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
         if (isset($this->_groupTree)) {
             CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
         }
         // form should be frozen for view mode
         $this->freeze();
         $buttons = array();
         $buttons[] = array('type' => 'cancel', 'name' => ts('Done'));
         $this->addButtons($buttons);
     } else {
         $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'));
         $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::buildQuickForm($this);
         $this->addFormRule(array($className, 'formRule'), $this);
     }
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
     if (Civi::settings()->get('activity_assignee_notification')) {
         $this->assign('activityAssigneeNotification', TRUE);
     } else {
         $this->assign('activityAssigneeNotification', FALSE);
     }
 }
Ejemplo n.º 21
0
Archivo: Tag.php Proyecto: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // get categories for the contact id
     $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
     // let's not load jstree if there are not children. This also fixes blank
     // display at the beginning of checkboxes
     $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
     $this->assign('loadjsTree', FALSE);
     if (!empty($loadJsTree)) {
         CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
         $this->assign('loadjsTree', TRUE);
     }
     $this->assign('tree', $tree);
     $this->assign('tag', $allTag);
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
 }
Ejemplo n.º 22
0
 static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE)
 {
     if (!$numAttachments) {
         $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
     }
     // Assign maxAttachments count to template for help message
     $form->assign('maxAttachments', $numAttachments);
     $config = CRM_Core_Config::singleton();
     // set default max file size as 2MB
     $maxFileSize = $config->maxFileSize ? $config->maxFileSize : 2;
     $currentAttachmentInfo = self::getEntityFile($entityTable, $entityID, TRUE);
     $totalAttachments = 0;
     if ($currentAttachmentInfo) {
         $totalAttachments = count($currentAttachmentInfo);
         $form->add('checkbox', 'is_delete_attachment', ts('Delete All Attachment(s)'));
         $form->assign('currentAttachmentInfo', $currentAttachmentInfo);
     } else {
         $form->assign('currentAttachmentInfo', NULL);
     }
     if ($totalAttachments) {
         if ($totalAttachments >= $numAttachments) {
             $numAttachments = 0;
         } else {
             $numAttachments -= $totalAttachments;
         }
     }
     $form->assign('numAttachments', $numAttachments);
     $tags = CRM_Core_BAO_Tag::getTags('civicrm_file');
     // get tagset info
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_file');
     // add attachments
     for ($i = 1; $i <= $numAttachments; $i++) {
         $form->addElement('file', "attachFile_{$i}", ts('Attach File'), 'size=30 maxlength=60');
         $form->addUploadElement("attachFile_{$i}");
         $form->setMaxFileSize($maxFileSize * 1024 * 1024);
         $form->addRule("attachFile_{$i}", ts('File size should be less than %1 MByte(s)', array(1 => $maxFileSize)), 'maxfilesize', $maxFileSize * 1024 * 1024);
         $form->addElement('text', "attachDesc_{$i}", ts('Description'), 'size=40 maxlength=255');
         if (!empty($tags)) {
             $form->add('select', "tag_{$i}", ts('Tags'), $tags, FALSE, array('id' => "tags_{$i}", 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     // build tagset widget
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, TRUE, TRUE, FALSE);
 }
Ejemplo n.º 23
0
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         require_once 'CRM/Contact/BAO/ContactType.php';
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         if ($contactTypes) {
             $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, false, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['groups']) {
         // multiselect for groups
         if ($form->_group) {
             $form->add('select', 'group', ts('Groups'), $form->_group, false, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
     }
     if ($form->_searchOptions['tags']) {
         // multiselect for categories
         require_once 'CRM/Core/BAO/Tag.php';
         $contactTags = CRM_Core_BAO_Tag::getTags();
         if ($contactTags) {
             $form->add('select', 'contact_tags', ts('Tags'), $contactTags, false, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
         }
         require_once 'CRM/Core/Form/Tag.php';
         require_once 'CRM/Core/BAO/Tag.php';
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', null, true);
     }
     // 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', 'source'));
     //added job title
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
     $config =& CRM_Core_Config::singleton();
     if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
         $form->add('checkbox', 'deleted_contacts', ts('Search in Trash (deleted contacts)'));
     }
     // add checkbox for cms users only
     $form->addYesNo('uf_user', ts('CMS User?'));
     // add search profiles
     require_once 'CRM/Core/BAO/UFGroup.php';
     // 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->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     require_once 'CRM/Contact/Form/Search.php';
     $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::check('view all activities')) {
         unset($componentModes['4']);
     }
     if (count($componentModes) > 1) {
         $form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
     }
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
     $form->addGroup($privacy, 'privacy', ts('Privacy'), array('&nbsp;', '&nbsp;', '&nbsp;', '<br/>'));
     // preferred communication method
     require_once 'CRM/Core/PseudoConstant.php';
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
     }
     $onHold[] = HTML_QuickForm::createElement('advcheckbox', 'on_hold', null, ts(''));
     $form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
     //CRM-6138 Preferred Language
     $langPreff = CRM_Core_PseudoConstant::languages();
     $form->add('select', 'preferred_language', ts('Preferred Language'), array('' => ts('- select language -')) + $langPreff);
 }