X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm%2FContribute%2FLybunt.php;h=bad9b8ff9e8fc893ad7501c9024ce31b45cfa755;hb=4238f84bfc2e2c172272a39f24e5bd6fa8826262;hp=0fb7f093a5d8ec4e0e09cb1981322d15687e3ad7;hpb=daa46b94db74b842b7d7c6be293401672b637e7f;p=civicrm-core.git diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 0fb7f093a5..bad9b8ff9e 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -89,15 +89,6 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $date['minYear']++; } - // Check if CiviCampaign is a) enabled and b) has active campaigns - $config = CRM_Core_Config::singleton(); - $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); - if ($campaignEnabled) { - $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); - $this->activeCampaigns = $getCampaigns['campaigns']; - asort($this->activeCampaigns); - } - $this->_columns = array( 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', @@ -271,19 +262,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { ); // If we have a campaign, build out the relevant elements - if ($campaignEnabled && !empty($this->activeCampaigns)) { - $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array( - 'title' => ts('Campaign'), - 'default' => 'false', - 'type' => CRM_Utils_Type::T_INT, - ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( - 'title' => ts('Campaign'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $this->activeCampaigns, - 'type' => CRM_Utils_Type::T_INT, - ); - } + $this->addCampaignFields('civicrm_contribution'); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -364,9 +343,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $this->_from .= " ON {$this->_aliases['civicrm_contribution']}.contact_id = {$this->_aliases['civicrm_contact']}.id AND {$this->_aliases['civicrm_contribution']}.is_test = 0 AND " . $this->whereClauseLastYear("{$this->_aliases['civicrm_contribution']}.receive_date") . " - {$this->_aclFrom} - LEFT JOIN civicrm_contribution cont_exclude ON cont_exclude.contact_id = {$this->_aliases['civicrm_contact']}.id - AND " . $this->whereClauseThisYear('cont_exclude.receive_date'); + {$this->_aclFrom} "; $this->selectivelyAddLocationTablesJoinsToFilterQuery(); } @@ -399,7 +376,11 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { if ($field['name'] == 'receive_date') { $clause = 1; if (empty($this->contactTempTable)) { - $this->_whereClauses[] = "cont_exclude.id IS NULL"; + $clause = "{$this->_aliases['civicrm_contact']}.id NOT IN ( + SELECT cont_exclude.contact_id + FROM civicrm_contribution cont_exclude + WHERE " . $this->whereClauseThisYear('cont_exclude.receive_date') + . ")"; } } // Group filtering is already done so skip. @@ -567,13 +548,12 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { // @todo this acl has no test coverage and is very hard to test manually so could be fragile. $this->resetFormSqlAndWhereHavingClauses(); - $this->contactTempTable = 'civicrm_report_temp_lybunt_c_' . date('Ymd_') . uniqid(); + $this->contactTempTable = $this->createTemporaryTable('rptlybunt', " + SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} + {$this->_where} + GROUP BY {$this->_aliases['civicrm_contact']}.id" + ); $this->limit(); - $getContacts = " - CREATE TEMPORARY TABLE $this->contactTempTable {$this->_databaseAttributes} - SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} {$this->_where} - GROUP BY {$this->_aliases['civicrm_contact']}.id"; - $this->executeReportQuery($getContacts); if (empty($this->_params['charts'])) { $this->setPager(); } @@ -717,7 +697,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { // convert campaign_id to campaign title if (array_key_exists('civicrm_contribution_campaign_id', $row)) { if ($value = $row['civicrm_contribution_campaign_id']) { - $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value]; + $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->campaigns[$value]; $entryFound = TRUE; } }