* Reference to the array.
* containing all values of
* the current membership
- * @param string $changeToday
+ * @param string|null $changeToday
* In case today needs
* to be customised, null otherwise
*
* @throws \CRM_Core_Exception
*/
- public static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday) {
+ public static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday = NULL) {
$today = 'now';
if ($changeToday) {
$today = CRM_Utils_Date::processDate($changeToday, NULL, FALSE, 'Y-m-d');
throw new CRM_Core_Exception(ts('Oops, it looks like there is no valid membership status corresponding to the membership start and end dates for this membership. Contact the site administrator for assistance.'));
}
- $currentMembership['today_date'] = $today;
-
if ($status['id'] !== $currentMembership['status_id']) {
$oldStatus = $currentMembership['status_id'];
$memberDAO = new CRM_Member_DAO_Membership();
$currentMembership['end_date'],
$format
),
- 'modified_date' => CRM_Utils_Date::customFormat(
- $currentMembership['today_date'],
- $format
- ),
+ 'modified_date' => date('Y-m-d H:i:s', strtotime($today)),
'membership_type_id' => $currentMembership['membership_type_id'],
'max_related' => $currentMembership['max_related'] ?? 0,
];
$this->assign('formClass', 'membershiprenew');
parent::preProcess();
- $this->assign('endDate', CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership',
- $this->_id, 'end_date'
- )
- ));
+ // @todo - we should store this as a property & re-use in setDefaults - for now that's a bigger change.
+ $currentMembership = civicrm_api3('Membership', 'getsingle', ['id' => $this->_id]);
+ CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership);
+
+ $this->assign('endDate', $currentMembership['end_date']);
$this->assign('membershipStatus',
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus',
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership',
return CRM_Member_BAO_Membership::create($memParams);
}
- // Check and fix the membership if it is STALE
- CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
-
$isMembershipCurrent = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $currentMembership['status_id'], 'is_current_member');
// CRM-7297 Membership Upsell - calculate dates based on new membership type
</tr>
<tr class="crm-member-membershiprenew-form-block-end_date">
<td class="label">{ts}Membership End Date{/ts}</td>
- <td class="html-adjust"> {$endDate}</td>
+ <td class="html-adjust"> {$endDate|crmDate}</td>
</tr>
<tr class="crm-member-membershiprenew-form-block-renewal_date">
<td class="label">{$form.renewal_date.label}</td>