// else fall back to using current membership type
$dao->free();
+ // Figure out number of terms
+ $numterms = 1;
+ $lineitems = CRM_Price_BAO_LineItem::getLineItems($contributionId, 'contribution');
+ foreach ($lineitems as $lineitem) {
+ if ($membership->membership_type_id == CRM_Utils_Array::value('membership_type_id', $lineitem)) {
+ $numterms = CRM_Utils_Array::value('membership_num_terms', $lineitem);
+
+ // in case membership_num_terms comes through as null or zero
+ $numterms = $numterms >= 1 ? $numterms : 1;
+ break;
+ }
+ }
+
if ($currentMembership) {
- CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership,
- $changeToday = NULL
- );
- $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id,
- $changeToday = NULL
- );
+ CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, NULL);
+ $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, NULL, NULL, $numterms);
$dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
}
else {
- $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
+ $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, null, null, null, $numterms);
}
//get the status for membership.
pf.label as field_title,
pf.html_type,
pfv.membership_type_id,
+ pfv.membership_num_terms,
li.price_field_id,
li.participant_count,
li.price_field_value_id,
'description' => $dao->description,
'entity_id' => $entityId,
'membership_type_id' => $dao->membership_type_id,
+ 'membership_num_terms' => $dao->membership_num_terms,
);
}
return $lineItems;