本文整理汇总了PHP中CRM_Member_BAO_MembershipStatus::getMembershipStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_MembershipStatus::getMembershipStatus方法的具体用法?PHP CRM_Member_BAO_MembershipStatus::getMembershipStatus怎么用?PHP CRM_Member_BAO_MembershipStatus::getMembershipStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_MembershipStatus
的用法示例。
在下文中一共展示了CRM_Member_BAO_MembershipStatus::getMembershipStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMembershipStatus
public function testGetMembershipStatus()
{
$params = array('name' => 'pending', 'is_active' => 1);
$membershipStatus = CRM_Member_BAO_MembershipStatus::add($params);
$result = CRM_Member_BAO_MembershipStatus::getMembershipStatus($membershipStatus->id);
$this->assertEquals($result['name'], 'pending', 'Verify membership status name.');
}
示例2: getRenewalDatesForMembershipType
/**
* Calculate start date and end date for membership updates.
*
* Note that this function is called by the api for any membership update although it was
* originally written for renewal (which feels a bit fragile but hey....).
*
* @param int $membershipId
* @param $changeToday
* @param int $membershipTypeID
* If provided, overrides the membership type of the $membershipID membership.
* @param int $numRenewTerms
* How many membership terms are being added to end date (default is 1).
*
* CRM-7297 Membership Upsell - Added $membershipTypeID param to facilitate calculations of dates when membership type changes
*
* @return array
* array fo the start date, end date and join date of the membership
*/
public static function getRenewalDatesForMembershipType($membershipId, $changeToday = NULL, $membershipTypeID = NULL, $numRenewTerms = 1)
{
$params = array('id' => $membershipId);
$membershipDetails = CRM_Member_BAO_Membership::getValues($params, $values);
$membershipDetails = $membershipDetails[$membershipId];
$statusID = $membershipDetails->status_id;
$membershipDates = array();
if (!empty($membershipDetails->join_date)) {
$membershipDates['join_date'] = CRM_Utils_Date::customFormat($membershipDetails->join_date, '%Y%m%d');
}
$oldPeriodType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'membership_type_id'), 'period_type');
// CRM-7297 Membership Upsell
if (is_null($membershipTypeID)) {
$membershipTypeDetails = self::getMembershipTypeDetails($membershipDetails->membership_type_id);
} else {
$membershipTypeDetails = self::getMembershipTypeDetails($membershipTypeID);
}
$statusDetails = CRM_Member_BAO_MembershipStatus::getMembershipStatus($statusID);
if ($statusDetails['is_current_member'] == 1) {
$startDate = $membershipDetails->start_date;
// CRM=7297 Membership Upsell: we need to handle null end_date in case we are switching
// from a lifetime to a different membership type
if (is_null($membershipDetails->end_date)) {
$date = date('Y-m-d');
} else {
$date = $membershipDetails->end_date;
}
$date = explode('-', $date);
$logStartDate = date('Y-m-d', mktime(0, 0, 0, (double) $date[1], (double) ($date[2] + 1), (double) $date[0]));
$date = explode('-', $logStartDate);
$year = $date[0];
$month = $date[1];
$day = $date[2];
switch ($membershipTypeDetails['duration_unit']) {
case 'year':
//need to check if the upsell is from rolling to fixed and adjust accordingly
if ($membershipTypeDetails['period_type'] == 'fixed' && $oldPeriodType == 'rolling') {
$month = substr($membershipTypeDetails['fixed_period_start_day'], 0, strlen($membershipTypeDetails['fixed_period_start_day']) - 2);
$day = substr($membershipTypeDetails['fixed_period_start_day'], -2);
$year += 1;
} else {
$year = $year + $numRenewTerms * $membershipTypeDetails['duration_interval'];
}
break;
case 'month':
$month = $month + $numRenewTerms * $membershipTypeDetails['duration_interval'];
break;
case 'day':
$day = $day + $numRenewTerms * $membershipTypeDetails['duration_interval'];
break;
}
if ($membershipTypeDetails['duration_unit'] == 'lifetime') {
$endDate = NULL;
} else {
$endDate = date('Y-m-d', mktime(0, 0, 0, $month, $day - 1, $year));
}
$today = date('Y-m-d');
$membershipDates['today'] = CRM_Utils_Date::customFormat($today, '%Y%m%d');
$membershipDates['start_date'] = CRM_Utils_Date::customFormat($startDate, '%Y%m%d');
$membershipDates['end_date'] = CRM_Utils_Date::customFormat($endDate, '%Y%m%d');
$membershipDates['log_start_date'] = CRM_Utils_Date::customFormat($logStartDate, '%Y%m%d');
} else {
$today = date('Y-m-d');
if ($changeToday) {
$today = CRM_Utils_Date::processDate($changeToday, NULL, FALSE, 'Y-m-d');
}
// Calculate new start/end dates when join date is today
$renewalDates = self::getDatesForMembershipType($membershipTypeDetails['id'], $today, NULL, NULL, $numRenewTerms);
$membershipDates['today'] = CRM_Utils_Date::customFormat($today, '%Y%m%d');
$membershipDates['start_date'] = $renewalDates['start_date'];
$membershipDates['end_date'] = $renewalDates['end_date'];
$membershipDates['log_start_date'] = $renewalDates['start_date'];
}
if (!isset($membershipDates['join_date'])) {
$membershipDates['join_date'] = $membershipDates['start_date'];
}
return $membershipDates;
}
示例3: getRenewalDatesForMembershipType
/**
* Function to calculate start date and end date for renewal membership
*
* @param int $membershipId
*
* @return Array array fo the start date, end date and join date of the membership
* @static
*/
function getRenewalDatesForMembershipType($membershipId, $changeToday = null)
{
require_once 'CRM/Member/BAO/Membership.php';
require_once 'CRM/Member/BAO/MembershipStatus.php';
$params = array('id' => $membershipId);
$membership =& new CRM_Member_BAO_Membership();
//$membership->copyValues( $params );
$membership->id = $membershipId;
$membership->find(true);
$membershipDetails = CRM_Member_BAO_Membership::getValues($params, $values);
$statusID = $membershipDetails[$membershipId]->status_id;
$membershipTypeDetails = self::getMembershipTypeDetails($membershipDetails[$membershipId]->membership_type_id);
$statusDetails = CRM_Member_BAO_MembershipStatus::getMembershipStatus($statusID);
if ($statusDetails['is_current_member'] == 1) {
$startDate = $membershipDetails[$membershipId]->start_date;
$date = explode('-', $membershipDetails[$membershipId]->end_date);
$logStartDate = date('Y-m-d', mktime(0, 0, 0, (double) $date[1], (double) ($date[2] + 1), (double) $date[0]));
$date = explode('-', $logStartDate);
$year = $date[0];
$month = $date[1];
$day = $date[2];
switch ($membershipTypeDetails['duration_unit']) {
case 'year':
$year = $year + $membershipTypeDetails['duration_interval'];
break;
case 'month':
$month = $month + $membershipTypeDetails['duration_interval'];
break;
case 'day':
$day = $day + $membershipTypeDetails['duration_interval'];
break;
}
if ($membershipTypeDetails['duration_unit'] == 'lifetime') {
$endDate = null;
} else {
$endDate = date('Y-m-d', mktime(0, 0, 0, $month, $day - 1, $year));
}
$today = date('Y-m-d');
} else {
$today = CRM_Utils_Date::getToday($changeToday);
$rollover = false;
if ($membershipTypeDetails['period_type'] == 'rolling') {
$startDate = $logStartDate = $today;
} else {
if ($membershipTypeDetails['period_type'] == 'fixed') {
// Renewing expired membership is two step process.
// 1. Renew the start date
// 2. Renew the end date
// 1.
$date = explode('-', $membershipDetails[$membershipId]->start_date);
$yearValue = date('Y');
$startDate = $logStartDate = date('Y-m-d', mktime(0, 0, 0, (double) $date[1], (double) $date[2], $yearValue));
// before moving to the step 2, check if TODAY is in
// rollover window.
$rolloverDay = substr($membershipTypeDetails['fixed_period_rollover_day'], -2);
$rolloverMonth = substr($membershipTypeDetails['fixed_period_rollover_day'], 0, -2);
$fixedStartMonth = substr($membershipTypeDetails['fixed_period_start_day'], 0, -2);
if ($rolloverMonth - $fixedStartMonth < 0) {
$rolloverDate = date('Ymd', mktime(0, 0, 0, (double) $rolloverMonth, (double) $rolloverDay, $yearValue + 1));
} else {
$rolloverDate = date('Ymd', mktime(0, 0, 0, (double) $rolloverMonth, (double) $rolloverDay, $yearValue));
}
if (CRM_Utils_Date::isoToMysql($today) > $rolloverDate) {
$rollover = true;
}
}
}
// 2.
$date = explode('-', $startDate);
$year = (double) $date[0];
$month = (double) $date[1];
$day = (double) $date[2];
switch ($membershipTypeDetails['duration_unit']) {
case 'year':
$year = $year + $membershipTypeDetails['duration_interval'];
if ($rollover) {
$year = $year + $membershipTypeDetails['duration_interval'];
}
break;
case 'month':
$month = $month + $membershipTypeDetails['duration_interval'];
if ($rollover) {
$month = $month + $membershipTypeDetails['duration_interval'];
}
break;
case 'day':
$day = $day + $membershipTypeDetails['duration_interval'];
if ($rollover) {
$day = $day + $membershipTypeDetails['duration_interval'];
}
break;
}
//.........这里部分代码省略.........