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) »
  • Custom Fields Sum() in Report
Pages: 1 2 [3]

Author Topic: Custom Fields Sum() in Report  (Read 4462 times)

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: Custom Fields Sum() in Report
September 24, 2010, 10:00:08 pm
I did that and it works sort of. It returns the message properly yet when I run the report for a date range in which there are records returned the code skips the first record. For example I have 3 notes entered and it only returns the Note2 and Note 3.

Code: [Select]
               $sql = $select . ' ' . $clause;

        $dao = CRM_Core_DAO::executeQuery( $sql );
        if (! $dao->fetch( ) ) {
          $statistics['groups2'][$i] = array( 'title' => '',
                              'value' =>  '</td><td>There were no notes entered for the date range selected.</td><td>' );
        }
        else {
        $i = 0;
        while ( $dao->fetch( ) ) {
         $statistics['groups2'][$i] = array( 'title' => '',
                      'value' =>  $dao->n_date . '</td><td>' . $dao->n_name . '</td><td>'  . $dao->n_note ); 
         $i++;
           }
    }
        return $statistics;

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: Custom Fields Sum() in Report
September 25, 2010, 01:38:07 am
finally after a friend sat down and helped me with it we figured it out. below is the snippet of code that works

Code: [Select]
$sql = $select . ' ' . $clause;

        $dao = CRM_Core_DAO::executeQuery( $sql );

        $i = 0;
        while ( $dao->fetch( ) ) {
         $statistics['groups2'][$i] = array( 'title' => '',
                      'value' =>  $dao->n_date . '</td><td>' . $dao->n_name . '</td><td>'  . $dao->n_note );
         $i++;
           }
         if (count($statistics['groups2']) == 0 || !(isset($statistics['groups2']))) {
            $statistics['groups2'][$i] = array( 'title' => '',
                              'value' =>  '</td><td>There were no notes entered for the date range selected.</td><td>' );
         }

        return $statistics;

 }

Pages: 1 2 [3]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Custom Fields Sum() in Report

This forum was archived on 2017-11-26.