Ejemplo n.º 1
0
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Member_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission));
     }
 }
Ejemplo n.º 2
0
 /**
  * Build the common elements between the search/advanced form.
  */
 public function buildQuickForm()
 {
     parent::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');
     $permission = CRM_Core_Permission::getPermission();
     // some tasks.. what do we want to do with the selected contacts ?
     $tasks = array();
     if ($this->_componentMode == 1 || $this->_componentMode == 7) {
         $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
     } else {
         $className = $this->_modeValue['taskClassName'];
         $tasks += $className::permissionedTaskTitles($permission, FALSE);
     }
     if (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         // CRM-11788, we might want to do this for all of search where force=1
         $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
         $getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
         $postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
         if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
             $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
             CRM_Utils_System::redirect($url);
         }
         $permissionForGroup = FALSE;
         if (!empty($this->_groupID)) {
             // check if user has permission to edit members of this group
             $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID);
             if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
                 $permissionForGroup = TRUE;
             }
             // check if _groupID exists, it might not if
             // we are displaying a hidden group
             if (!isset($this->_group[$this->_groupID])) {
                 $this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
             }
             // set the group title
             $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
             $this->assign_by_ref('group', $groupValues);
             // also set ssID if this is a saved search
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
             $this->assign('ssID', $ssID);
             //get the saved search mapping id
             if ($ssID) {
                 $this->_ssID = $ssID;
                 $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
                 $this->assign('ssMappingID', $ssMappingId);
             }
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         $this->assign('permissionedForGroup', $permissionForGroup);
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // check if _groupID exists, it might not if
         // we are displaying a hidden group
         if (!isset($this->_group[$this->_amtgID])) {
             $this->assign('permissionedForGroup', FALSE);
             $this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
         }
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $this->assign_by_ref('group', $groupValues);
         $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'crm-form-submit'));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
         $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
         $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
         $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
     }
     $selectedContactIds = array();
     $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
     // We use ajax to handle selections only if the search results component_mode is set to "contacts"
     if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) {
         $this->addClass('crm-ajax-selection-form');
         $qfKeyParam = "civicrm search {$qfKeyParam}";
         $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $this->addRowSelectors($rows);
     }
 }
Ejemplo n.º 3
0
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Client Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Case_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Case_Task::permissionedTaskTitles($permission);
         if (!empty($this->_formValues['case_deleted'])) {
             unset($tasks[1]);
         } else {
             unset($tasks[4]);
         }
         $this->addTaskMenu($tasks);
     }
 }
Ejemplo n.º 4
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     CRM_Case_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Case_Task::permissionedTaskTitles($permission);
         if (!empty($this->_formValues['case_deleted'])) {
             unset($tasks[1]);
         } else {
             unset($tasks[4]);
         }
         $this->addTaskMenu($tasks);
     }
 }
Ejemplo n.º 5
0
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     if (CRM_Core_Permission::check('access deleted contacts') and Civi::settings()->get('contact_undelete')) {
         $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
     }
     CRM_Event_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $lineItems = $eventIds = array();
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         foreach ($rows as $row) {
             $eventIds[$row['event_id']] = $row['event_id'];
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         //get actual count only when we are dealing w/ single event.
         $participantCount = 0;
         if (count($eventIds) == 1) {
             //convert form values to clause.
             $seatClause = array();
             if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') {
                 $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )";
             }
             if (!empty($this->_formValues['participant_status_id'])) {
                 $seatClause[] = CRM_Contact_BAO_Query::buildClause("participant.status_id", '=', $this->_formValues['participant_status_id'], 'Int');
                 if ($status = CRM_Utils_Array::value('IN', $this->_formValues['participant_status_id'])) {
                     $this->_formValues['participant_status_id'] = $status;
                 }
             }
             if (!empty($this->_formValues['participant_role_id'])) {
                 $escapedRoles = array();
                 foreach ((array) $this->_formValues['participant_role_id'] as $participantRole) {
                     $escapedRoles[] = CRM_Utils_Type::escape($participantRole, 'String');
                 }
                 $seatClause[] = "( participant.role_id IN ( '" . implode("' , '", $escapedRoles) . "' ) )";
             }
             // CRM-15379
             if (!empty($this->_formValues['participant_fee_id'])) {
                 $participant_fee_id = $this->_formValues['participant_fee_id'];
                 foreach ($participant_fee_id as $k => &$val) {
                     $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
                     $val = CRM_Core_DAO::escapeString(trim($val));
                 }
                 $feeLabel = implode('|', $participant_fee_id);
                 $seatClause[] = "( participant.fee_level REGEXP '{$feeLabel}' )";
             }
             $seatClause = implode(' AND ', $seatClause);
             $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause);
         }
         $this->assign('participantCount', $participantCount);
         $this->assign('lineItems', $lineItems);
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->addTaskMenu($tasks);
     }
 }
