/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { $this->_contributionIds = array(); $values = $this->controller->exportValues('Search'); $this->_task = $values['task']; $contributeTasks = CRM_Contribute_Task::tasks(); $this->assign('taskName', $contributeTasks[$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_CONTRIBUTE); $result = $query->searchQuery(0, 0, null); while ($result->fetch()) { $ids[] = $result->contribution_id; } $this->assign('totalSelectedContributions', $this->get('rowCount')); } if (!empty($ids)) { $this->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) '; $this->assign('totalSelectedContributions', count($ids)); } $this->_contributionIds = $this->_componentIds = $ids; //set the context for redirection for any task actions $session =& CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/search', 'force=1')); }
/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { $this->_contributionIds = array(); $values = $this->controller->exportValues('Search'); $this->_task = $values['task']; $contributeTasks = CRM_Contribute_Task::tasks(); $this->assign('taskName', $contributeTasks[$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); } } if (!empty($ids)) { $this->_contributionClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) '; $this->assign('totalSelectedContributions', count($ids)); } } else { $fv = $this->get('formValues'); $query =& new CRM_Contact_BAO_Query($fv, null, null, false, false, CRM_CONTACT_BAO_QUERY_MODE_CONTRIBUTE); $result = $query->searchQuery(0, 0, null); while ($result->fetch()) { $ids[] = $result->contribution_id; } $this->assign('totalSelectedContributions', $this->get('rowCount')); } $this->_contributionIds = $ids; }
static function preProcessCommon(&$form, $useTable = false) { $form->_contributionIds = array(); $values = $form->controller->exportValues($form->get('searchFormName')); $form->_task = $values['task']; $contributeTasks = CRM_Contribute_Task::tasks(); $form->assign('taskName', $contributeTasks[$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_CONTRIBUTE); $result = $query->searchQuery(0, 0, null); while ($result->fetch()) { $ids[] = $result->contribution_id; } $form->assign('totalSelectedContributions', $form->get('rowCount')); } if (!empty($ids)) { $form->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) '; $form->assign('totalSelectedContributions', count($ids)); } $form->_contributionIds = $form->_componentIds = $ids; //set the context for redirection for any task actions $session = CRM_Core_Session::singleton(); $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); require_once 'CRM/Utils/Rule.php'; $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $searchFormName = strtolower($form->get('searchFormName')); if ($searchFormName == 'search') { $session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/search', $urlParams)); } else { $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams)); } }
/** * @param CRM_Core_Form $form * @param bool $useTable */ public static function preProcessCommon(&$form, $useTable = FALSE) { $form->_contributionIds = array(); $values = $form->controller->exportValues($form->get('searchFormName')); $form->_task = $values['task']; $contributeTasks = CRM_Contribute_Task::tasks(); $form->assign('taskName', $contributeTasks[$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); } $form->_includesSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams); $query = new CRM_Contact_BAO_Query($queryParams, array('contribution_id'), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE); // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this // can we remove? if not why not? if ($form->_includesSoftCredits) { $contactIds = $contributionContactIds = array(); $query->_rowCountClause = " count(civicrm_contribution.id)"; $query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id "; } else { $query->_distinctComponentClause = ' civicrm_contribution.id'; $query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id '; } $result = $query->searchQuery(0, 0, $sortOrder); while ($result->fetch()) { $ids[] = $result->contribution_id; if ($form->_includesSoftCredits) { $contactIds[$result->contact_id] = $result->contact_id; $contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id; } } $result->free(); $form->assign('totalSelectedContributions', $form->get('rowCount')); } if (!empty($ids)) { $form->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) '; $form->assign('totalSelectedContributions', count($ids)); } if (!empty($form->_includesSoftCredits) && !empty($contactIds)) { $form->_contactIds = $contactIds; $form->_contributionContactIds = $contributionContactIds; } $form->_contributionIds = $form->_componentIds = $ids; //set the context for redirection for any task actions $session = CRM_Core_Session::singleton(); $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $searchFormName = strtolower($form->get('searchFormName')); if ($searchFormName == 'search') { $session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/search', $urlParams)); } else { $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams)); } }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // text for sort_name $this->addElement('text', 'sort_name', ts('Contributor'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Contribute_Form_Search::buildQuickFormCommon($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)) { $this->addElement('checkbox', 'toggleSelect', null, null, array('onChange' => "return toggleCheckboxVals('mark_x_',this.form);")); $total = $cancel = 0; foreach ($rows as $row) { $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');")); if ($row['cancel_date']) { $cancel += $row['total_amount']; } else { $total += $row['total_amount']; } } $this->assign('total_amount', $total); $this->assign('cancel_amount', $cancel); $this->assign('num_amount', count($rows)); $this->assign('single', $this->_single); // also add the action and radio boxes require_once 'CRM/Contribute/Task.php'; $tasks = array('' => ts('- more actions -')) + CRM_Contribute_Task::tasks(); $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' => null)); $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onchange' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_'," . $this->getName() . "); return false;")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true))); }