changes from earlier PR 622
authorAndrew Hunt <andrew@aghstrategies.com>
Sat, 25 May 2013 21:30:29 +0000 (17:30 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Sat, 25 May 2013 21:30:29 +0000 (17:30 -0400)
CRM/Activity/Form/Search.php
CRM/Member/BAO/Membership.php
CRM/Member/Page/DashBoard.php
templates/CRM/Member/Page/DashBoard.tpl

index da7e5efe902e374d3278fdc4e2b1194708c11754..f7352b2db77bdefb52d36f174a6ae6226dde261d 100644 (file)
@@ -435,7 +435,58 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
     if (!empty($this->_defaults)) {
       $this->setDefaults($this->_defaults);
     }
-
+        
+    // Added for membership search
+    
+    $signupType = CRM_Utils_Request::retrieve('signupType', 'Positive',
+      CRM_Core_DAO::$_nullObject
+    );
+    
+    if ($signupType) {
+      //$this->_formValues['activity_type_id'] = array();
+    
+      $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
+      $signup = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
+      $renew = CRM_Utils_Array::key('Membership Signup', $activityTypes);
+      
+      switch ($signupType) {
+        case 3: // signups and renewals
+          $this->_formValues['activity_type_id'][$renew] = 1;
+          $this->_defaults['activity_type_id'][$renew] = 1;
+        case 1: // signups only
+          $this->_formValues['activity_type_id'][$signup] = 1;
+          $this->_defaults['activity_type_id'][$signup] = 1;
+          break;
+          
+        case 2: // renewals only
+          $this->_formValues['activity_type_id'][$renew] = 1;
+          $this->_defaults['activity_type_id'][$renew] = 1;
+          break;
+      }
+    }
+    
+    $dateLow = CRM_Utils_Request::retrieve('dateLow', 'Positive',
+      CRM_Core_DAO::$_nullObject
+    );
+    
+    if ($dateLow) {
+      $this->_formValues['activity_date_low'] = $dateLow;
+      $this->_defaults['activity_date_low'] = $dateLow;
+    }
+    
+    $dateHigh = CRM_Utils_Request::retrieve('dateHigh', 'Positive',
+      CRM_Core_DAO::$_nullObject
+    );
+    
+    if ($dateHigh) {
+      // Activity date time assumes midnight at the beginning of the date
+      // This sets it to almost midnight at the end of the date
+      if ($dateHigh <= 99999999) {
+        $dateHigh = 1000000 * $dateHigh + 235959;
+      }
+      $this->_formValues['activity_date_high'] = $dateHigh;
+      $this->_defaults['activity_date_high'] = $dateHigh;
+    } 
   }
 
   function getFormValues() {
index bc3d44682e7abace993e01f6269fa3286ad7c0fd..d50bf9589504baec58a9f057c343a28c479927a2 100644 (file)
@@ -41,6 +41,11 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
    * @static
    */
   static $_importableFields = NULL;
+  
+  static $_renewalActType = NULL;
+  
+  static $_signupActType = NULL;
+   
   function __construct() {
     parent::__construct();
   }
@@ -1080,11 +1085,9 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
 
   /**
    * Function to get membership joins/renewals for a specified membership
-   * type.  Specifically, retrieves a count of memberships whose start_date
-   * is within a specified date range.  Dates match the regexp
-   * "yyyy(mm(dd)?)?".  Omitted portions of a date match the earliest start
-   * date or latest end date, i.e., 200803 is March 1st as a start date and
-   * March 31st as an end date.
+   * type.  Specifically, retrieves a count of memberships whose "Membership
+   * Signup" or "Membership Renewal" activity falls in the given date range.
+   * Dates match the pattern "yyyy-mm-dd". 
    *
    * @param int    $membershipTypeId  membership type id
    * @param int    $startDate         date on which to start counting
@@ -1097,24 +1100,45 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
    */
   //LCD
   public static function getMembershipStarts($membershipTypeId, $startDate, $endDate, $isTest = 0, $isOwner = 0) {
-    $query = "SELECT count(civicrm_membership.id) as member_count
-  FROM   civicrm_membership left join civicrm_membership_status on ( civicrm_membership.status_id = civicrm_membership_status.id )
-WHERE  membership_type_id = %1 AND start_date >= '$startDate' AND start_date <= '$endDate'
-AND civicrm_membership_status.is_current_member = 1
-AND civicrm_membership.contact_id NOT IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)
-AND is_test = %2";
-    // LCD
+  
+    $testClause = 'membership.is_test = 1';
+    if (!$isTest) {
+      $testClause = '( membership.is_test IS NULL OR membership.is_test = 0 )';
+    }
+  
+    if (!self::$_signupActType || !self::$_renewalActType) {
+      self::_getActTypes();
+    }
+    
+    if (!self::$_signupActType || !self::$_renewalActType) {
+      return 0;
+    }
+
+    $query = "
+    SELECT  COUNT(DISTINCT membership.id) as member_count
+      FROM  civicrm_membership membership
+INNER JOIN civicrm_activity activity ON (activity.source_record_id = membership.id AND activity.activity_type_id in (%1, %2))
+INNER JOIN  civicrm_membership_status status ON ( membership.status_id = status.id AND status.is_current_member = 1 )
+INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND contact.is_deleted = 0 )
+     WHERE  membership.membership_type_id = %3
+       AND  activity.activity_date_time >= '$startDate' AND activity.activity_date_time <= '$endDate 23:59:59'
+       AND  {$testClause}";
+     
     $query .= ($isOwner) ? ' AND owner_membership_id IS NULL' : '';
