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 CiviEvent (Moderator: Yashodha Chaku) »
  • Events dashboard - sort by events date
Pages: [1]

Author Topic: Events dashboard - sort by events date  (Read 1546 times)

sykong

  • Guest
Events dashboard - sort by events date
October 17, 2009, 06:03:32 pm
Seems like no one has brought this up...

I have 3 events created. Currently the dashboard shows the most recently created event (which is also the event that is going to take place the latest) first, and the events that have been created earlier last.

Would it make more sense to sort it by the event start date? ie to have the event that is taking place soon display first.

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Events dashboard - sort by events date
October 18, 2009, 12:19:47 am
sykong :
To sort on the basis of end date you might want to modify the query in getEventSummary method in CRM/Event/BAO/Event.php

Here is the patch :
Code: [Select]
Index: CRM/Event/BAO/Event.php
===================================================================
--- CRM/Event/BAO/Event.php (revision 24260)
+++ CRM/Event/BAO/Event.php (working copy)
@@ -343,7 +343,7 @@
 WHERE      civicrm_event.is_active = 1 AND
            ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0)
 GROUP BY   civicrm_event.id
-ORDER BY   civicrm_event.end_date DESC
+ORDER BY   civicrm_event.start_date DESC
 LIMIT      0, 10

I recommend using Custom PHP Path Directory and custom templates to achieve the same.
For more details, refer : http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

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

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Events dashboard - sort by events date
October 18, 2009, 06:53:19 am

i think the correct sort should be:

sort by start date but only include all the events that have not yet ended

we are planning to make this fix for 3.1 or 3.2. A patch to do this would be great and guaranteed to make it into the 3.1 code base :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

sykong

  • Guest
Re: Events dashboard - sort by events date
October 18, 2009, 10:17:33 am
Quote from: Donald Lobo on October 18, 2009, 06:53:19 am
but only include all the events that have not yet ended

This makes it a bit more complicated... especially if there is a need to deal with time zones. Is there a pre-defined variable/functions to give the current date/time in the correct timezone?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Events dashboard - sort by events date
October 18, 2009, 02:44:56 pm

We dont deal with timezones (as yet), so the problem is a bit simpler. You can set the timezone in your php.ini file

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

sykong

  • Guest
Re: Events dashboard - sort by events date
October 19, 2009, 06:00:37 am
My contribution, based on what Yashoda provided

Code: [Select]
$timenow = date( "Y-m-d H:i:s", time() );
        $query = "
SELECT     civicrm_event.id as id, civicrm_event.title as event_title, civicrm_event.is_public as is_public,
           civicrm_event.max_participants as max_participants, civicrm_event.start_date as start_date,
           civicrm_event.end_date as end_date, civicrm_event.is_map as is_map, civicrm_option_value.label as event_type,
           civicrm_event.summary as summary
FROM       civicrm_event
LEFT JOIN  civicrm_option_value ON (
           civicrm_event.event_type_id = civicrm_option_value.value AND
           civicrm_option_value.option_group_id = %1 )
WHERE      civicrm_event.is_active = 1 AND
           ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0) AND
           civicrm_event.end_date >= '$timenow'
GROUP BY   civicrm_event.id
ORDER BY   civicrm_event.start_date ASC
LIMIT      0, 10
";

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Events dashboard - sort by events date
October 19, 2009, 06:27:37 pm
I've posted an issue to fix this in 3.1:
http://issues.civicrm.org/jira/browse/CRM-5254

The plan is to use start_date ASC ... AND to select events with start or end date greater than 7 days ago. (Some events don't have an end date - and we think some folks like to see summary info on recently completed events in the dashboard. )
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Events dashboard - sort by events date

This forum was archived on 2017-11-26.