-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIVIMUTIL-8 Version 1.3.4. New feature - Set Membership End Date to e…
…nd of the month; update README; civix upgrade. Update Settings page.
- Loading branch information
1 parent
d443c66
commit 9e67d4f
Showing
11 changed files
with
240 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use Civi\Api4\Membership; | ||
|
||
/** | ||
* Job.Specificmembershipenddate API | ||
* | ||
* Scheduled job which will bulk adjust the membership end date for all | ||
* membership, setting the end date to the end of month | ||
* | ||
* @param array $params | ||
* | ||
* @return array | ||
* API result descriptor | ||
* | ||
* @throws API_Exception | ||
* @see civicrm_api3_create_success | ||
* | ||
*/ | ||
function civicrm_api3_membershiputils_Specificmembershipenddate($params): array { | ||
try { | ||
// If this option is enabled then action, otherwise skip | ||
if ( Civi::settings()->get( 'use_specific_membership_end_date' ) ) { | ||
// Get all memberships | ||
$memberships = Membership::get() | ||
->addSelect( 'id', 'end_date' ) | ||
->addWhere( 'status_id:name', 'IN', [ | ||
'New', | ||
'Current', | ||
'Grace' | ||
] ) | ||
->execute()->getArrayCopy(); | ||
foreach ( $memberships as $membership ) { | ||
// Set a specific end date | ||
$new_end_date = date_create_from_format('Y-m-d', Civi::settings()->get('specific_membership_end_date')); | ||
|
||
// Update the membership | ||
Membership::update() | ||
->addValue( 'end_date', $new_end_date->format( 'Y-m-d' ) ) | ||
->addWhere( 'id', '=', $membership['id'] ) | ||
->execute(); | ||
} | ||
|
||
return civicrm_api3_create_success( TRUE, $params, 'membershiputils', 'Specificmembershipenddate' ); | ||
} | ||
} | ||
catch (Exception $e) { | ||
throw new CRM_Core_Exception('Error setting specific membership end date. Error: ' . $e->getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.