I found a piece of code to show a birthday block in Drupal.
Had to modify it a little bit to get it to work with the current versions.
But I noticed that deleted or deceased persons were still showing up in this list.
I don't know the correct code for this. Could someone please fix this code for me and others that are wanting to use this code?
My php / mysql skills are not enough but I think it must be something like: $sql = "SELECT * FROM civicrm_contact
\n"
. "where is_deceased
= false";
<?php
// Check if CiviCRM is installed here.
if (!module_exists('civicrm')) return false;
// Initialization call is required to use CiviCRM APIs.
civicrm_initialize(true);
require_once('CRM/Core/DAO.php');
$query = "SELECT id, display_name, birth_date, CONCAT(((RIGHT(birth_date,5)
< RIGHT(CURRENT_DATE,5)) + YEAR(CURRENT_DATE)), RIGHT(birth_date,6)) AS bday,
concat(concat(month(birth_date), '/'), day(birth_date)) as displaydate,
(TO_DAYS(CONCAT(((RIGHT(birth_date,5) < RIGHT(CURRENT_DATE,5)) + YEAR(CURRENT_DATE)),
RIGHT(birth_date,6))) - TO_DAYS(CURRENT_DATE)) AS toBday FROM civicrm_contact WHERE
(TO_DAYS(CONCAT(((RIGHT(birth_date,5) < RIGHT(CURRENT_DATE,5)) + YEAR(CURRENT_DATE)),
RIGHT(birth_date,6))) - TO_DAYS(CURRENT_DATE) < 7) ORDER BY bday, RIGHT(birth_date,5);";
$params = array( );
$dao =& CRM_Core_DAO::executeQuery( $query, $params );
echo "<div class=\"item-list\"><ul>\n";
while ( $dao->fetch( ) ) {
echo "<li><a href=\"/civicrm/contact/view?reset=1&cid=" . $dao->id . "\">" . $dao->display_name .
"</a>, " . $dao->displaydate;
echo "</li>\n";
}
echo "</div></ul>\n";
?>