$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -')) + CRM_Activity_Task::permissionedTaskTitles($permission);
-
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -')) + CRM_Case_Task::permissionedTaskTitles($permission);
+ $tasks = CRM_Case_Task::permissionedTaskTitles($permission);
if (!empty($this->_formValues['case_deleted'])) {
unset($tasks[1]);
unset($tasks[4]);
}
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu($tasks);
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
- $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
+ $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows'));
}
}
->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('' => ts('- actions -'));
+ $tasks = array();
if ($this->_componentMode == 1 || $this->_componentMode == 7) {
$tasks += CRM_Contact_Task::permissionedTaskTitles($permission,
CRM_Utils_Array::value('deleted_contacts', $this->_formValues)
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
}
else {
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);",
- )
- );
+ $this->addTaskMenu($tasks);
}
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
if (!empty($queryParams)) {
$softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
}
- $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
+ $this->addTaskMenu($tasks);
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
*/
class CRM_Core_Form_Search extends CRM_Core_Form {
+ /**
+ * Common buildform tasks required by all searches
+ */
function buildQuickform() {
$resources = CRM_Core_Resources::singleton();
),
));
}
+
+ /**
+ * Add actions menu to search results form
+ * @param $tasks
+ */
+ function addTaskMenu($tasks) {
+ if (is_array($tasks) && !empty($tasks)) {
+ $tasks = array('' => ts('Actions')) + $tasks;
+ $this->add('select', 'task', NULL, $tasks, FALSE, array('class' => 'crm-select2 crm-action-menu huge crm-search-result-actions'));
+ $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'hiddenElement crm-search-go-button'));
+ }
+ }
}
$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
+ $tasks = CRM_Event_Task::permissionedTaskTitles($permission);
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
$tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
$this->assign('ssID', $this->_ssID);
}
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu($tasks);
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel',
$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -'));
- $permissionedTask = CRM_Grant_Task::permissionedTaskTitles($permission);
- if (is_array($permissionedTask) && !CRM_Utils_System::isNull($permissionedTask)) {
- $tasks += $permissionedTask;
- }
-
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu(CRM_Grant_Task::permissionedTaskTitles($permission));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -')) + CRM_Member_Task::permissionedTaskTitles($permission);
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
$permission = CRM_Core_Permission::getPermission();
- $tasks = array('' => ts('- actions -')) + CRM_Pledge_Task::permissionedTaskTitles($permission);
-
- $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
- $this->add('submit', $this->_actionButtonName, ts('Go'),
- array(
- 'class' => 'form-submit',
- 'id' => 'Go',
- 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);",
- )
- );
+ $this->addTaskMenu(CRM_Pledge_Task::permissionedTaskTitles($permission));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
return fieldCount;
}
-/**
- * This function is used to check if any action is selected and also to check if any contacts are checked.
- *
- * @access public
- * @param fldPrefix - common string which precedes unique checkbox ID and identifies field as
- * belonging to the resultset's checkbox collection
- * @param form - name of form that checkboxes are part of
- * Sample usage: onClick="javascript:checkPerformAction('chk_', myForm );"
- *
- */
-function checkPerformAction(fldPrefix, form, taskButton, selection) {
- var cnt;
- var gotTask = 0;
-
- // taskButton TRUE means we don't need to check the 'task' field - it's a button-driven task
- if (taskButton == 1) {
- gotTask = 1;
- }
- else {
- if (document.forms[form].task.selectedIndex) {
- //force user to select all search contacts, CRM-3711
- if (document.forms[form].task.value == 13 || document.forms[form].task.value == 14) {
- var toggleSelect = document.getElementsByName('toggleSelect');
- if (toggleSelect[0].checked || document.forms[form].radio_ts[0].checked) {
- return true;
- }
- else {
- alert("Please select all contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button.");
- return false;
- }
- }
- gotTask = 1;
- }
- }
-
- if (gotTask == 1) {
- // If user wants to perform action on ALL records and we have a task, return (no need to check further)
- if (document.forms[form].radio_ts[0].checked) {
- return true;
- }
-
- cnt = (selection == 1) ? countSelections() : countSelectedCheckboxes(fldPrefix, document.forms[form]);
- if (!cnt) {
- alert("Please select one or more contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button.");
- return false;
- }
- }
- else {
- alert("Please select an action from the drop-down menu.");
- return false;
- }
-}
-
/**
* Function to enable task action select
*/