Commit c6a8e7a3 authored by kurund's avatar kurund

allow contribution widget to include pending status if &includePending=1 is passed.

parent 03598663
......@@ -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);
......
......@@ -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) . ';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment