From c6a8e7a398d278e56f9e277fd3713f75050bd3fe Mon Sep 17 00:00:00 2001 From: kurund Date: Sun, 19 Apr 2015 14:54:00 -0600 Subject: [PATCH] allow contribution widget to include pending status if &includePending=1 is passed. --- CRM/Contribute/BAO/Widget.php | 13 ++++++++++--- extern/widget.php | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Widget.php b/CRM/Contribute/BAO/Widget.php index 8b67c1629c..2f7e62554f 100644 --- a/CRM/Contribute/BAO/Widget.php +++ b/CRM/Contribute/BAO/Widget.php @@ -41,11 +41,12 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { * Gets all campaign related data and returns it as a std class. * * @param int $contributionPageID - * @param string $widgetID + * @param int $widgetID + * @param boolean $includePending * * @return object */ - public static function getContributionPageData($contributionPageID, $widgetID) { + public static function getContributionPageData($contributionPageID, $widgetID, $includePending = false) { $config = CRM_Core_Config::singleton(); $data = array(); @@ -78,12 +79,18 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { $data['button_title'] = $widget->button_title; $data['about'] = $widget->about; + //check if pending status needs to be included + $status = '1'; + if ($includePending) { + $status = '1,2'; + } + $query = " SELECT count( id ) as count, sum( total_amount) as amount FROM civicrm_contribution WHERE is_test = 0 - AND contribution_status_id = 1 + AND contribution_status_id IN ({$status}) AND contribution_page_id = %1"; $params = array(1 => array($contributionPageID, 'Integer')); $dao = CRM_Core_DAO::executeQuery($query, $params); diff --git a/extern/widget.php b/extern/widget.php index 92686dc778..b294d043a6 100644 --- a/extern/widget.php +++ b/extern/widget.php @@ -41,6 +41,7 @@ require_once 'CRM/Utils/Request.php'; $cpageId = CRM_Utils_Request::retrieve('cpageId', 'Positive', CRM_Core_DAO::$_nullObject); $widgetId = CRM_Utils_Request::retrieve('widgetId', 'Positive', CRM_Core_DAO::$_nullObject); $format = CRM_Utils_Request::retrieve('format', 'Positive', CRM_Core_DAO::$_nullObject); +$includePending = CRM_Utils_Request::retrieve('includePending', 'Boolean', CRM_Core_DAO::$_nullObject); require_once 'CRM/Contribute/BAO/Widget.php'; @@ -49,7 +50,7 @@ if (isset($format)) { $jsonvar .= $cpageId; } -$data = CRM_Contribute_BAO_Widget::getContributionPageData($cpageId, $widgetId); +$data = CRM_Contribute_BAO_Widget::getContributionPageData($cpageId, $widgetId, $includePending); $output = ' var ' . $jsonvar . ' = ' . json_encode($data) . '; -- 2.25.1