-    $params = array(1 => array($membershipTypeId, 'Integer'),
-      2 => array($isTest, 'Boolean'),
+
+    $params = array(
+      1 => array(self::$_signupActType, 'Integer'),
+      2 => array(self::$_renewalActType, 'Integer'),
+      3 => array($membershipTypeId, 'Integer'), 
     );
+    
     $memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
     return (int)$memberCount;
   }
 
   /**
    * Function to get a count of membership for a specified membership type,
-   * optionally for a specified date.  The date must have the form yyyymmdd.
+   * optionally for a specified date.  The date must have the form yyyy-mm-dd. 
    *
    * If $date is omitted, this function counts as a member anyone whose
    * membership status_id indicates they're a current member.
@@ -1134,8 +1158,8 @@ AND is_test = %2";
    *         $date.
    */
   public static function getMembershipCount($membershipTypeId, $date = NULL, $isTest = 0, $isOwner = 0) {
-    if (!is_null($date) && !preg_match('/^\d{8}$/', $date)) {
-      CRM_Core_Error::fatal(ts('Invalid date "%1" (must have form yyyymmdd).', array(1 => $date)));
+    if (!CRM_Utils_Rule::date($date)) {
+      CRM_Core_Error::fatal(ts('Invalid date "%1" (must have form yyyy-mm-dd).', array(1 => $date)));
     }
 
     $params = array(1 => array($membershipTypeId, 'Integer'),
@@ -1150,7 +1174,6 @@ AND civicrm_membership.is_test = %2";
       $query .= " AND civicrm_membership_status.is_current_member = 1";
     }
     else {
-      $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
       $query .= " AND civicrm_membership.start_date <= '$date' AND civicrm_membership_status.is_current_member = 1";
     }
     // LCD
@@ -2294,11 +2317,8 @@ LEFT JOIN civicrm_membership mem ON ( cr.id = mem.contribution_recur_id )
   /**
    * Function to get membership joins for a specified membership
    * type.  Specifically, retrieves a count of still current memberships whose
-   * join_date and start_date
-   * are within a specified date range.  Dates match the regexp
-   * "yyyy(mm(dd)?)?".  Omitted portions of a date match the earliest start
-   * date or latest end date, i.e., 200803 is March 1st as a start date and
-   * March 31st as an end date.
+   * join_date and start_date are within a specified date range.  Dates match
+   * the pattern "yyyy-mm-dd". 
    *
    * @param int    $membershipTypeId  membership type id
    * @param int    $startDate         date on which to start counting
@@ -2314,18 +2334,29 @@ LEFT JOIN civicrm_membership mem ON ( cr.id = mem.contribution_recur_id )
     if (!$isTest) {
       $testClause = '( membership.is_test IS NULL OR membership.is_test = 0 )';
     }
+    if (!self::$_signupActType) {
+      self::_getActTypes();
+    }
+    
+    if (!self::$_signupActType) {
+      return 0;
+    }
 
     $query = "
-    SELECT  count( membership.id ) as member_count
+    SELECT  COUNT(DISTINCT membership.id) as member_count 
       FROM  civicrm_membership membership
+INNER JOIN civicrm_activity activity ON (activity.source_record_id = membership.id AND activity.activity_type_id = %1) 
 INNER JOIN  civicrm_membership_status status ON ( membership.status_id = status.id AND status.is_current_member = 1 )
-INNER JOIN  civicrm_contact contact ON ( membership.contact_id = contact.id AND contact.is_deleted = 0 )
-     WHERE  membership.membership_type_id = %1
-       AND  membership.join_date >= '$startDate'  AND membership.join_date <= '$endDate'
-       AND  membership.start_date >= '$startDate' AND membership.start_date <= '$endDate'
+INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND contact.is_deleted = 0 )
+     WHERE  membership.membership_type_id = %2
+       AND  activity.activity_date_time >= '$startDate' AND activity.activity_date_time <= '$endDate 23:59:59'
        AND  {$testClause}";
 
-    $params = array(1 => array($membershipTypeId, 'Integer'));
+    $params = array(
+      1 => array(self::$_signupActType, 'Integer'),
+      2 => array($membershipTypeId, 'Integer'),
+    );
+
     $memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
 
     return (int)$memberCount;
@@ -2333,12 +2364,9 @@ INNER JOIN  civicrm_contact contact ON ( membership.contact_id = contact.id AND
 
   /**
    * Function to get membership renewals for a specified membership
-   * type.  Specifically, retrieves a count of still current memberships whose
-   * join_date is before and start_date
-   * is within a specified date range.  Dates match the regexp
-   * "yyyy(mm(dd)?)?".  Omitted portions of a date match the earliest start
-   * date or latest end date, i.e., 200803 is March 1st as a start date and
-   * March 31st as an end date.
+   * type.  Specifically, retrieves a count of still current memberships
+   * whose join_date is before and start_date is within a specified date 
+   * range.  Dates match the pattern "yyyy-mm-dd".
    *
    * @param int    $membershipTypeId  membership type id
    * @param int    $startDate         date on which to start counting
@@ -2354,18 +2382,28 @@ INNER JOIN  civicrm_contact contact ON ( membership.contact_id = contact.id AND
     if (!$isTest) {
       $testClause = '( membership.is_test IS NULL OR membership.is_test = 0 )';
     }
+    if (!self::$_renewalActType) {
+      self::_getActTypes();
+    }
+    
+    if (!self::$_renewalActType) {
+      return 0;
+    }
 
     $query = "
-    SELECT  count(membership.id) as member_count
+    SELECT  COUNT(DISTINCT membership.id) as member_count 
       FROM  civicrm_membership membership
+INNER JOIN civicrm_activity activity ON (activity.source_record_id = membership.id AND activity.activity_type_id = %1)
 INNER JOIN  civicrm_membership_status status ON ( membership.status_id = status.id AND status.is_current_member = 1 )
 INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND contact.is_deleted = 0 )
-     WHERE  membership.membership_type_id = %1
-       AND  membership.join_date < '$startDate'
-       AND  membership.start_date >= '$startDate' AND membership.start_date <= '$endDate'
+     WHERE  membership.membership_type_id = %2
+       AND  activity.activity_date_time >= '$startDate' AND activity.activity_date_time <= '$endDate 23:59:59' 
        AND  {$testClause}";
 
-    $params = array(1 => array($membershipTypeId, 'Integer'));
+    $params = array(
+      1 => array(self::$_renewalActType, 'Integer'),
+      2 => array($membershipTypeId, 'Integer'),
+    );
     $memberCount = CRM_Core_DAO::singleValueQuery($query, $params);
 
     return (int)$memberCount;
@@ -2742,5 +2780,11 @@ WHERE      civicrm_membership.is_test = 0";
     $fieldID = key($qf->_priceSet['fields']);
     $qf->_params['price_' . $fieldID] = CRM_Utils_Array::value('id', $editedResults);
   }
+  
+  static function _getActTypes() {
+    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
+    self::$_renewalActType = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
+    self::$_signupActType = CRM_Utils_Array::key('Membership Signup', $activityTypes);
+  }
 }
 
index 42cac7d0a98c001e6c5ac42645116f47fba62b8d..13b8e1d218849411b3aa2a18452ba6aed77e0621 100644 (file)
@@ -49,17 +49,18 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
   function preProcess() {
     CRM_Utils_System::setTitle(ts('CiviMember'));
     $membershipSummary = array();
-    $preMonth          = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
-    $preMonthEnd       = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d');
-    $prePreMonthEnd    = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 2, 01, date("Y"))), '%Y%m%d');
+    $preMonth = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
+    $preMonthEnd = date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
 
     $preMonthYear = mktime(0, 0, 0, substr($preMonth, 4, 2), 1, substr($preMonth, 0, 4));
 
-    $today          = getdate();
-    $date           = CRM_Utils_Date::getToday();
+    $today = getdate();
+    $date = CRM_Utils_Date::getToday();
     $isCurrentMonth = 0;
 
+    // You can force the dashboard to display based upon a certain date
     $ym = CRM_Utils_Array::value('date', $_GET);
+    
     if ($ym) {
       if (preg_match('/^\d{6}$/', $ym) == 0 ||
         !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) ||
@@ -69,34 +70,22 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
       }
 
       $isPreviousMonth = 0;
-      $isCurrentMonth  = substr($ym, 0, 4) == $today['year'] && substr($ym, 4, 2) == $today['mon'];
-      $ymd             = date('Ymd', mktime(0, 0, -1, substr($ym, 4, 2) + 1, 1, substr($ym, 0, 4)));
-      $monthStartTs    = mktime(0, 0, 0, substr($ym, 4, 2), 1, substr($ym, 0, 4));
-      $current         = CRM_Utils_Date::customFormat($date, '%Y%m%d');
+      $isCurrentMonth = substr($ym, 0, 4) == $today['year'] && substr($ym, 4, 2) == $today['mon'];
+      $ymd = date('Y-m-d', mktime(0, 0, -1, substr($ym, 4, 2) + 1, 1, substr($ym, 0, 4)));
+      $monthStartTs = mktime(0, 0, 0, substr($ym, 4, 2), 1, substr($ym, 0, 4));
+      $current = CRM_Utils_Date::customFormat($date, '%Y-%m-%d');
+      $ym = substr($ym, 0, 4) . '-' . substr($ym, 4, 2);
     }
     else {
-      $ym              = sprintf("%04d%02d", $today['year'], $today['mon']);
-      $ymd             = sprintf("%04d%02d%02d", $today['year'], $today['mon'], $today['mday']);
-      $monthStartTs    = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
-      $current         = NULL;
-      $isCurrentMonth  = 1;
+      $ym = sprintf("%04d-%02d", $today['year'], $today['mon']);
+      $ymd = sprintf("%04d-%02d-%02d", $today['year'], $today['mon'], $today['mday']);
+      $monthStartTs = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
+      $current = CRM_Utils_Date::customFormat($date, '%Y-%m-%d');
+      $isCurrentMonth = 1;
       $isPreviousMonth = 1;
     }
-    $monthStart = $ym . '01';
-    $yearStart = substr($ym, 0, 4) . '0101';
-
-    // $preMonthStart is the day before $monthStart
-    $preMonthStart = CRM_Utils_Date::customFormat(date("Y-m-t",
-        mktime(0, 0, 0, substr($ym, 4, 2) - 1, 01, substr($ym, 0, 4))
-      ),
-      '%Y%m%d'
-    );
-    // $preYearStart is the day before $yearStart
-    $preYearStart = CRM_Utils_Date::customFormat(date("Y-m-t",
-        mktime(0, 0, 0, 12, 31, substr($ym, 0, 4) - 1)
-      ),
-      '%Y%m%d'
-    );
+    $monthStart = $ym . '-01';
+    $yearStart = substr($ym, 0, 4) . '-01-01';
 
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
     // added
@@ -175,6 +164,11 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
     $status = implode(',', $status);
 
+    /* Disabled for lack of appropriate search
+       
+       The Membership search isn't able to properly filter by join or renewal events.
+       Until that works properly, the subtotals shouldn't get links.
     foreach ($membershipSummary as $typeID => $details) {
       foreach ($details as $key => $value) {
         switch ($key) {
@@ -243,8 +237,26 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
         }
       }
     }
-    // LCD debug
-    //CRM_Core_Error::debug($membershipSummary);
+    */
+    
+    // Temporary replacement for current totals column
+    
+    foreach ($membershipSummary as $typeID => $details) {
+      if (!$isCurrentMonth) {
+        $membershipSummary[$typeID]['total']['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
+          "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID"
+        );
+        $membershipSummary[$typeID]['total_owner']['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID&owner=1");
+      }
+      else {
+        $membershipSummary[$typeID]['total']['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
+          "reset=1&force=1&status=$status"
+        );
+        $membershipSummary[$typeID]['total_owner']['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1");
+      }
+      $membershipSummary[$typeID]['current']['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID");
+      $membershipSummary[$typeID]['current_owner']['current_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&owner=1");
+    }
 
     $totalCount = array();
 
@@ -276,64 +288,64 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
 
     $totalCount['premonth']['new'] = array(
       'count' => $newCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&join=$preMonth&joinEnd=$preMonthEnd&start=$preMonth&end=$preMonthEnd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=1&dateLow=$preMonth&dateHigh=$preMonthEnd"
       ),
     );
 
     $totalCount['premonth']['renew'] = array(
       'count' => $renewCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&joinEnd=$prePreMonthEnd&start=$preMonth&end=$preMonthEnd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=2&dateLow=$preMonth&dateHigh=$preMonthEnd"
       ),
     );
 
     $totalCount['premonth']['total'] = array(
       'count' => $totalCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&start=$preMonth&end=$preMonthEnd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=3&dateLow=$preMonth&dateHigh=$preMonthEnd"
       ),
     );
 
     $totalCount['month']['new'] = array(
       'count' => $newCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&join=$monthStart&joinEnd=$ymd&start=$monthStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=1&dateLow=$monthStart&dateHigh=$ymd"
       ),
     );
 
     $totalCount['month']['renew'] = array(
       'count' => $renewCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&joinEnd=$preMonthStart&start=$monthStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=2&dateLow=$monthStart&dateHigh=$ymd"
       ),
     );
 
     $totalCount['month']['total'] = array(
       'count' => $totalCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&start=$monthStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=3&dateLow=$monthStart&dateHigh=$ymd"
       ),
     );
 
     $totalCount['year']['new'] = array(
       'count' => $newCountYear,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&join=$yearStart&joinEnd=$ymd&start=$yearStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=1&dateLow=$yearStart&dateHigh=$ymd"
       ),
     );
 
     $totalCount['year']['renew'] = array(
       'count' => $renewCountYear,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&joinEnd=$preYearStart&start=$yearStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=2&dateLow=$yearStart&dateHigh=$ymd"
       ),
     );
 
     $totalCount['year']['total'] = array(
       'count' => $totalCountYear,
-      'url' => CRM_Utils_System::url('civicrm/member/search',
-        "reset=1&force=1&status=$status&start=$yearStart&end=$ymd"
+      'url' => CRM_Utils_System::url('civicrm/activity/search',
+        "reset=1&force=1&signupType=3&dateLow=$yearStart&dateHigh=$ymd"
       ),
     );
 
@@ -360,6 +372,8 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
       );
     }
 
