<?php
-// $Id$
-
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
'pieChart' => 'Pie Chart',
);
public $_drilldownReport = array('pledge/summary' => 'Link to Detail Report');
-
+
protected $_customGroupExtends = array(
'Pledge');
-
+
function __construct() {
+
+ // 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(
array(
'pledge_create_date' =>
array(
- 'title' => 'Pledge Made',
+ 'title' => ts('Pledge Made'),
'operatorType' => CRM_Report_Form::OP_DATE,
),
'currency' =>
array('title' => 'Currency',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::currencySymbols('name','name'),
+ 'options' => CRM_Core_OptionGroup::values('currencies_enabled'),
+ 'default' => NULL,
'type' => CRM_Utils_Type::T_STRING,
),
'financial_type_id' =>
'required' => TRUE,
),
),
+ 'filters' =>
+ array(
+ 'scheduled_date' =>
+ array(
+ 'title' => ts('Next Payment Due'),
+ 'operatorType' => CRM_Report_Form::OP_DATE,
+ ),
+ ),
'grouping' => 'pledge-fields',
),
'civicrm_address' =>
),
);
+ // If we have a campaign, build out the relevant elements
+ if ($campaignEnabled && !empty($this->activeCampaigns)) {
+ $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array(
+ 'title' => 'Campaign',
+ 'default' => 'false',
+ );
+ $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'),
+ 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+ 'options' => $this->activeCampaigns,
+ );
+ }
+
$this->_tagFilter = TRUE;
$this->_currencyColumn = 'civicrm_pledge_currency';
parent::__construct();
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
- if (CRM_Utils_Array::value('required', $field) ||
- CRM_Utils_Array::value($fieldName, $this->_params['fields'])
- ) {
+ if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
// to include optional columns address and email, only if checked
if ($tableName == 'civicrm_address') {
$this->_addressField = TRUE;
$this->_from = "
FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}
- INNER JOIN civicrm_pledge {$this->_aliases['civicrm_pledge']}
+ INNER JOIN civicrm_pledge {$this->_aliases['civicrm_pledge']}
ON ({$this->_aliases['civicrm_pledge']}.contact_id =
- {$this->_aliases['civicrm_contact']}.id) AND
+ {$this->_aliases['civicrm_contact']}.id) AND
{$this->_aliases['civicrm_pledge']}.status_id IN ( {$statusIds} )
LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']}
ON ({$this->_aliases['civicrm_pledge']}.id =
// include address field if address column is to be included
if ($this->_addressField) {
$this->_from .= "
- LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
- ON ({$this->_aliases['civicrm_contact']}.id =
+ LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
+ ON ({$this->_aliases['civicrm_contact']}.id =
{$this->_aliases['civicrm_address']}.contact_id) AND
{$this->_aliases['civicrm_address']}.is_primary = 1\n";
}
// include email field if email column is to be included
if ($this->_emailField) {
$this->_from .= "
- LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON ({$this->_aliases['civicrm_contact']}.id =
- {$this->_aliases['civicrm_email']}.contact_id) AND
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ ON ({$this->_aliases['civicrm_contact']}.id =
+ {$this->_aliases['civicrm_email']}.contact_id) AND
{$this->_aliases['civicrm_email']}.is_primary = 1\n";
}
}
function groupBy() {
$this->_groupBy = "
- GROUP BY {$this->_aliases['civicrm_pledge']}.contact_id,
+ GROUP BY {$this->_aliases['civicrm_pledge']}.contact_id,
{$this->_aliases['civicrm_pledge']}.id,
{$this->_aliases['civicrm_pledge']}.currency";
}
//handle the Financial Type Ids
if (array_key_exists('civicrm_pledge_financial_type_id', $row)) {
if ($value = $row['civicrm_pledge_financial_type_id']) {
- $rows[$rowNum]['civicrm_pledge_financial_type_id'] =
+ $rows[$rowNum]['civicrm_pledge_financial_type_id'] =
CRM_Contribute_PseudoConstant::financialType($value, false);
}
$entryFound = TRUE;
$entryFound = TRUE;
}
+ // If using campaigns, convert campaign_id to campaign title
+ if (array_key_exists('civicrm_pledge_campaign_id', $row)) {
+ if ($value = $row['civicrm_pledge_campaign_id']) {
+ $rows[$rowNum]['civicrm_pledge_campaign_id'] = $this->activeCampaigns[$value];
+ }
+ $entryFound = TRUE;
+ }
+
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {