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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Allowing for batch updates of membership status
Pages: [1]

Author Topic: Allowing for batch updates of membership status  (Read 2428 times)

illmasterc

  • Guest
Allowing for batch updates of membership status
May 10, 2010, 01:33:03 pm
Per the request of a client, I wanted a way to bulk update member statuses (for the purpose of setting a large group as inactive).  Updating membership fields in a batch process is done through profiles.  The problem is, without touching the core code, the only membership fields that are exposed in profiles are member id and source.

Allowing for batch updating required editing 3 core files:

--- sites/all/modules/civicrm/CRM/UF/Form/Field.php   (revision 8059)
+++ sites/all/modules/civicrm/CRM/UF/Form/Field.php   (working copy)
@@ -333,7 +333,7 @@
             unset( $membershipFields['membership_end_date'] );
             unset( $membershipFields['member_is_test'] );
             unset( $membershipFields['is_override'] );
-            unset( $membershipFields['status_id'] );
+            //unset( $membershipFields['status_id'] );
             unset( $membershipFields['member_is_pay_later'] );
             $fields['Membership'] =& $membershipFields;
         }

EXPLANATION: Commenting out this unset above allowed for the "status_id" field to be selectable in a membership profile.

--- sites/all/modules/civicrm/CRM/Core/BAO/UFGroup.php   (revision 8059)
+++ sites/all/modules/civicrm/CRM/Core/BAO/UFGroup.php   (working copy)
@@ -1402,7 +1402,7 @@
                        array(''=>ts( '- select -' )) + CRM_Member_PseudoConstant::membershipType( ), $required );           
         } else if ($field['name'] == 'status_id' ) {
             require_once 'CRM/Member/PseudoConstant.php';
-            $form->add('select', 'status_id', $title,
+            $form->add('select', $name, $title,
                        array(''=>ts( '- select -' )) + CRM_Member_PseudoConstant::membershipStatus( ), $required );
         } else if ( $fieldName === 'gender' ) { 
             $genderOptions = array( );   
Index: sites/all/modules/civicrm/CRM/Member/Form/Task/Batch.php

EXPLANATION: The reason for modifying the file above was to properly use the "$name" variable instead of just static "status_id".  The name variable included the member_id in it, and after the modification was then recognized properly by the template file for each member.

===================================================================
--- sites/all/modules/civicrm/CRM/Member/Form/Task/Batch.php   (revision 8059)
+++ sites/all/modules/civicrm/CRM/Member/Form/Task/Batch.php   (working copy)
@@ -223,7 +223,7 @@
                 $membership->id = CRM_Utils_Array::value( 'membership', $ids );
                 $membership->find(true);
                 $membership->free();
-                $value['status_id'] = $membership->status_id;
+                //$value['status_id'] = $membership->status_id;
                 
                 if ( empty( $customFields ) ) {
                     // membership type custom data
Index: sites/all/modules/civicrm/CRM/UF/Form/Field.php
===================================================================

EXPLANATION: The reason for this final modification above was that when submitting the form, whatever value was submitted for status_id was being overridden by the commented out line above.  Basically it would just take the status_id the member currently had and use that value instead of whatever was set in the form upon submission. 

After these edits, it is working properly.  I have not extensively tested how these edits will affect other batch operations, and I'm not 100% sure this is the best way to have gone about this, I'm just listening to Lobo and posting in the forums ;)
-
 Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allowing for batch updates of membership status
May 11, 2010, 10:36:47 am
Per my IRC chat w/ Chris on this:

if civicrm_membership.is_override is NOT set to false - then any statuses your client sets via batch update
[1:44pm] dgg: will be over-ridden next time UpdateMembershipStatus is irun
[1:45pm] dgg: since membership statuses are set programmatically based on your membership status rules UNLESS is_override = TRUE
[1:46pm] isovera: okay, so on that form, I should also have it set is_override = TRUE anytime they do that?
[1:46pm] dgg: well, i guess a couple of approaches - depending on use cases
[1:47pm] dgg: if the assumption is that they want the status change to be permanent - then maybe you should automagically set is_override if they change status for a row
[1:48pm] dgg: however, might be cleaner and better to allow the is_override field to ALSO be set in the batch update (i.e. it's another profile field)
[1:49pm] isovera: right, gotcha
[1:49pm] dgg: i think there's some drawbacks to either approach (from a 'user confusion' point of view).
[1:50pm] dgg: seems like you'd want to warn the admin if they included status in the profile and didn't include is_override
Protect your investment in CiviCRM by  becoming a Member!

bmw

  • I post occasionally
  • **
  • Posts: 103
  • Karma: 4
    • Alcohol Justice - The Industry Watchdog
  • CiviCRM version: 4.5.8
  • CMS version: Joomla! 3.4.0
  • MySQL version: 5.5.42-cli
  • PHP version: 5.3.27
Re: Allowing for batch updates of membership status
July 15, 2010, 02:58:32 pm
Dave,
I don't understand why these fields are not available for Admins to be able to use for adjusting Membership status and types. Was there some philosophy around not making them available? I don't see it as a special use but a regular function.

In my case, client wants all new and current members to be only flagged as "Current". There is no way to adjust except manually and individually if the fields are not made available for Admin use.

Thanks,
Bruce
Bruce Wolfe, M.S.W., CIO
Alcohol Justice, 501(c)3

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allowing for batch updates of membership status
July 16, 2010, 07:09:20 am
Bruce - The discussion above was specifically related to the Batch Update task (where an admin updates a set of membership records). Out-of-the-box functionality allows admins to modify the "Membership Status Rules" to change how membership statuses are assigned during the default "automatic status assignment".

In your case, you can modify the status rules for "Current" status so that status applies to all current memberships (i.e. status start date = membership start date) and disable the "New" status rule.

In addition, admins can "override" the automatic status assignment for any specific membership when editing or editing a membership for a contact by checking the Override checkbox and assigning a status. Override statuses are "fixed" - i.e. they wont' be changed by the UpdateMembershipRecord.php script. However they can be modified manually from the edit membership screen.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Allowing for batch updates of membership status

This forum was archived on 2017-11-26.