Exemple #1
0
 /** 
  * returns the column headers as an array of tuples: 
  * (name, sortName (key to the sort array)) 
  * 
  * @param string $action the action being performed 
  * @param enum   $output what should the result set include (web/email/csv) 
  * 
  * @return array the column headers that need to be displayed 
  * @access public 
  */
 public function &getColumnHeaders($action = null, $output = null)
 {
     if (!isset(self::$_columnHeaders)) {
         self::$_columnHeaders = array(array('name' => ts('Amount'), 'sort' => 'total_amount', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Type'), 'sort' => 'contribution_type_id', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Source'), 'sort' => 'contribution_source', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Received'), 'sort' => 'receive_date', 'direction' => CRM_Utils_Sort::DESCENDING), array('name' => ts('Thank-you Sent'), 'sort' => 'thankyou_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Status'), 'sort' => 'contribution_status_id', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Premium'), 'sort' => 'product_name', 'direction' => CRM_Utils_Sort::DONTCARE), array('desc' => ts('Actions')));
         if (!$this->_single) {
             $pre = array(array('desc' => ts('Contact Type')), array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE));
             self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
         }
     }
     return self::$_columnHeaders;
 }
Exemple #2
0
 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post processing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submission is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  */
 public function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     if (!empty($_POST)) {
         $this->_formValues = $this->controller->exportValues($this->_name);
     }
     $this->fixFormValues();
     // We don't show test records in summaries or dashboards
     if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context == 'dashboard') {
         $this->_formValues["contribution_test"] = 0;
     }
     foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) {
         if (isset($this->_formValues[$f])) {
             $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
         }
     }
     $config = CRM_Core_Config::singleton();
     if (!empty($_POST)) {
         $specialParams = array('financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status_id', 'contribution_source', 'contribution_trxn_id', 'contribution_page_id', 'contribution_product_id');
         foreach ($specialParams as $element) {
             $value = CRM_Utils_Array::value($element, $this->_formValues);
             if ($value) {
                 if (is_array($value)) {
                     $this->_formValues[$element] = array('IN' => $value);
                 } else {
                     $this->_formValues[$element] = array('LIKE' => "%{$value}%");
                 }
             }
         }
         $tags = CRM_Utils_Array::value('contact_tags', $this->_formValues);
         if ($tags && !is_array($tags)) {
             unset($this->_formValues['contact_tags']);
             $this->_formValues['contact_tags'][$tags] = 1;
         }
         if ($tags && is_array($tags)) {
             unset($this->_formValues['contact_tags']);
             foreach ($tags as $notImportant => $tagID) {
                 $this->_formValues['contact_tags'][$tagID] = 1;
             }
         }
         if (!$config->groupTree) {
             $group = CRM_Utils_Array::value('group', $this->_formValues);
             if ($group && !is_array($group)) {
                 unset($this->_formValues['group']);
                 $this->_formValues['group'][$group] = 1;
             }
             if ($group && is_array($group)) {
                 unset($this->_formValues['group']);
                 foreach ($group as $notImportant => $groupID) {
                     $this->_formValues['group'][$groupID] = 1;
                 }
             }
         }
     }
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine = $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Contribute_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = NULL;
     if ($this->_context == 'basic' || $this->_context == 'user') {
         $prefix = $this->_prefix;
     }
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(TRUE);
     $query =& $selector->getQuery();
     if ($this->_context == 'user') {
         $query->setSkipPermission(TRUE);
     }
     $summary =& $query->summaryContribution($this->_context);
     $this->set('summary', $summary);
     $this->assign('contributionSummary', $summary);
     $controller->run();
 }
 /**
  * The post processing of the form gets done here.
  *
  * Key things done during post processing are
  *      - check for reset or next request. if present, skip post procesing.
  *      - now check if user requested running a saved search, if so, then
  *        the form values associated with the saved search are used for searching.
  *      - if user has done a submit with new values the regular post submissing is
  *        done.
  * The processing consists of using a Selector / Controller framework for getting the
  * search results.
  *
  * @param
  *
  * @return void
  * @access public
  */
 function postProcess()
 {
     if ($this->_done) {
         return;
     }
     $this->_done = TRUE;
     if (!empty($_POST)) {
         $this->_formValues = $this->controller->exportValues($this->_name);
     }
     $this->fixFormValues();
     // we don't show test contributions in Contact Summary / User Dashboard
     // in Search mode by default we hide test contributions
     if (!CRM_Utils_Array::value('contribution_test', $this->_formValues)) {
         $this->_formValues["contribution_test"] = 0;
     }
     foreach (array('contribution_amount_low', 'contribution_amount_high') as $f) {
         if (isset($this->_formValues[$f])) {
             $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
         }
     }
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) {
         // check actionName and if next, then do not repeat a search, since we are going to the next page
         // hack, make sure we reset the task values
         $stateMachine =& $this->controller->getStateMachine();
         $formName = $stateMachine->getTaskFormName();
         $this->controller->resetPage($formName);
         return;
     }
     $sortID = NULL;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Contribute_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
     $selector->setKey($this->controller->_key);
     $prefix = NULL;
     if ($this->_context == 'basic' || $this->_context == 'user') {
         $prefix = $this->_prefix;
     }
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SESSION, $prefix);
     $controller->setEmbedded(TRUE);
     $query =& $selector->getQuery();
     if ($this->_context == 'user') {
         $query->setSkipPermission(TRUE);
     }
     $summary =& $query->summaryContribution($this->_context);
     $this->set('summary', $summary);
     $this->assign('contributionSummary', $summary);
     $controller->run();
 }
