本文整理汇总了PHP中CRM_Member_DAO_Membership::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_Membership::fetch方法的具体用法?PHP CRM_Member_DAO_Membership::fetch怎么用?PHP CRM_Member_DAO_Membership::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_DAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_DAO_Membership::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listMemberships
/**
* Function to list memberships for the UF user
*
* return null
* @access public
*/
function listMemberships()
{
$membership = array();
require_once "CRM/Member/BAO/Membership.php";
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
$dao->find();
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeVaues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])) {
$membership[$dao->id]['active'] = true;
}
$membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
}
示例2: listMemberships
/**
* Function to list memberships for the UF user
*
* return null
* @access public
*/
function listMemberships()
{
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
$dao->find();
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (!empty($statusANDType[$dao->id]['is_current_member'])) {
$membership[$dao->id]['active'] = TRUE;
}
$membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
if (!$membership[$dao->id]['renewPageId']) {
// Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings
$defaultRenewPageId = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME, 'default_renewal_contribution_page');
if ($defaultRenewPageId) {
$membership[$dao->id]['renewPageId'] = $defaultRenewPageId;
}
}
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
}
示例3: listMemberships
/**
* List memberships for the UF user.
*
*/
public function listMemberships()
{
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
$dao->find();
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (!empty($statusANDType[$dao->id]['is_current_member'])) {
$membership[$dao->id]['active'] = TRUE;
}
$membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
if (!$membership[$dao->id]['renewPageId']) {
// Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings
$defaultRenewPageId = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME, 'default_renewal_contribution_page');
if ($defaultRenewPageId) {
//CRM-14831 - check if membership type is present in contrib page
$memBlock = CRM_Member_BAO_Membership::getMembershipBlock($defaultRenewPageId);
if (!empty($memBlock['membership_types'])) {
$memTypes = explode(',', $memBlock['membership_types']);
if (in_array($dao->membership_type_id, $memTypes)) {
$membership[$dao->id]['renewPageId'] = $defaultRenewPageId;
}
}
} else {
switch ($membership[$dao->id]['membership_type_id']) {
case "1":
default:
$membership[$dao->id]['renewPageId'] = 2;
break;
case "10":
$membership[$dao->id]['renewPageId'] = 19;
break;
case "11":
$membership[$dao->id]['renewPageId'] = 23;
break;
case "5":
case "9":
$membership[$dao->id]['renewPageId'] = 22;
break;
}
}
}
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
}
示例4: getAllContactMembership
/**
* Returns the membership types for a particular contact
* who has lifetime membership without end date.
*
* @param int $contactID
* @param bool $isTest
* @param bool $onlyLifeTime
*
* @return array
*/
public static function getAllContactMembership($contactID, $isTest = FALSE, $onlyLifeTime = FALSE)
{
$contactMembershipType = array();
if (!$contactID) {
return $contactMembershipType;
}
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactID;
$pendingStatusId = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
$dao->whereAdd("status_id != {$pendingStatusId}");
if ($isTest) {
$dao->is_test = $isTest;
} else {
$dao->whereAdd('is_test IS NULL OR is_test = 0');
}
if ($onlyLifeTime) {
$dao->whereAdd('end_date IS NULL');
}
$dao->find();
while ($dao->fetch()) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$contactMembershipType[$dao->membership_type_id] = $membership;
}
return $contactMembershipType;
}
示例5: updateMembershipStatus
/**
* Update membership status to deceased.
* function return the status message for updated membership.
*
* @param array $deceasedParams
* having contact id and deceased value.
*
* @return null|string
* $updateMembershipMsg string status message for updated membership.
*/
public function updateMembershipStatus($deceasedParams)
{
$updateMembershipMsg = NULL;
$contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
$deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
// process to set membership status to deceased for both active/inactive membership
if ($contactId && $this->_contactType == 'Individual' && !empty($deceasedParams['is_deceased'])) {
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
if (!$userId) {
$userId = $contactId;
}
// get deceased status id
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
if (!$deceasedStatusId) {
return $updateMembershipMsg;
}
$today = time();
if ($deceasedDate && strtotime($deceasedDate) > $today) {
return $updateMembershipMsg;
}
// get non deceased membership
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactId;
$dao->whereAdd("status_id != {$deceasedStatusId}");
$dao->find();
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$memCount = 0;
while ($dao->fetch()) {
// update status to deceased (for both active/inactive membership )
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->id, 'status_id', $deceasedStatusId);
// add membership log
$membershipLog = array('membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'modified_id' => $userId, 'modified_date' => date('Ymd'), 'membership_type_id' => $dao->membership_type_id, 'max_related' => $dao->max_related);
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//create activity when membership status is changed
$activityParam = array('subject' => "Status changed from {$allStatus[$dao->status_id]} to {$allStatus[$deceasedStatusId]}", 'source_contact_id' => $userId, 'target_contact_id' => $dao->contact_id, 'source_record_id' => $dao->id, 'activity_type_id' => array_search('Change Membership Status', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
$activityResult = civicrm_api('activity', 'create', $activityParam);
$memCount++;
}
// set status msg
if ($memCount) {
$updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", array(1 => $memCount));
}
}
return $updateMembershipMsg;
}
示例6: addMembershipLog
private function addMembershipLog()
{
$membership = new CRM_Member_DAO_Membership();
$membership->query("SELECT id FROM civicrm_membership");
while ($membership->fetch()) {
$ids[] = $membership->id;
}
foreach ($ids as $id) {
$membership = new CRM_Member_DAO_Membership();
$membership->id = $id;
$membershipLog = new CRM_Member_DAO_MembershipLog();
if ($membership->find(TRUE)) {
$membershipLog->membership_id = $membership->id;
$membershipLog->status_id = $membership->status_id;
$membershipLog->start_date = self::repairDate($membership->start_date);
$membershipLog->end_date = self::repairDate($membership->end_date);
$membershipLog->modified_id = $membership->contact_id;
$membershipLog->modified_date = date("Ymd");
$membershipLog->membership_type_id = $membership->membership_type_id;
$membershipLog->save();
}
$membershipLog = NULL;
}
}
示例7: updateRelatedMemberships
/**
* Function to updated related memberships
*
* @param int $ownerMembershipId owner Membership Id
* @param array $params formatted array of key => value..
* @static
*/
static function updateRelatedMemberships($ownerMembershipId, $params)
{
$membership = new CRM_Member_DAO_Membership();
$membership->owner_membership_id = $ownerMembershipId;
$membership->find();
while ($membership->fetch()) {
$relatedMembership = new CRM_Member_DAO_Membership();
$relatedMembership->id = $membership->id;
$relatedMembership->copyValues($params);
$relatedMembership->save();
$relatedMembership->free();
}
$membership->free();
}
示例8: addMembershipToRealtedContacts
/**
* Added for CRM-12695
* Based on the contactID provided
* add/update membership(s) to related contacts
*
* @param int $contactID
*/
public static function addMembershipToRealtedContacts($contactID)
{
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactID;
$dao->is_test = 0;
$dao->find();
//checks membership of contact itself
while ($dao->fetch()) {
$relationshipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $dao->membership_type_id, 'relationship_type_id', 'id');
if ($relationshipTypeId) {
$membershipParams = array('id' => $dao->id, 'contact_id' => $dao->contact_id, 'membership_type_id' => $dao->membership_type_id, 'join_date' => CRM_Utils_Date::isoToMysql($dao->join_date), 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'source' => $dao->source, 'status_id' => $dao->status_id);
// create/update membership(s) for related contact(s)
CRM_Member_BAO_Membership::createRelatedMemberships($membershipParams, $dao);
}
// end of if relationshipTypeId
}
}
示例9: browse
/**
* This function is called when action is browse
*
* return null
* @access public
*/
function browse()
{
$links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
//$dao->orderBy('name');
$dao->find();
//CRM--4418, check for view, edit, delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit memberships')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviMember')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// get deceased status id
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
//checks membership of contact itself
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//carry campaign.
$membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])) {
$membership[$dao->id]['active'] = TRUE;
}
if (empty($dao->owner_membership_id)) {
// unset renew and followup link for deceased membership
$currentMask = $mask;
if ($dao->status_id == $deceasedStatusId) {
$currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
}
$isUpdateBilling = false;
$paymentObject = CRM_Core_BAO_PaymentProcessor::getProcessorForEntity($membership[$dao->id]['membership_id'], 'membership', 'obj');
if (!empty($paymentObject)) {
$isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
}
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('all', NULL, NULL, $isCancelSupported, $isUpdateBilling), $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId));
} else {
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('view'), $mask, array('id' => $dao->id, 'cid' => $this->_contactId));
}
//does membership have auto renew CRM-7137.
if (CRM_Utils_Array::value('contribution_recur_id', $membership[$dao->id]) && !CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])) {
$membership[$dao->id]['auto_renew'] = 1;
} else {
$membership[$dao->id]['auto_renew'] = 0;
}
}
//Below code gives list of all Membership Types associated
//with an Organization(CRM-2016)
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($this->_contactId);
foreach ($membershipTypes as $key => $value) {
$membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, array('id' => $value['id'], 'cid' => $this->_contactId));
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
$this->assign('membershipTypes', $membershipTypes);
if ($this->_contactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
}
}
示例10: browse
/**
* called when action is browse.
*/
public function browse()
{
$links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
//$dao->orderBy('name');
$dao->find();
//CRM--4418, check for view, edit, delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit memberships')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviMember')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// get deceased status id
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
//checks membership of contact itself
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//carry campaign.
$membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (!empty($statusANDType[$dao->id]['is_current_member'])) {
$membership[$dao->id]['active'] = TRUE;
}
if (empty($dao->owner_membership_id)) {
// unset renew and followup link for deceased membership
$currentMask = $mask;
if ($dao->status_id == $deceasedStatusId) {
$currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
}
$isUpdateBilling = FALSE;
$paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($membership[$dao->id]['membership_id'], 'membership', 'obj');
if (!empty($paymentObject)) {
$isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
}
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('all', NULL, NULL, $isCancelSupported, $isUpdateBilling), $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'membership.tab.row', 'Membership', $dao->id);
} else {
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('view'), $mask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'membership.tab.row', 'Membership', $dao->id);
}
//does membership have auto renew CRM-7137.
if (!empty($membership[$dao->id]['contribution_recur_id']) && !CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])) {
$membership[$dao->id]['auto_renew'] = 1;
} else {
$membership[$dao->id]['auto_renew'] = 0;
}
// if relevant, count related memberships
if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id]) && CRM_Utils_Array::value('relationship_type_id', $statusANDType[$dao->id]) && empty($dao->owner_membership_id)) {
// not an related membership
$query = "\n SELECT COUNT(m.id)\n FROM civicrm_membership m\n LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id\n LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id\n WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0";
$num_related = CRM_Core_DAO::singleValueQuery($query);
$max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]);
$membership[$dao->id]['related_count'] = $max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array(1 => $num_related, 2 => $max_related));
} else {
$membership[$dao->id]['related_count'] = ts('N/A');
}
}
//Below code gives list of all Membership Types associated
//with an Organization(CRM-2016)
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($this->_contactId);
foreach ($membershipTypes as $key => $value) {
$membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, array('id' => $value['id'], 'cid' => $this->_contactId), ts('more'), FALSE, 'membershipType.organization.action', 'MembershipType', $value['id']);
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
$this->assign('membershipTypes', $membershipTypes);
if ($this->_contactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
// Refresh other tabs with related data
$this->ajaxResponse['updateTabs'] = array('#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId));
if (CRM_Core_Permission::access('CiviContribute')) {
$this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
}
}
}
示例11: joinrenew_pricesetmap_beforeRelationshipCreate
/**
* Implementation of hook_pricesetmap_beforeRelationshipCreate
*
* @param $formName - Name of the form being validated, you will typically use this to do different things for different forms.
* @param $form - The form object passed into postProcess and then to use
* @param $relationship - The params for the relationship that is about to be created.
*/
function joinrenew_pricesetmap_beforeRelationshipCreate($formName, &$form, &$relationship)
{
if ($formName == "CRM_Contribute_Form_Contribution_Confirm" && $form->getVar("_id") == JOINRENEW_PAGE_ID) {
$relationship['start_date'] = substr($relationship['end_date'], 0, 4) . "-01-01";
}
if ($formName == "CRM_Contribute_Form_Contribution_Confirm" && ($form->getVar("_id") == FAMILYMEMBERSHIP_PAGE_ID || $form->getVar("_id") == JOINRENEW_PAGE_ID)) {
//We know this is a Section because it is being sent in from PriceSetMap,
//for the Auxiliary Family Member, so find the membership and set the start
//and end date to match the membership
$contactID = $form->getVar("_contactID");
$result = civicrm_api3('MembershipType', 'get', array('sequential' => 1, 'return' => "id,name", 'relationship_type_id' => array('<>' => ""), 'is_active' => 1));
if ($result['is_error'] == 0 && $result['count'] > 0) {
$FamilyMembershipTypes = array();
foreach ($result['values'] as $type) {
$FamilyMembershipTypes[$type['id']] = $type;
}
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactID;
$dao->is_test = 0;
$dao->find();
$good_statuses = array(1, 2, 3, 8);
while ($dao->fetch()) {
if (array_key_exists($dao->membership_type_id, $FamilyMembershipTypes) && in_array($dao->status_id, $good_statuses)) {
$year = substr($dao->end_date, 0, 4);
$relationship['start_date'] = $year . "-01-01";
$relationship['end_date'] = $year . "-12-31";
}
}
}
}
}
示例12: browse
/**
* This function is called when action is browse
*
* return null
* @access public
*/
function browse()
{
$links =& self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
$membership = array();
require_once 'CRM/Member/DAO/Membership.php';
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
//$dao->orderBy('name');
$dao->find();
//CRM--4418, check for view, edit, delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit memberships')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviMember')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// get deceased status id
require_once 'CRM/Member/PseudoConstant.php';
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
//checks membership of contact itself
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeVaues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])) {
$membership[$dao->id]['active'] = true;
}
if (!$dao->owner_membership_id) {
// unset renew and followup link for deceased membership
$currentMask = $mask;
if ($dao->status_id == $deceasedStatusId) {
$currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
}
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('all', null, null, $isCancelSupported), $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId));
} else {
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('view'), $mask, array('id' => $dao->id, 'cid' => $this->_contactId));
}
//does membership is auto renew CRM-7137.
if ($isCancelSupported) {
$membership[$dao->id]['auto_renew'] = CRM_Utils_Array::value('contribution_recur_id', $membership[$dao->id]);
}
}
//Below code gives list of all Membership Types associated
//with an Organization(CRM-2016)
include_once 'CRM/Member/BAO/MembershipType.php';
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($this->_contactId);
foreach ($membershipTypes as $key => $value) {
$membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, array('id' => $value['id'], 'cid' => $this->_contactId));
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
$this->assign('membershipTypes', $membershipTypes);
if ($this->_contactId) {
require_once 'CRM/Contact/BAO/Contact.php';
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
}
}
示例13: addMembershipLog
function addMembershipLog()
{
$membership = new CRM_Member_DAO_Membership();
$membership->query("SELECT id FROM civicrm_membership");
while ($membership->fetch()) {
$ids[] = $membership->id;
}
require_once 'CRM/Member/DAO/MembershipLog.php';
foreach ($ids as $id) {
$membership = new CRM_Member_DAO_Membership();
$membership->id = $id;
$membershipLog = new CRM_Member_DAO_MembershipLog();
if ($membership->find(true)) {
$membershipLog->membership_id = $membership->id;
$membershipLog->status_id = $membership->status_id;
$membershipLog->start_date = self::repairDate($membership->start_date);
$membershipLog->end_date = self::repairDate($membership->end_date);
$membershipLog->modified_id = $membership->contact_id;
$membershipLog->modified_date = date("Ymd");
$membershipLog->save();
}
$membershipLog = null;
}
}
示例14: getMembershipsForContact
private function getMembershipsForContact($contact_id)
{
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contact_id;
$dao->whereAdd('is_test IS NULL OR is_test = 0');
// order by start date to find most recent membership first, CRM-4545
$dao->orderBy('start_date DESC');
$dao->find(false);
$memberships = array();
while ($dao->fetch()) {
$startDate = new DateTime($dao->start_date);
$endDate = new DateTime($dao->end_date);
$memberships[$dao->id] = CRM_Member_PseudoConstant::membershipType($dao->membership_type_id) . ': ' . CRM_Member_PseudoConstant::membershipStatus($dao->status_id, null, 'label') . ' (' . $startDate->format('d-m-Y') . ' - ' . $endDate->format('d-m-Y') . ')';
}
return $memberships;
}
示例15: updateMembershipStatus
function updateMembershipStatus($deceasedParams)
{
$updateMembershipMsg = null;
$contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
$deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
// process to set membership status to deceased for both active/inactive membership
if ($contactId && $this->_contactType == 'Individual' && CRM_Utils_Array::value('is_deceased', $deceasedParams)) {
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
if (!$userId) {
$userId = $contactId;
}
require_once 'CRM/Member/BAO/MembershipLog.php';
require_once 'CRM/Member/DAO/Membership.php';
require_once 'CRM/Member/PseudoConstant.php';
require_once 'CRM/Utils/Date.php';
// get deceased status id
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
if (!$deceasedStatusId) {
return $updateMembershipMsg;
}
$today = time();
if ($deceasedDate && strtotime($deceasedDate) > $today) {
return $updateMembershipMsg;
}
// get non deceased membership
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $contactId;
$dao->whereAdd("status_id != {$deceasedStatusId}");
$dao->find();
$memCount = 0;
while ($dao->fetch()) {
// update status to deceased (for both active/inactive membership )
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->id, 'status_id', $deceasedStatusId);
// add membership log
$membershipLog = array('membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'renewal_reminder_date' => CRM_Utils_Date::isoToMysql($dao->reminder_date), 'modified_id' => $userId, 'modified_date' => date('Ymd'));
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
$memCount++;
}
// set status msg
if ($memCount) {
$updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", array(1 => $memCount));
}
}
return $updateMembershipMsg;
}