comment fixes
[civicrm-core.git] / CRM / Contribute / BAO / Widget.php
index d0f34918c4c92af74826472239da472b7fc10f64..c7456707fc70a3ce310a20fd7f2ad542587a142d 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
+ * @copyright CiviCRM LLC (c) 2004-2015
  */
 
 /**
- * Class to retrieve information about a contribution page
+ * Class to retrieve information about a contribution page.
  */
 class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget {
 
@@ -41,11 +40,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 bool $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 +78,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);