Exemple #4
0
 /**
  * Returns the column headers as an array of tuples:
  * (name, sortName (key to the sort array))
  *
  * @param string $action
  *   The action being performed.
  * @param string $output
  *   What should the result set include (web/email/csv).
  *
  * @return array
  *   the column headers that need to be displayed
  */
 public function &getColumnHeaders($action = NULL, $output = NULL)
 {
     $pre = array();
     self::$_columnHeaders = array(array('name' => $this->_includeSoftCredits ? ts('Contribution Amount') : ts('Amount'), 'sort' => 'total_amount', 'direction' => CRM_Utils_Sort::DONTCARE));
     if ($this->_includeSoftCredits) {
         self::$_columnHeaders = array_merge(self::$_columnHeaders, array(array('name' => ts('Soft Credit Amount'), 'sort' => 'contribution_soft_credit_amount', 'direction' => CRM_Utils_Sort::DONTCARE)));
     }
     self::$_columnHeaders = array_merge(self::$_columnHeaders, array(array('name' => ts('Type'), 'sort' => 'financial_type', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Source'), 'sort' => 'contribution_source', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Received'), 'sort' => 'receive_date', 'direction' => CRM_Utils_Sort::DESCENDING), array('name' => ts('Thank-you Sent'), 'sort' => 'thankyou_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Status'), 'sort' => 'contribution_status', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Premium'), 'sort' => 'product_name', 'direction' => CRM_Utils_Sort::DONTCARE)));
     if (!$this->_single) {
         $pre = array(array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE));
     }
     self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
     if ($this->_includeSoftCredits) {
         self::$_columnHeaders = array_merge(self::$_columnHeaders, array(array('name' => ts('Soft Credit For'), 'sort' => 'contribution_soft_credit_name', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Soft Credit Type'), 'sort' => 'contribution_soft_credit_type', 'direction' => CRM_Utils_Sort::ASCENDING)));
     }
     self::$_columnHeaders = array_merge(self::$_columnHeaders, array(array('desc' => ts('Actions'))));
     CRM_Core_Smarty::singleton()->assign('softCreditColumns', $this->_includeSoftCredits);
     return self::$_columnHeaders;
 }
 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_contributionClause);
     // process the result of the query
     $rows = array();
     // check is the user has view/edit contribution permission
     $permission = CRM_CORE_PERMISSION_VIEW;
     if (CRM_Utils_System::checkPermission('edit contributions')) {
         $permission = CRM_CORE_PERMISSION_EDIT;
     }
     $mask = CRM_Core_Action::mask($permission);
     while ($result->fetch()) {
         $row = array();
         // the columns we are interested in
         foreach ($GLOBALS['_CRM_CONTRIBUTE_SELECTOR_SEARCH']['_properties'] as $property) {
             $row[$property] = $result->{$property};
         }
         $row['checkbox'] = CRM_CORE_FORM_CB_PREFIX . $result->contribution_id;
         $row['action'] = CRM_Core_Action::formLink(CRM_Contribute_Selector_Search::links(), $mask, array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context));
         $config =& CRM_Core_Config::singleton();
         $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
         switch ($result->contact_type) {
             case 'Individual':
                 $contact_type .= 'ind.gif" alt="' . ts('Individual') . '" />';
                 break;
             case 'Household':
                 $contact_type .= 'house.png" alt="' . ts('Household') . '" height="16" width="16" />';
                 break;
             case 'Organization':
                 $contact_type .= 'org.gif" alt="' . ts('Organization') . '" height="16" width="18" />';
                 break;
         }
         $row['contact_type'] = $contact_type;
         $rows[] = $row;
     }
     return $rows;
 }