/**
  * Retrieve list of Scheduled Reminders
  *
  * @param bool    $namesOnly    return simple list of names
  *
  * @return array  (reference)   reminder list
  * @static
  * @access public
  */
 static function &getList($namesOnly = FALSE, $entityValue = NULL, $id = NULL)
 {
     $activity_type = CRM_Core_PseudoConstant::activityType(FALSE) + CRM_Core_PseudoConstant::activityType(FALSE, TRUE);
     $activity_status = CRM_Core_PseudoConstant::activityStatus();
     $event_type = CRM_Event_PseudoConstant::eventType();
     $civicrm_event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
     $civicrm_participant_status_type = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
     $auto_renew_options = CRM_Core_PseudoConstant::autoRenew();
     $civicrm_membership_type = CRM_Member_PseudoConstant::membershipType();
     asort($activity_type);
     $entity = array('civicrm_activity' => 'Activity', 'civicrm_participant' => 'Event', 'civicrm_membership' => 'Member');
     $query = "\nSELECT\n       title,\n       cam.entity,\n       cas.id as id,\n       cam.entity_value as entityValue,\n       cas.entity_value as entityValueIds,\n       cam.entity_status as entityStatus,\n       cas.entity_status as entityStatusIds,\n       cas.start_action_date as entityDate,\n       cas.start_action_offset,\n       cas.start_action_unit,\n       cas.start_action_condition,\n       cas.absolute_date,\n       is_repeat,\n       is_active\n\nFROM civicrm_action_schedule cas\nLEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)\n";
     $params = CRM_Core_DAO::$_nullArray;
     if ($entityValue and $id) {
         $where = "\nWHERE   cas.entity_value = {$id} AND\n        cam.entity_value = '{$entityValue}'";
         $query .= $where;
         $params = array(1 => array($id, 'Integer'), 2 => array($entityValue, 'String'));
     }
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $list[$dao->id]['id'] = $dao->id;
         $list[$dao->id]['title'] = $dao->title;
         $list[$dao->id]['start_action_offset'] = $dao->start_action_offset;
         $list[$dao->id]['start_action_unit'] = $dao->start_action_unit;
         $list[$dao->id]['start_action_condition'] = $dao->start_action_condition;
         $list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate));
         $list[$dao->id]['absolute_date'] = $dao->absolute_date;
         $status = $dao->entityStatus;
         $statusArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds);
         foreach ($statusArray as &$s) {
             $s = CRM_Utils_Array::value($s, ${$status});
         }
         $statusIds = implode(', ', $statusArray);
         $value = $dao->entityValue;
         $valueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds);
         foreach ($valueArray as &$v) {
             $v = CRM_Utils_Array::value($v, ${$value});
         }
         $valueIds = implode(', ', $valueArray);
         $list[$dao->id]['entity'] = $entity[$dao->entity];
         $list[$dao->id]['value'] = $valueIds;
         $list[$dao->id]['status'] = $statusIds;
         $list[$dao->id]['is_repeat'] = $dao->is_repeat;
         $list[$dao->id]['is_active'] = $dao->is_active;
     }
     return $list;
 }
 /**
  * Get all the auto renew options
  *
  * @access public
  * @static
  *
  * @return array self::autoRenew - array reference of all autoRenew
  *
  */
 public static function &autoRenew()
 {
     if (!self::$autoRenew) {
         self::$autoRenew = CRM_Core_OptionGroup::values('auto_renew_options', FALSE, FALSE);
     }
     return self::$autoRenew;
 }