Commit 5b83e9cd authored by sluc23's avatar sluc23

Merge branch '2.x#dev-birthday' into '2.x'

add birth_date in order_bys

See merge request civicrm/com.ixiam.modules.reportplus!20
parents fb3a2cb2 cd15de74
<?php
use CRM_Reportplus_ExtensionUtil as E;
class CRM_Reportplus_Form_Contact_Birthday extends CRM_Reportplus_Form {
protected $_summary = NULL;
......@@ -97,6 +99,27 @@ class CRM_Reportplus_Form_Contact_Birthday extends CRM_Reportplus_Form {
'default_weight' => '0',
'default_order' => 'ASC',
),
'birth_date_year' => array(
'title' => E::ts('Birth Date (Year)'),
'default_weight' => '1',
'dbAlias' => 'YEAR(contact_civireport.birth_date)',
'type' => CRM_Utils_Type::T_STRING,
'default_order' => 'ASC',
),
'birth_date_month' => array(
'title' => E::ts('Birth Date (Month)'),
'default_weight' => '2',
'dbAlias' => 'MONTH(contact_civireport.birth_date)',
'type' => CRM_Utils_Type::T_STRING,
'default_order' => 'ASC',
),
'birth_date_day' => array(
'title' => E::ts('Birth Date (Day)'),
'default_weight' => '3',
'dbAlias' => 'DAYOFMONTH(contact_civireport.birth_date)',
'type' => CRM_Utils_Type::T_STRING,
'default_order' => 'ASC',
),
),
),
'civicrm_email' => array(
......@@ -307,6 +330,9 @@ class CRM_Reportplus_Form_Contact_Birthday extends CRM_Reportplus_Form {
}
}
// Hide all contacts with null bday
array_push($clauses, '( contact_civireport.birth_date IS NOT NULL )');
if ($clauses) {
$this->_where = "WHERE " . implode(' AND ', $clauses);
}
......@@ -362,9 +388,13 @@ class CRM_Reportplus_Form_Contact_Birthday extends CRM_Reportplus_Form {
$entryFound = TRUE;
}
// display birthday in the configured custom format
if (array_key_exists('civicrm_contact_birth_date', $row)) {
$bday = strftime("%d.%m.%Y", strtotime($row['civicrm_contact_birth_date']));
$rows[$rowNum]['civicrm_contact_birth_date'] = $bday;
$birthDate = $row['civicrm_contact_birth_date'];
if ($birthDate) {
$rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, Civi::settings()->get('dateformatshortdate'));
}
$entryFound = TRUE;
}
......
......@@ -163,3 +163,11 @@ msgstr "Ocultar filas/columnas sin categoría"
msgid "Show Totals"
msgstr "Mostrar Totales"
msgid "Birth Date (Year)"
msgstr "Fecha de nacimiento (Año)"
msgid "Birth Date (Month)"
msgstr "Fecha de nacimiento (Mes)"
msgid "Birth Date (Day)"
msgstr "Fecha de nacimiento (Día)"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment