* 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();
$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);
$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';
$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) . ';