Skip to content

Commit

Permalink
Add effective date to the campaign progress report.
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jul 23, 2016
1 parent 7ab16c3 commit 56c3280
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions CRM/Extendedreport/Form/Report/Campaign/CampaignProgressReport.php
Expand Up @@ -57,6 +57,14 @@ public function __construct() {
'type' => CRM_Utils_Type::T_MONEY,
),
),
'filters' => array(
'effective_date' => array(
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Date range'),
'operatorType' => self::OP_SINGLEDATE,
'pseudofield' => TRUE,
)
),
),
);

Expand Down Expand Up @@ -103,6 +111,7 @@ function from() {
* Join on a progress summary.
*/
protected function joinProgressTable() {
$until = CRM_Utils_Array::value('effective_date_value', $this->_params);
$this->_from .= " LEFT JOIN
(
Expand All @@ -120,18 +129,27 @@ protected function joinProgressTable() {
GROUP BY pledge_id
) as pp
ON pp.pledge_id = p.id
WHERE p.is_test = 0
UNION
WHERE p.is_test = 0";
if ($until) {
$this->_from .= ' AND p.create_date <="' . CRM_Utils_Type::validate(CRM_Utils_Date::processDate($until), 'Integer') . '"';
}

$this->_from .= " UNION
SELECT CONCAT('c', c.id) as id, contact_id, campaign_id, financial_type_id,
COALESCE(total_amount, 0) as total_amount, c.currency,
COALESCE(total_amount, 0) as paid_amount,
0 as balance_amount,
0 as is_pledge
FROM civicrm_contribution c LEFT JOIN civicrm_pledge_payment pp ON pp.contribution_id = c.id
FROM civicrm_contribution c
LEFT JOIN civicrm_pledge_payment pp ON pp.contribution_id = c.id
WHERE c.contribution_status_id = 1
AND pp.id IS NULL
) as progress ON progress.campaign_id = campaign.id
AND pp.id IS NULL ";
if ($until) {
$this->_from .= ' AND c.receive_date <= "' . CRM_Utils_Type::validate(CRM_Utils_Date::processDate($until), 'Integer') . '"';
}

$this->_from .= ") as progress ON progress.campaign_id = campaign.id
";
}
Expand Down Expand Up @@ -213,4 +231,23 @@ function alterDisplay(&$rows) {
$this->assign('grandStat', $this->rollupRow);
}


/**
* Note: $fieldName param allows inheriting class to build operationPairs
* specific to a field.
*
* @param string $type
* @param null $fieldName
*
* @return array
*/
function getOperationPair($type = "string", $fieldName = NULL) {
if ($type == self::OP_SINGLEDATE) {
return array(
'to' => ts('Until Date'),
);
}
return parent::getOperationPair($type, $fieldName);
}

}

0 comments on commit 56c3280

Please sign in to comment.