Ejemplo n.º 6
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     // text for sort_name
     $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $this->_group = CRM_Core_PseudoConstant::nestedGroup();
     // multiselect for groups
     if ($this->_group) {
         $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     }
     // multiselect for tags
     $contactTags = CRM_Core_BAO_Tag::getTags();
     if ($contactTags) {
         $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     }
     CRM_Contribute_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $queryParams = $this->get('queryParams');
         $softCreditFiltering = FALSE;
         if (!empty($queryParams)) {
             $softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
         }
         $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
         $this->addTaskMenu($tasks);
     }
 }
Ejemplo n.º 7
0
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Event_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $lineItems = $eventIds = array();
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         foreach ($rows as $row) {
             $eventIds[$row['event_id']] = $row['event_id'];
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         //get actual count only when we are dealing w/ single event.
         $participantCount = 0;
         if (count($eventIds) == 1) {
             //convert form values to clause.
             $seatClause = array();
             if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') {
                 $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )";
             }
             if (!empty($this->_formValues['participant_status_id'])) {
                 $seatClause[] = CRM_Contact_BAO_Query::buildClause("participant.status_id", '=', $this->_formValues['participant_status_id'], 'Int');
                 if ($status = CRM_Utils_Array::value('IN', $this->_formValues['participant_status_id'])) {
                     $this->_formValues['participant_status_id'] = $status;
                 }
             }
             if (!empty($this->_formValues['participant_role_id'])) {
                 $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', (array) $this->_formValues['participant_role_id']) . ' ) )';
             }
             // CRM-15379
             if (!empty($this->_formValues['participant_fee_id'])) {
                 $participant_fee_id = $this->_formValues['participant_fee_id'];
                 $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $participant_fee_id, 'label');
                 $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
                 $seatClause[] = "( participant.fee_level LIKE '%{$feeLabel}%' )";
             }
             $seatClause = implode(' AND ', $seatClause);
             $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause);
         }
         $this->assign('participantCount', $participantCount);
         $this->assign('lineItems', $lineItems);
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->addTaskMenu($tasks);
     }
 }
Ejemplo n.º 8
0
 /**
  * Builds the list of tasks or actions that a searcher can perform on a result set.
  *
  * The returned array completely replaces the task list, so a child class that
  * wants to modify the existing list should manipulate the result of this method.
  *
  * @param CRM_Core_Form_Search $form
  * @return array
  */
 function buildTaskList(CRM_Core_Form_Search $form)
 {
     return $form->getVar('_taskList');
 }
Ejemplo n.º 9
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     CRM_Pledge_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Pledge_Task::permissionedTaskTitles($permission));
     }
 }
Ejemplo n.º 10
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     //build the search form.
     CRM_Campaign_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission);
         //hack to serve right page to state machine.
         $taskMapping = array('interview' => 1, 'reserve' => 2, 'release' => 3);
         $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping);
         $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]);
         if ($this->_operation == 'interview' && !empty($this->_formValues['campaign_survey_id'])) {
             $activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
             $surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'activity_type_id');
             $taskValue = array($currentTaskValue => ts('Record %1 Responses', array(1 => $activityTypes[$surveyTypeId])));
         }
         $this->addTaskMenu($taskValue);
     }
 }
 /**
  * @return string
  */
 public function getTemplateFileName()
 {
     if (!$this->_searchPane) {
         return parent::getTemplateFileName();
     } else {
         if (isset($this->_paneTemplatePath[$this->_searchPane])) {
             return $this->_paneTemplatePath[$this->_searchPane];
         } else {
             $name = ucfirst($this->_searchPane);
             return "CRM/Relationship/Form/Search/Criteria/{$name}.tpl";
         }
     }
 }