/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { $this->_caseIds = array(); $values = $this->controller->exportValues('Search'); $this->_task = $values['task']; $caseTasks = CRM_Case_Task::tasks(); $this->assign('taskName', $caseTasks[$this->_task]); $ids = array(); if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } else { $queryParams = $this->get('queryParams'); $query =& new CRM_Contact_BAO_Query($queryParams, null, null, false, false, CRM_Contact_BAO_Query::MODE_CASE); $result = $query->searchQuery(0, 0, null); while ($result->fetch()) { $ids[] = $result->case_id; } } if (!empty($ids)) { $this->_componentClause = ' civicrm_case.id IN ( ' . implode(',', $ids) . ' ) '; $this->assign('totalSelectedCases', count($ids)); } $this->_caseIds = $this->_componentIds = $ids; //set the context for redirection for any task actions $session =& CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/case/search', 'force=1')); }
/** * Determine the form name based on the action. This allows us * to avoid using conditional state machine, much more efficient * and simpler * * @param CRM_Core_Controller $controller the controller object * * @return string the name of the form that will handle the task * @access protected */ function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff $value = CRM_Utils_Array::value('task', $_POST); if (!isset($value)) { $value = $this->_controller->get('task'); } $this->_controller->set('task', $value); return CRM_Case_Task::getTask($value); }
/** * These tasks are the core set of tasks that the user can perform * on a contact / group of contacts * * @return array the set of tasks for a group of contacts * @static * @access public */ static function &tasks() { if (!self::$_tasks) { self::$_tasks = array(1 => ts('Delete Cases'), 3 => ts('Export Cases'), 4 => ts('Restore Cases')); //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviCase')) { unset(self::$_tasks[1]); } } asort(self::$_tasks); return self::$_tasks; }
/** * These tasks are the core set of tasks that the user can perform * on a contact / group of contacts * * @return array the set of tasks for a group of contacts * @static * @access public */ static function &tasks() { if (!self::$_tasks) { self::$_tasks = array(1 => array('title' => ts('Delete Cases'), 'class' => 'CRM_Case_Form_Task_Delete', 'result' => FALSE), 2 => array('title' => ts('Print Selected Rows'), 'class' => 'CRM_Case_Form_Task_Print', 'result' => FALSE), 3 => array('title' => ts('Export Cases'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 4 => array('title' => ts('Restore Cases'), 'class' => 'CRM_Case_Form_Task_Restore', 'result' => FALSE)); //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviCase')) { unset(self::$_tasks[1]); } } CRM_Utils_Hook::searchTasks('case', self::$_tasks); asort(self::$_tasks); return self::$_tasks; }
static function preProcessCommon(&$form, $useTable = FALSE) { $form->_caseIds = array(); $values = $form->controller->exportValues($form->get('searchFormName')); $form->_task = $values['task']; $caseTasks = CRM_Case_Task::tasks(); $form->assign('taskName', $caseTasks[$form->_task]); $ids = array(); if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } else { $queryParams = $form->get('queryParams'); $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CASE); $query->_distinctComponentClause = " ( civicrm_case.id )"; $query->_groupByComponentClause = " GROUP BY civicrm_case.id "; $result = $query->searchQuery(0, 0, NULL); while ($result->fetch()) { $ids[] = $result->case_id; } } if (!empty($ids)) { $form->_componentClause = ' civicrm_case.id IN ( ' . implode(',', $ids) . ' ) '; $form->assign('totalSelectedCases', count($ids)); } $form->_caseIds = $form->_componentIds = $ids; //set the context for redirection for any task actions $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $session = CRM_Core_Session::singleton(); $searchFormName = strtolower($form->get('searchFormName')); if ($searchFormName == 'search') { $session->replaceUserContext(CRM_Utils_System::url('civicrm/case/search', $urlParams)); } else { $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams)); } }
/** * 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); } }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { $this->addElement('text', 'sort_name', ts('Client Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); require_once 'CRM/Case/BAO/Query.php'; CRM_Case_BAO_Query::buildSearchForm($this); /* * add form checkboxes for each row. This is needed out here to conform to QF protocol * of all elements being declared in builQuickForm */ $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);")); foreach ($rows as $row) { $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');")); } } $total = $cancel = 0; require_once "CRM/Core/Permission.php"; $permission = CRM_Core_Permission::getPermission(); require_once 'CRM/Case/Task.php'; $tasks = array('' => ts('- more actions -')) + CRM_Case_Task::permissionedTaskTitles($permission); if (CRM_Utils_Array::value('case_deleted', $this->_formValues)) { unset($tasks[1]); } else { 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->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);")); // 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('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true))); }
/** * 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); } }
/** * Determine the form name based on the action. This allows us * to avoid using conditional state machine, much more efficient * and simpler * * @param CRM_Core_Controller $controller the controller object * * @return string the name of the form that will handle the task * @access protected */ function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff // fix value if print button is pressed if (CRM_Utils_Array::value('_qf_' . $formName . '_next_print', $_POST)) { $value = CRM_Case_Task::PRINT_CASES; } else { $value = CRM_Utils_Array::value('task', $_POST); } if (!isset($value)) { $value = $this->_controller->get('task'); } $this->_controller->set('task', $value); return CRM_Case_Task::getTask($value); }
/** * Build the form * * @access public * * @return void */ function 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); /* * add form checkboxes for each row. This is needed out here to conform to QF protocol * of all elements being declared in builQuickForm */ $rows = $this->get('rows'); if (is_array($rows)) { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js'); if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row')); } } $total = $cancel = 0; $permission = CRM_Core_Permission::getPermission(); $tasks = array('' => ts('- actions -')) + CRM_Case_Task::permissionedTaskTitles($permission); if (!empty($this->_formValues['case_deleted'])) { unset($tasks[1]); } else { 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);")); // 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 );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE))); }