本文整理汇总了PHP中CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes方法的具体用法?PHP CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes怎么用?PHP CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Financial_BAO_FinancialType
的用法示例。
在下文中一共展示了CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* called when action is browse.
*/
public function browse()
{
$links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
$addWhere = "membership_type_id IN (0)";
if (!empty($membershipTypes)) {
$addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
}
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
$dao->whereAdd($addWhere);
//$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;
// It would be better to determine if there is a recurring contribution &
// is so get the entity for the recurring contribution (& skip if not).
$paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($membership[$dao->id]['membership_id'], 'membership', 'obj');
if (!empty($paymentObject)) {
// @todo - get this working with syntax style $paymentObject->supports(array
//('updateSubscriptionBillingInfo'));
$isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
}
// @todo - get this working with syntax style $paymentObject->supports(array
//('CancelSubscriptionSupported'));
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
$links = self::links('all', NULL, NULL, $isCancelSupported, $isUpdateBilling);
self::getPermissionedLinks($dao->membership_type_id, $links);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('Renew') . '...', FALSE, 'membership.tab.row', 'Membership', $dao->id);
} else {
$links = self::links('view');
self::getPermissionedLinks($dao->membership_type_id, $links);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $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--membership is active and type allows inheritance--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);
//.........这里部分代码省略.........
示例2: getContactMembershipCount
/**
* Get membership record count for a Contact.
*
* @param int $contactID
* @param bool $activeOnly
*
* @return null|string
*/
public static function getContactMembershipCount($contactID, $activeOnly = FALSE)
{
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
$addWhere = " AND membership_type_id IN (0)";
if (!empty($membershipTypes)) {
$addWhere = " AND membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
}
$select = "SELECT count(*) FROM civicrm_membership ";
$where = "WHERE civicrm_membership.contact_id = {$contactID} AND civicrm_membership.is_test = 0 ";
// CRM-6627, all status below 3 (active, pending, grace) are considered active
if ($activeOnly) {
$select .= " INNER JOIN civicrm_membership_status ON civicrm_membership.status_id = civicrm_membership_status.id ";
$where .= " and civicrm_membership_status.is_current_member = 1";
}
$query = $select . $where . $addWhere;
return CRM_Core_DAO::singleValueQuery($query);
}
示例3: testgetAvailableMembershipTypes
/**
* Check method testgetAvailableMembershipTypes()
*/
public function testgetAvailableMembershipTypes()
{
// Create Membership types
$ids = array();
$params = array('name' => 'Type One', 'domain_id' => 1, 'minimum_fee' => 10, 'duration_unit' => 'year', 'member_of_contact_id' => $this->_orgContactID, 'period_type' => 'fixed', 'duration_interval' => 1, 'financial_type_id' => 1, 'visibility' => 'Public', 'is_active' => 1);
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
// Add another
$params['name'] = 'Type Two';
$params['financial_type_id'] = 2;
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
$this->setACL();
$this->setPermissions(array('view contributions of type Donation', 'view contributions of type Member Dues'));
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
$expectedResult = array(1 => "Type One", 2 => "Type Two");
$this->assertEquals($expectedResult, $types, 'Verify that only certain membership types can be retrieved');
$this->setPermissions(array('view contributions of type Donation'));
unset($expectedResult[2]);
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
$this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available membership types');
}