+    // Activity search also unable to handle owner vs. inherited
+
     //LCD add owner values
     $totalCount['premonth_owner']['premonth_owner'] = array(
       'count' => $totalCountPreMonth_owner,
@@ -368,28 +382,28 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
 
     $totalCount['month_owner']['month_owner'] = array(
       'count' => $totalCountMonth_owner,
-      'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$monthStart&end=$ymd&owner=1"),
+    //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$monthStart&end=$ymd&owner=1"),
     );
 
     $totalCount['year_owner']['year_owner'] = array(
       'count' => $totalCountYear_owner,
-      'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$yearStart&end=$ymd&owner=1"),
+    //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$yearStart&end=$ymd&owner=1"),
     );
 
     $totalCount['current_owner']['current_owner'] = array(
       'count' => $totalCountCurrent_owner,
-      'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1"),
+    //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1"),
     );
 
     $totalCount['total_owner']['total_owner'] = array(
       'count' => $totalCountTotal_owner,
-      'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1"),
+    //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1"),
     );
 
     if (!$isCurrentMonth) {
       $totalCount['total_owner']['total_owner'] = array(
         'count' => $totalCountTotal_owner,
-        'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=&end=$ymd&owner=1"),
+      //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=&end=$ymd&owner=1"),
       );
     }
     //LCD end
index bf57933a9e5e224cd63cd142b006e5a86c59edbb..cbd28ee1758538ad76cc1a7fd63fcec702ca3c02 100644 (file)
 
     {foreach from=$membershipSummary item=row}
         <tr>
-      <td><strong>{$row.month.total.name}</strong></td>
-            {if $preMonth}
-                <td class="label"><a href="{$row.premonth.new.url}" title="view details">{$row.premonth.new.count}</a></td>
-                <td class="label"><a href="{$row.premonth.renew.url}" title="view details">{$row.premonth.renew.count}</a>
-    </td>
-                <td class="label">
-        <a href="{$row.premonth.total.url}" title="view details">{$row.premonth.total.count}</a>&nbsp;
-        [ <a href="{$row.premonth_owner.premonth_owner.url}" title="view details">
-        {$row.premonth_owner.premonth_owner.count}</a> ]
-    </td>
-            {/if}
+            <td><strong>{$row.month.total.name}</strong></td>
+          {if $preMonth}
+            <td class="label">
+              {if $row.premonth.new.url}<a href="{$row.premonth.new.url}" title="view details">{$row.premonth.new.count}</a>
+              {else}{$row.premonth.new.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.premonth.renew.url}<a href="{$row.premonth.renew.url}" title="view details">{$row.premonth.renew.count}</a>
+              {else}{$row.premonth.renew.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.premonth.total.url}
+                <a href="{$row.premonth.total.url}" title="view details">{$row.premonth.total.count}</a>
+              {else}
+                {$row.premonth.total.count}
+              {/if}&nbsp;[ 
+              {if $row.premonth_owner.premonth_owner.url}
+                <a href="{$row.premonth_owner.premonth_owner.url}" title="view details">{$row.premonth_owner.premonth_owner.count}</a>
+              {else}
+                {$row.premonth_owner.premonth_owner.count}
+              {/if}]
+            </td>
+          {/if}
 
-      <td class="label"><a href="{$row.month.new.url}" title="view details">{$row.month.new.count}</a></td>
-            <td class="label"><a href="{$row.month.renew.url}" title="view details">{$row.month.renew.count}</a></td>
-            <td class="label"><a href="{$row.month.total.url}" title="view details">{$row.month.total.count}</a>&nbsp;
-          [ <a href="{$row.month_owner.month_owner.url}" title="view details">
-    {$row.month_owner.month_owner.count}</a> ]
-      </td>
+            <td class="label">
+              {if $row.month.new.url}<a href="{$row.month.new.url}" title="view details">{$row.month.new.count}</a>
+              {else}{$row.month.new.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.month.renew.url}<a href="{$row.month.renew.url}" title="view details">{$row.month.renew.count}</a>
+              {else}{$row.month.renew.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.month.total.url}
+                <a href="{$row.month.total.url}" title="view details">{$row.month.total.count}</a>
+              {else}
+                {$row.month.total.count}
+              {/if}&nbsp;[ 
+              {if $row.month_owner.month_owner.url}
+                <a href="{$row.month_owner.month_owner.url}" title="view details">{$row.month_owner.month_owner.count}</a>
+              {else}
+                {$row.month_owner.month_owner.count}
+              {/if}]
+            </td>
 
-            <td class="label"><a href="{$row.year.new.url}" title="view details">{$row.year.new.count}</a></td>
-            <td class="label"><a href="{$row.year.renew.url}" title="view details">{$row.year.renew.count}</a></td>
-            <td class="label"><a href="{$row.year.total.url}" title="view details">{$row.year.total.count}</a>&nbsp;
-        [ <a href="{$row.year_owner.year_owner.url}" title="view details">{$row.year_owner.year_owner.count}</a> ]
-      </td>
+            <td class="label">
+              {if $row.year.new.url}<a href="{$row.year.new.url}" title="view details">{$row.year.new.count}</a>
+              {else}{$row.year.new.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.year.renew.url}<a href="{$row.year.renew.url}" title="view details">{$row.year.renew.count}</a>
+              {else}{$row.year.renew.count}{/if}
+            </td>
+            <td class="label">
+              {if $row.year.total.url}
+                <a href="{$row.year.total.url}" title="view details">{$row.year.total.count}</a>
+              {else}
+                {$row.year.total.count}
+              {/if}&nbsp;[ 
+              {if $row.year_owner.year_owner.url}
+                <a href="{$row.year_owner.year_owner.url}" title="view details">{$row.year_owner.year_owner.count}</a>
+              {else}
+                {$row.year_owner.year_owner.count}
+              {/if}]
+            </td>
 
             <td class="label">
-                {if $isCurrent}
-        <a href="{$row.current.total.url}" title="view details">{$row.current.total.count}</a>&nbsp;
-                    [ <a href="{$row.current_owner.current_owner.url}" title="view details">
-        {$row.current_owner.current_owner.count}</a> ]
+              {if $isCurrent}
+                {if $row.current.total.url}
+                  <a href="{$row.current.total.url}" title="view details">{$row.current.total.count}</a>
+                {else}
+                  {$row.current.total.count}
+                {/if}&nbsp;[
+                {if $row.current_owner.current_owner.url}
+                  <a href="{$row.current_owner.current_owner.url}" title="view details">{$row.current_owner.current_owner.count}</a>
+                {else}
+                  {$row.current_owner.current_owner.count}
+                {/if} ]
+              {else}
+                {if $row.total.total.url}
+                  <a href="{$row.total.total.url}" title="view details">{$row.total.total.count}</a>
+                {else}
+                  {$row.total.total.count}
+                {/if}&nbsp;[
+                {if $row.total_owner.total_owner.url}
+                  <a href="{$row.total_owner.total_owner.url}" title="view details">{$row.total_owner.total_owner.count}</a>
                 {else}
-                    <a href="{$row.total.total.url}" title="view details">{$row.total.total.count}</a>&nbsp;
-                    [ <a href="{$row.total_owner.total_owner.url}" title="view details">
-        {$row.total_owner.total_owner.count}</a> ]
-                {/if}
+                  {$row.total_owner.total_owner.count}
+                {/if} ]
+              {/if}
             </td> {* member/search?reset=1&force=1&membership_type_id=1&current=1 *}
         </tr>
     {/foreach}
        <a href="{$totalCount.premonth.renew.url}" title="view details">{$totalCount.premonth.renew.count}</a></td>
            <td class="label">
        <a href="{$totalCount.premonth.total.url}" title="view details">{$totalCount.premonth.total.count}</a>
-       [ <a href="{$totalCount.premonth_owner.premonth_owner.url}" title="view details">{$totalCount.premonth_owner.premonth_owner.count}</a> ]
+       [
+       {if $totalCount.premonth_owner.premonth_owner.url}
+        <a href="{$totalCount.premonth_owner.premonth_owner.url}" title="view details">{$totalCount.premonth_owner.premonth_owner.count}</a>
+       {else}
+         {$totalCount.premonth_owner.premonth_owner.count}
+       {/if}
+       ]
      </td>
         {/if}
 
     <a href="{$totalCount.month.renew.url}" title="view details">{$totalCount.month.renew.count}</a></td>
         <td class="label">
     <a href="{$totalCount.month.total.url}" title="view details">{$totalCount.month.total.count}</a>
-    [ <a href="{$totalCount.month_owner.month_owner.url}" title="view details">
-    {$totalCount.month_owner.month_owner.count}</a> ]
+       [
+       {if $totalCount.month_owner.month_owner.url}
+        <a href="{$totalCount.month_owner.month_owner.url}" title="view details">{$totalCount.month_owner.month_owner.count}</a>
+       {else}
+         {$totalCount.month_owner.month_owner.count}
+       {/if}
+       ]
   </td>
         <td class="label">
     <a href="{$totalCount.year.new.url}" title="view details">{$totalCount.year.new.count}</a></td>
     <a href="{$totalCount.year.renew.url}" title="view details">{$totalCount.year.renew.count}</a></td>
         <td class="label">
     <a href="{$totalCount.year.total.url}" title="view details">{$totalCount.year.total.count}</a>
-    [ <a href="{$totalCount.year_owner.year_owner.url}" title="view details">{$totalCount.year_owner.year_owner.count}
-    </a> ]
+       [
+       {if $totalCount.year_owner.year_owner.url}
+        <a href="{$totalCount.year_owner.year_owner.url}" title="view details">{$totalCount.year_owner.year_owner.count}</a>
+       {else}
+         {$totalCount.year_owner.year_owner.count}
+       {/if}
+       ]
   </td>
 
         <td class="label">