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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Relationships, Active and Inactive Status, and Start End dates
Pages: [1]

Author Topic: Relationships, Active and Inactive Status, and Start End dates  (Read 4376 times)

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Relationships, Active and Inactive Status, and Start End dates
August 28, 2011, 08:32:25 pm
Hi - scenario is that we want a Smart Group to include people who have a Relationship whenever the 'current' date is between the Start and End date.

Seems like this isn't as obvious as I expected. Am I missing something.

When I set Smart Group to be 'Relationship is Active' I get everyone in the group who has a future Start Date.

If someone is in Smart Group and their End Date passes by then they drop out - so that works as expected.

Does this just seem like it is something that wasn't accounted for when built - ie that the 'relationship is active' should fall between the Start / End date because the scenario of putting in future relationship hadn't been considered?

The language on the Relationships Tab says

Inactive Relationships
These relationships are Disabled OR have a past End Date.

I think this should be 'Disabled or have a future Start Date or a past End Date' if we can get the code sorted.

Happy to work on the code esp if it seems like a simple tweak and one that would be considered for core.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

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: Relationships, Active and Inactive Status, and Start End dates
August 28, 2011, 11:19:58 pm

pretty sure that scenario was not considered when we did relationships

if you can check th code and see where we do the end date check and patch that would be great

note that we should allow the possibility of a null start date and/or a null end date (in which case the dates are ignored)

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

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Relationships, Active and Inactive Status, and Start End dates
August 28, 2011, 11:21:56 pm
happy to do the above but it needs Eileen who may think she has better things to do right now  ;D
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Relationships, Active and Inactive Status, and Start End dates
October 06, 2011, 03:00:43 pm
http://issues.civicrm.org/jira/browse/CRM-8997
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

jaymcgraw

  • I post occasionally
  • **
  • Posts: 106
  • Karma: 6
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.92-community
  • PHP version: 5.2.11
Re: Relationships, Active and Inactive Status, and Start End dates
October 24, 2011, 02:52:51 pm
I noticed this as well and support this change. IMO, relationships with future start dates should not be considered active. Also, it would be nice to include the capability to search by relationship start/end dates similar to that of searching by member start dates. Thanks!

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Re: Relationships, Active and Inactive Status, and Start End dates
November 15, 2012, 02:04:00 am
I implemented the patch i CRM-8997 but did not see any effect in contact relationship tab. So I did some changes in link_to_original_code/CRM/Contact/BAO/Relationship.php:

static function makeURLClause( $contactId, $status, $numRelationship, $count, $relationshipId, $direction )
...
       if ( $status == self::PAST ) {
            //this case for showing past relationship
            $where .= ' AND civicrm_relationship.is_active = 1 ';
            $where .= " AND civicrm_relationship.end_date < '" . $date . "'";
        } else if ( $status == self::DISABLED ) {
            // this case for showing disabled relationship
            $where .= ' AND civicrm_relationship.is_active = 0 ';
        } else if ( $status == self::CURRENT ) {
            //this case for showing current relationship
            $where .= ' AND civicrm_relationship.is_active = 1 ';
            $where .= " AND (civicrm_relationship.end_date >= '" . $date . "' OR civicrm_relationship.end_date IS NULL) ";
+          $where .= " AND (civicrm_relationship.start_date < '" . $date . "' OR civicrm_relationship.start_date IS NULL) ";
        } else if ( $status == self::INACTIVE ) {
            //this case for showing inactive relationships
            $where .= " AND (civicrm_relationship.end_date < '" . $date . "'";
+          $where .= " OR civicrm_relationship.start_date > '" . $date . "'";
            $where .= ' OR civicrm_relationship.is_active = 0 )';
        }

And also the inherited memberships also stands as valid regardless of the start date (as long as the relationship is set to active). What exactly did the patch for CRM-8997 do?

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: Relationships, Active and Inactive Status, and Start End dates
November 15, 2012, 06:38:36 am

I've been adding a few scheduled jobs to 4.3 recently and this seems to be yet another good candidate

I think having a job that de-activates all relationsips that have not yet started or have ended would simplify a fair bit of the code within PHP, i..e we only search for active / inactive relationships and ignore dates since that is handled by the scheduled job

