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 create reports which show overdue (scheduled) Activities in red?
Pages: [1]

Author Topic: How to create reports which show overdue (scheduled) Activities in red?  (Read 3094 times)

Mark Tompsett

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 9
    • QualityTime Services Ltd
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.30-cll
  • PHP version: 5.3.23
How to create reports which show overdue (scheduled) Activities in red?
January 17, 2012, 08:28:17 am
What I am trying to do is create a report which shows overdue scheduled Activities in red, like the Activities dashlet does or the Case Activities display in the Manage Case screen.
In these displays the table row in which such Activities are displayed has a class of "status-overdue" which causes the row to display in red (by virtue of the civicrm.css which makes them appear in color:#E43D2B which is a bright orange/red).
None of the report templates that come with CiviCRM seem to do this, so I tried to create my own report template to do this, but I am struggling.    :(

Looking at the code for these existing displays it seems that the row object has a property 'class' which if set to the value 'status-overdue' will cause the table row in the generated HTML to have that class.  I have tried (in the alterDisplay function of the report template) ...
Code: [Select]
$rows[$rowNum]['class'] = 'status-overdue'in the appropriate place, but that seems to have no effect.

I am obviously a little out of my depth here, so can anyone help please?  :-[

Thanks
Mark

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 create reports which show overdue (scheduled) Activities in red?
January 17, 2012, 10:08:39 pm
Quote
$rows[$rowNum]['class'] = 'status-overdue'

Once you add the class in alterdisplay you will also need to modify report template to add it to <tr>

Hth
Kurund
Found this reply helpful? Support CiviCRM

Mark Tompsett

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 9
    • QualityTime Services Ltd
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.30-cll
  • PHP version: 5.3.23
Re: How to create reports which show overdue (scheduled) Activities in red?
January 18, 2012, 02:54:30 pm
Thanks Kurund, that worked.   :)

Mark

mhonman

  • I’m new here
  • *
  • Posts: 20
  • Karma: 2
Re: How to create reports which show overdue (scheduled) Activities in red?
January 19, 2012, 06:51:56 am
Just a bit more detail on that... the custom report doesn't have any special template, it just includes templates/CRM/Report/Form.tpl - which in turn includes templates/CRM/Report/Layout/Table.tpl which has the <tr in question.

The change to that template is simple, the line
            <tr  class="{cycle values="odd-row,even-row"} crm-report" id="crm-report_{$rowid}">

becomes
            <tr  class="{cycle values="odd-row,even-row"} {$row.class} crm-report" id="crm-report_{$rowid}">
 
Would one of the CiviCRM team be able to make that change to the version of Table.tpl distributed with CiviCRM, as it seems to be a generally useful enhancement?

Mark (the other one)

P.S. Here is the code that goes in the report...

            if ( array_key_exists('civicrm_activity_activity_date_time', $row ) ) {
                if ( CRM_Utils_Date::overdue( $rows[$rowNum]['civicrm_activity_activity_date_time'] ) ) {
                    $rows[$rowNum]['class'] = $rows[$rowNum]['class']." status-overdue";
                    $entryFound = true;
                }
            }
« Last Edit: January 19, 2012, 07:15:29 am by mhonman »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: How to create reports which show overdue (scheduled) Activities in red?
January 20, 2012, 09:45:34 am
This improvement will be included in the 4.2 release cycle: http://issues.civicrm.org/jira/browse/CRM-9515
Protect your investment in CiviCRM by  becoming a Member!

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: How to create reports which show overdue (scheduled) Activities in red?
August 29, 2012, 01:42:51 am
I've just installed 4.2 and it seems to have changed all my activities reports and the activity dashlet to showing ALL past activities in red. Before it just used to highlight incomplete activities in red, but now it shows completed activities in red too. ???

Does anyone know if this is as a result of http://issues.civicrm.org/jira/browse/CRM-9515 ?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: How to create reports which show overdue (scheduled) Activities in red?
August 29, 2012, 02:32:38 pm
Stuart - I tested this on my local 4.2 and only past due activities where status is NOT completed are being assigned the status-overdue class. Also checked the code change for CRM-9515 (below) which checks status before assigning that css class. Hopefully you can dig in a bit more on your side to see what's happening. Are your "completed" activities marked differently somehow ??

Code: [Select]
+            if ( array_key_exists('civicrm_activity_activity_date_time', $row ) ) {
+                if ( CRM_Utils_Date::overdue( $rows[$rowNum]['civicrm_activity_activity_date_time'] ) &&
+                     $activityStatus[$row['civicrm_activity_status_id']] != 'Completed' ) {
+                    $rows[$rowNum]['class'] = "status-overdue";
+                    $entryFound = true;
+                }
+            }
+
Protect your investment in CiviCRM by  becoming a Member!

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: How to create reports which show overdue (scheduled) Activities in red?
August 30, 2012, 01:11:54 am
Hi Dave

Thanks for checking this out.

I had a fiddle with the Activity.php lines that you listed and even when I changed the activityStatus check to
$activityStatus[$row['civicrm_activity_status_id']] != 'Scheduled'
it still gave the same result.

In fact the only thing that made the activities go black again was to change it to this:
$activityStatus[$row['civicrm_activity_status_id']] = FALSE

So I wonder if my activityStatus check is doing funny things. But I don't know where that is.

Stuart

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: How to create reports which show overdue (scheduled) Activities in red?
August 31, 2012, 02:37:11 pm
Let's see what values are being returned in $activityStatus[$row['civicrm_activity_status_id']] variable (should be the status labels - e.g. Scheduled, Completed, etc.)

Change this line in the code section shown in my previous post:

          $rows[$rowNum]['class'] = "status-overdue";

to this:

          $rows[$rowNum]['class'] = "status-overdue " . $activityStatus[$row['civicrm_activity_status_id']];

and then use Firebug or view source to look at the class being assigned to your past activity rows.
Protect your investment in CiviCRM by  becoming a Member!

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: How to create reports which show overdue (scheduled) Activities in red?
September 05, 2012, 01:32:24 am
Hi Dave,

This is interesting. I put your code change into sites/all/modules/civicrm/CRM/Report/Form/Activity.php and the activityStatus came up as blank. Before the row class was this:
<tr  class="even-row status-overdue crm-report" id="crm-report_0">

And after I put in the change, it went to this:
<tr  class="even-row status-overdue  crm-report" id="crm-report_0">

Not sure why this is. When I list the option values for activities (/civicrm/admin/optionValue?gid=25&reset=1), it lists out the options.

Any thoughts?

Stuart

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: How to create reports which show overdue (scheduled) Activities in red?
September 05, 2012, 01:42:47 pm
Seems like this section of the function is not working as expected:
Code: [Select]
      if (array_key_exists('civicrm_activity_status_id', $row)) {
        if ($value = $row['civicrm_activity_status_id']) {
          $rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
          $entryFound = TRUE;
        }
      }

But then I would expect that the Activity Status column on the report would be empty or possibly have a numeric value instead of the labels. What do you see in the status column?

Maybe jump on IRC and we can add some debug statements ??
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • How to create reports which show overdue (scheduled) Activities in red?

This forum was archived on 2017-11-26.