本文整理汇总了PHP中CRM_Member_BAO_MembershipType::free方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_MembershipType::free方法的具体用法?PHP CRM_Member_BAO_MembershipType::free怎么用?PHP CRM_Member_BAO_MembershipType::free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_MembershipType
的用法示例。
在下文中一共展示了CRM_Member_BAO_MembershipType::free方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAllMembershipStatus
//.........这里部分代码省略.........
}
continue;
}
//we fetch related, since we need to check for deceased
//now further processing is handle w/ main membership record.
if ($dao->owner_membership_id) {
continue;
}
//update membership records where status is NOT - Pending OR Cancelled.
//as well as membership is not override.
//skipping Expired membership records -> reduced extra processing( kiran )
if (!$dao->is_override && !in_array($dao->status_id, array(array_search('Pending', $allStatus), array_search('Cancelled', $allStatus), array_search('Expired', $allStatus)))) {
// CRM-7248: added excludeIsAdmin param to the following fn call to prevent moving to admin statuses
//get the membership status as per id.
$newStatus = civicrm_api('membership_status', 'calc', array('membership_id' => $dao->membership_id, 'version' => 3, 'ignore_admin_only' => FALSE), TRUE);
$statusId = CRM_Utils_Array::value('id', $newStatus);
//process only when status change.
if ($statusId && $statusId != $dao->status_id) {
//take all params that need to save.
$memParams = $memberParams;
$memParams['status_id'] = $statusId;
$memParams['createActivity'] = TRUE;
$memParams['version'] = 3;
//since there is change in status.
$statusChange = array('status_id' => $statusId);
$smarty->append_by_ref('memberParams', $statusChange, TRUE);
//process member record.
civicrm_api('membership', 'create', $memParams);
$updateCount++;
}
}
//convert date from string format to timestamp format
$reminder_date = CRM_Utils_DATE::unixTime($dao->reminder_date);
$today_date = CRM_Utils_DATE::unixTime($today);
//send reminder for membership renewal
if ($dao->reminder_date && $dao->reminder_date != '0000-00-00' && $reminder_date <= $today_date) {
$memType = new CRM_Member_BAO_MembershipType();
$memType->id = $dao->membership_type_id;
$memType->find(TRUE);
$renewalMsgId = $memType->renewal_msg_id;
if ($memType->autorenewal_msg_id && $dao->recur_id) {
$contribStatusId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $dao->recur_id, 'contribution_status_id');
if ($contribStatusId != array_search('Cancelled', $contribStatus)) {
$renewalMsgId = $memType->autorenewal_msg_id;
}
}
if ($renewalMsgId) {
$toEmail = CRM_Contact_BAO_Contact::getPrimaryEmail($dao->contact_id);
if ($toEmail) {
$sendResult = CRM_Core_BAO_MessageTemplates::sendReminder($dao->contact_id, $toEmail, $renewalMsgId, $fromEmailAddress);
if (!$sendResult || is_a($sendResult, 'PEAR_Error')) {
// we could not send an email, for now we ignore
// CRM-3406
// at some point we might decide to do something
} else {
$reminderCount++;
}
//set membership reminder date to NULL since we've sent the reminder.
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'reminder_date', 'null');
// insert the activity log record.
$config = CRM_Core_Config::singleton();
$activityParams = array();
$activityParams['subject'] = $allTypes[$dao->membership_type_id] . ": Status - " . $statusLabels[$newStatus['id']] . ", End Date - " . CRM_Utils_Date::customFormat(CRM_Utils_Date::isoToMysql($dao->end_date), $config->dateformatFull);
$activityParams['source_record_id'] = $dao->membership_id;
$session = CRM_Core_Session::singleton();
$activityParams['source_contact_id'] = $session->get('userID') ? $session->get('userID') : $dao->contact_id;
$activityParams['assignee_contact_id'] = $dao->contact_id;
$activityParams['activity_date_time'] = date('YmdHis');
static $actRelIds = array();
if (!isset($actRelIds['activity_type_id'])) {
$actRelIds['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name');
}
$activityParams['activity_type_id'] = $actRelIds['activity_type_id'];
if (!isset($actRelIds['activity_status_id'])) {
$actRelIds['activity_status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
}
$activityParams['status_id'] = $actRelIds['activity_status_id'];
static $msgTpl = array();
if (!isset($msgTpl[$memType->renewal_msg_id])) {
$msgTpl[$memType->renewal_msg_id] = array();
$messageTemplate = new CRM_Core_DAO_MessageTemplates();
$messageTemplate->id = $memType->renewal_msg_id;
if ($messageTemplate->find(TRUE)) {
$msgTpl[$memType->renewal_msg_id]['subject'] = $messageTemplate->msg_subject;
$msgTpl[$memType->renewal_msg_id]['details'] = $messageTemplate->msg_text;
}
$messageTemplate->free();
}
$activityParams['details'] = "Subject: {$msgTpl[$memType->renewal_msg_id]['subject']}\nMessage: {$msgTpl[$memType->renewal_msg_id]['details']}\n";
$activity = CRM_Activity_BAO_Activity::create($activityParams);
}
}
$memType->free();
}
// CRM_Core_Error::debug( 'fEnd', count( $GLOBALS['_DB_DATAOBJECT']['RESULTS'] ) );
}
$result['is_error'] = 0;
$result['messages'] = ts('Processed %1 membership records. Updated %2 records. Sent %3 renewal reminders.', array(1 => $processCount, 2 => $updateCount, 3 => $reminderCount));
return $result;
}