thoughts? If u'll think this is a good idea, who's up for contributing a patch?

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

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Re: Relationships, Active and Inactive Status, and Start End dates
November 15, 2012, 07:32:14 am
That's a good idea, Lobo!

A thing that comes to my mind is the membership status. It seems like for inherited membership the status, start and end dates (maybe all of it) is always the same as the primary membership. But for the inherited membership it would be better/more clearer if this was the same as the corresponding relationship values. E.g.
  * create a inherited membership when the relationship is created/activated
  * always keep membership start and end date in sync with the corresponding relationship fields (and that means the membership status would be right as well)
  * only delete inherited membership when either relationship is deactivated/deleted or primary membership is deleted
Of course this above cannot be has to be checked with the primary membership (the start date of a inherited membership cannot be earlier than the primary membership and so on...).

This way the memberships details is more correct IMO because the inherited membership was not started/ended until the relationship was started/ended. I am now trying to think as my client (CiviCRM user) not as a myself (system architect/developer)  :) What do you think?

I run bin/UpdateMembershipRecord.php on a daily basis in cron to update memberships status (based on status rules). So for me this script feels like a natural candidate for the job if this above should be true. But I run 4.07 so I guess I may already be a bit old-fashioned...

// Jonas

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Relationships, Active and Inactive Status, and Start End dates
October 29, 2013, 03:38:06 am
I know this is resurrecting an old thread, sorry, but this problem hit me today, and I wondered if anything had been done about fixing it, or if some decision had been made not to implement the cron job approach lobo outlined in his comment?  I can't conceive of a situation where you'd want a relationship that has ended to still show up as active.

I have an API call that searches for a relationship, including an "is_active = 1" filter, and it is returning multiple results even though the contact's relationship tab shows they have only one active relationship. I think it is counter-intuitive to show a relationship in the GUI as inactive because the end date is passed, but then leave the is_active flag set to be active, isn't it?

If setting an end date in the past cannot automatically result in is_active being set to 0 at the time the relationship is re-saved, I'd vote for a scheduled job to run hourly to tidy this up.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Relationships, Active and Inactive Status, and Start End dates
October 29, 2013, 06:07:00 am
Hi,

There is a cronjob called "Disable expired relationships". Do you run it daily?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Relationships, Active and Inactive Status, and Start End dates
October 29, 2013, 06:45:13 am
Thanks for pointing that out, Xavier.

Our production system is still v4.2.4, so that scheduled job isn't available. But I see from our test system that it exists in 4.4.0 and maybe earlier, so once I have a plan for dealing with the word replacement issue (or once 4.4.1 is released) I will get the benefit of it.

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Re: Relationships, Active and Inactive Status, and Start End dates
November 28, 2013, 05:39:39 am
Hi again!

I have had my own patch (described above at 15 nov 2012) and it works well for searching and showing relationships as active/inactive correctly according to start/end dates. But still the membership dates is not showed correctly. And I guess they will not be correct even if I would upgrade and start running the new job?

The membership date and status should not be inherited from the primary contact at least not showed on the related contacts membership tab as they are not correct. The inherited membership should have same dates as the relationship, shouldn't it? A inherited membership can't start before the relationships were created/activated and can't be active after the relationship end date, correct?

My client wants to register relationships in advance with start dates in the future. But when they do an active membership turns up with start date several years back (because primary member have been member for several years). This is very misleading!

If I have understood this correctly a new record in civicrm_membership is created with the field owner_membership_id set to the primary member's contact id. So I guess there is nothing keeping us from setting different start and end dates for the inherited memberships as they have it's own record? And then the update_membership_status job can do it's thing and set the correct status.

Could it be a good idea to change the code that creates inherited memberships to register relationships creation/start date and either relationship or primary membership end date (whichever is the earliest) into the inherited membership record?

// Jonas

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Relationships, Active and Inactive Status, and Start End dates
November 28, 2013, 12:22:45 pm
Quote
There is a cronjob called "Disable expired relationships". Do you run it daily?

I think that cron is available in the LTS versions of 4.2 - although it may not be added to the DB & you may have to do that (possible via the UI)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Relationships, Active and Inactive Status, and Start End dates

This forum was archived on 2017-11-26.