/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { $this->_grantIds = array(); $values = $this->controller->exportValues('Search'); $this->_task = $values['task']; $grantTasks = CRM_Grant_Task::tasks(); $this->assign('taskName', $grantTasks[$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_GRANT); $result = $query->searchQuery(0, 0, null); while ($result->fetch()) { $ids[] = $result->grant_id; } } if (!empty($ids)) { $this->_grantClause = ' civicrm_grant.id IN ( ' . implode(',', $ids) . ' ) '; $this->assign('totalSelectedGrants', count($ids)); } $this->_grantIds = $this->_componentIds = $ids; //set the context for redirection for any task actions $session =& CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/search', 'force=1')); }
/** * 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) { if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) { self::$_tasks = array(1 => ts('Delete Grants')); } } return self::$_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 * * @param string $formName * * @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_Grant_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 Grants'), 3 => ts('Export Grants')); } if (!CRM_Core_Permission::check('delete in CiviGrant')) { unset(self::$_tasks[1]); } 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 Grants'), 'class' => 'CRM_Grant_Form_Task_Delete', 'result' => FALSE), 2 => array('title' => ts('Print Grants'), 'class' => 'CRM_Grant_Form_Task_Print', 'result' => FALSE), 3 => array('title' => ts('Export Grants'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 4 => array('title' => ts('Update Grants'), 'class' => 'CRM_Grant_Form_Task_Update', 'result' => FALSE)); } if (!CRM_Core_Permission::check('delete in CiviGrant')) { unset(self::$_tasks[1]); } CRM_Utils_Hook::searchTasks('grant', self::$_tasks); asort(self::$_tasks); return self::$_tasks; }
/** * @param CRM_Core_Form $form * @param bool $useTable */ public static function preProcessCommon(&$form, $useTable = FALSE) { $form->_grantIds = array(); $values = $form->controller->exportValues('Search'); $form->_task = $values['task']; $grantTasks = CRM_Grant_Task::tasks(); $form->assign('taskName', $grantTasks[$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'); $sortOrder = NULL; if ($form->get(CRM_Utils_Sort::SORT_ORDER)) { $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER); } $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_GRANT); $query->_distinctComponentClause = ' civicrm_grant.id'; $query->_groupByComponentClause = ' GROUP BY civicrm_grant.id '; $result = $query->searchQuery(0, 0, $sortOrder); while ($result->fetch()) { $ids[] = $result->grant_id; } } if (!empty($ids)) { $form->_componentClause = ' civicrm_grant.id IN ( ' . implode(',', $ids) . ' ) '; $form->assign('totalSelectedGrants', count($ids)); } $form->_grantIds = $form->_componentIds = $ids; //set the context for redirection for any task actions $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $session = CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/search', $urlParams)); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); require_once 'CRM/Grant/BAO/Query.php'; CRM_Grant_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('onchange' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);")); foreach ($rows as $row) { $this->addElement('checkbox', CRM_Utils_Array::value('checkbox', $row), null, null, array('onclick' => " toggleTaskAction( true ); return checkSelectedBox('" . CRM_Utils_Array::value('checkbox', $row) . "', '" . $this->getName() . "');")); $grant_id = $row['grant_id']; } } $total = $cancel = 0; require_once "CRM/Core/Permission.php"; $permission = CRM_Core_Permission::getPermission(); require_once 'CRM/Grant/Task.php'; $tasks = array('' => ts('- more 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->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('onchange' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true))); }
/** * 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_Grant_Task::PRINT_GRANTS; } else { $value = CRM_Utils_Array::value('task', $_POST); } if (!isset($value)) { $value = $this->_controller->get('task'); } $this->_controller->set('task', $value); return CRM_Grant_Task::getTask($value); }
/** * Build the form object. * * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); $this->addSortNameField(); CRM_Grant_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_Grant_Task::permissionedTaskTitles($permission)); } }
/** * Build the form object. * * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Name or Email'), array('class' => 'twenty') + CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Grant_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_Grant_Task::permissionedTaskTitles($permission)); } }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Grant_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('onchange' => "toggleTaskAction( true );", 'class' => 'select-rows')); foreach ($rows as $row) { $this->addElement('checkbox', CRM_Utils_Array::value('checkbox', $row), NULL, NULL, array('onclick' => " toggleTaskAction( true );", 'class' => 'select-row')); $grant_id = $row['grant_id']; } } $total = $cancel = 0; $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);")); // 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', 'onchange' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE))); }