CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • how to get gender into report
Pages: [1]

Author Topic: how to get gender into report  (Read 2593 times)

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
how to get gender into report
June 25, 2010, 07:49:41 am
ive worked out how to get the gender_id into the report but having a 1 or a 2 in there is useless to most people.
Code: [Select]
'display_name' =>
                                 array( 'title'      => ts( 'Contact Name' ),
                                        'required'   => true,
                                        'no_repeat'  => true ),
                                 'gender_id' =>
                                 array( 'title'      => ts( 'Gender' ),
                                        'required'   => true,
                                        'no_repeat'  => false ),
                                 'birth_date' =>
                                 array( 'title'      => ts( 'Date of Birth' ),
                                        'required'   => true,
                                        'no_repeat'  => false ),
                                 'id'           =>
                                 array( 'no_display' => true,
                                        'required'   => true ), ),


how do i actually get it to say male or female depending on the option value?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to get gender into report
June 25, 2010, 10:12:52 am
Quote
how do i actually get it to say male or female depending on the option value?
You mean you need select?

Kurund
Found this reply helpful? Support CiviCRM

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: how to get gender into report
June 25, 2010, 06:03:25 pm
yes. i just need the gender to show up in the report in plain english (as male or female) and not as numbers (1 or 2).

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to get gender into report
June 28, 2010, 02:17:10 am
Quote
yes. i just need the gender to show up in the report in plain english (as male or female) and not as numbers (1 or 2).

You should check code for state province or country, it will be similar to gender.

Kurund
Found this reply helpful? Support CiviCRM

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: how to get gender into report
June 28, 2010, 02:45:18 am
unfortunately, that's what i did in the first place. the output of gender is still numeric...


Code: [Select]
'civicrm_address' =>
                   array( 'dao'      => 'CRM_Core_DAO_Address',
                          'fields'   =>
                          array( 'street_address'    => null,
                                 'city'              => null,
                                 'postal_code'       => null,
                                 'state_province_id' =>
                                 array( 'title'      => ts( 'State/Province' ), ),
                                 'country_id'        =>
                                 array( 'title'      => ts( 'Country' ), ),
                                 ),
                         


and the code i put in...
Code: [Select]
array( 'dao'     => 'CRM_Contact_DAO_Contact',
                          'fields'  =>
                          array( 'display_name' =>
                                 array( 'title'      => ts( 'Contact Name' ),
                                        'required'   => true,
                                        'no_repeat'  => true ),
                                 'organization_name' =>
                                 array( 'title' => ts( 'Club' ),
                                        'required'  => true,
                                        'no_repeat' => false ),
                                 'gender_id' =>
                                 array( 'title'      => ts( 'Gender' ), ),
                                 'birth_date' =>
                                 array( 'title'      => ts( 'Date of Birth' ), ),
                                 'id'           =>
                                 array( 'no_display' => true,
                                        'required'   => true ), ),

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: how to get gender into report
June 28, 2010, 03:16:59 am
Yoda_Oz :
Quote
the output of gender is still numeric...
You might wanna manipulate the option values in alterDisplay method using gender method in CRM/Core/PseudoConstant.php which will convert the numeric to value (the way you want it).

As Kurund mentioned earlier, for reference you can check stateProvince or country in the same method.
Hope that helps!
Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: how to get gender into report
June 28, 2010, 03:36:13 am
im not a coder and i dont have a clue what to do. can't someone just tell me what to copy and paste and where to put it please???

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: how to get gender into report
June 28, 2010, 03:48:02 am
Put the following code in alterDisplay method :

Code: [Select]
+            if ( array_key_exists('civicrm_contact_gender_id', $row) ) {
+                if ( $value = $row['civicrm_contact_gender_id'] ) {
+                    $gender = CRM_Core_PseudoConstant::gender( $value );
+                    $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
+                }
+                $entryFound = true;
+            }
+ 

-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: how to get gender into report
June 28, 2010, 03:50:34 am
YAY!!!!!!!

finally! this has been bugging me for days! thank you very much :)

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to get gender into report
June 28, 2010, 03:52:11 am
Since you are non-techie might be easier to hire someone from professional list :)

Kurund
Found this reply helpful? Support CiviCRM

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: how to get gender into report
August 27, 2010, 03:49:09 am
If you are expecting a lot of rows in your output it can improve performance slightly to put
Quote
$gender = CRM_Core_PseudoConstant::gender( $value );
before the foreach

Note for core team: the issue is that this is not the same pattern as many other fields. Obviously it would be easier when customizing reports -- something the report writer is supposed to support -- to declare this in the __construct function rather than code it in alterDisplay().
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

phunter

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
  • CiviCRM version: Latest
  • CMS version: Drupal 7
Re: how to get gender into report
May 06, 2014, 12:24:02 pm
I realise this is a post that is many years old but seems the best place to comment rather than adding a new post but also possibly has connections with https://forum.civicrm.org/index.php?topic=30874.0
and
https://wiki.civicrm.org/confluence/display/CRMDOC/Search+on+Gender+and+Age

The root of the problem seems to be there there is no longer a method of CRM_Core_PseudoConstant::gender() defined in ./CRM/Core/PseudoConstant.php

Has this been replace with another solution to populate a list of available genders in reports and searches or an I missing something here?

It should also be noted that the gender search wiki needs the interface element updating and a summary method adding along with fixes to get the gender working (the bit that I a stuck on)

Any comments would be appreciated.




Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • how to get gender into report

This forum was archived on 2017-11-26.