本文整理汇总了PHP中CRM_Member_DAO_Membership::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_Membership::orderBy方法的具体用法?PHP CRM_Member_DAO_Membership::orderBy怎么用?PHP CRM_Member_DAO_Membership::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_DAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_DAO_Membership::orderBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getContactMembership
/**
* Return a current membership of given contact.
*
* NB: if more than one membership meets criteria, a randomly selected one is returned.
*
* @param int $contactID
* Contact id.
* @param int $memType
* Membership type, null to retrieve all types.
* @param int $isTest
* @param int $membershipId
* If provided, then determine if it is current.
* @param bool $onlySameParentOrg
* True if only Memberships with same parent org as the $memType wanted, false otherwise.
*
* @return array|bool
*/
public static function getContactMembership($contactID, $memType, $isTest, $membershipId = NULL, $onlySameParentOrg = FALSE)
{
//check for owner membership id, if it exists update that membership instead: CRM-15992
if ($membershipId) {
$ownerMemberId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'owner_membership_id', 'id');
if ($ownerMemberId) {
$membershipId = $ownerMemberId;
$contactID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'contact_id', 'id');
}
}
$dao = new CRM_Member_DAO_Membership();
if ($membershipId) {
$dao->id = $membershipId;
}
$dao->contact_id = $contactID;
$dao->membership_type_id = $memType;
//fetch proper membership record.
if ($isTest) {
$dao->is_test = $isTest;
} else {
$dao->whereAdd('is_test IS NULL OR is_test = 0');
}
//avoid pending membership as current membership: CRM-3027
$statusIds[] = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
if (!$membershipId) {
// CRM-15475
$statusIds[] = array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE));
}
$dao->whereAdd('status_id NOT IN ( ' . implode(',', $statusIds) . ')');
// order by start date to find most recent membership first, CRM-4545
$dao->orderBy('start_date DESC');
// CRM-8141
if ($onlySameParentOrg && $memType) {
// require the same parent org as the $memType
$params = array('id' => $memType);
$membershipType = array();
if (CRM_Member_BAO_MembershipType::retrieve($params, $membershipType)) {
$memberTypesSameParentOrg = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($membershipType['member_of_contact_id']);
$memberTypesSameParentOrgList = implode(',', array_keys($memberTypesSameParentOrg));
$dao->whereAdd('membership_type_id IN (' . $memberTypesSameParentOrgList . ')');
}
}
if ($dao->find(TRUE)) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
$ownerMemberId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membership['id'], 'owner_membership_id', 'id');
if ($ownerMemberId) {
$membership['id'] = $membership['membership_id'] = $ownerMemberId;
$membership['membership_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membership['id'], 'contact_id', 'id');
}
return $membership;
}
// CRM-8141
if ($onlySameParentOrg && $memType) {
// see if there is a membership that has same parent as $memType but different parent than $membershipID
if ($dao->id && CRM_Core_Permission::check('edit memberships')) {
// CRM-10016, This is probably a backend renewal, and make sure we return the same membership thats being renewed.
$dao->whereAdd();
} else {
unset($dao->id);
}
unset($dao->membership_type_id);
if ($dao->find(TRUE)) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
return $membership;
}
}
return FALSE;
}
示例3: buildMembershipBlock
//.........这里部分代码省略.........
$this->assign('membership_name', $memType['name']);
if (!$thankPage && $cid) {
$membership = new CRM_Member_DAO_Membership();
$membership->contact_id = $cid;
$membership->membership_type_id = $memType['id'];
if ($membership->find(TRUE)) {
$this->assign('renewal_mode', TRUE);
$memType['current_membership'] = $membership->end_date;
$this->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
}
}
$membershipTypes[] = $memType;
}
} elseif ($memType['is_active']) {
$javascriptMethod = NULL;
$allowAutoRenewOpt = (int) $memType['auto_renew'];
if (is_array($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $id => $val) {
if (!$val['is_recur']) {
$allowAutoRenewOpt = 0;
continue;
}
}
}
$javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );");
$autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $allowAutoRenewOpt * CRM_Utils_Array::value($value, CRM_Utils_Array::value('auto_renew', $this->_membershipBlock));
if ($allowAutoRenewOpt) {
$allowAutoRenewMembership = TRUE;
}
//add membership type.
$radio[$memType['id']] = $this->createElement('radio', NULL, NULL, NULL, $memType['id'], $javascriptMethod);
if ($cid) {
$membership = new CRM_Member_DAO_Membership();
$membership->contact_id = $cid;
$membership->membership_type_id = $memType['id'];
//show current membership, skip pending and cancelled membership records,
//because we take first membership record id for renewal
$membership->whereAdd('status_id != 5 AND status_id !=6');
if (!is_null($isTest)) {
$membership->is_test = $isTest;
}
//CRM-4297
$membership->orderBy('end_date DESC');
if ($membership->find(TRUE)) {
if (!$membership->end_date) {
unset($radio[$memType['id']]);
$this->assign('islifetime', TRUE);
continue;
}
$this->assign('renewal_mode', TRUE);
$this->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
$memType['current_membership'] = $membership->end_date;
if (!$endDate) {
$endDate = $memType['current_membership'];
$this->_defaultMemTypeId = $memType['id'];
}
if ($memType['current_membership'] < $endDate) {
$endDate = $memType['current_membership'];
$this->_defaultMemTypeId = $memType['id'];
}
}
}
$membershipTypes[] = $memType;
}
}
}
$this->assign('membershipBlock', $this->_membershipBlock);
$this->assign('showRadio', $isContributionMainPage);
$this->assign('membershipTypes', $membershipTypes);
$this->assign('allowAutoRenewMembership', $allowAutoRenewMembership);
$this->assign('autoRenewMembershipTypeOptions', json_encode($autoRenewMembershipTypeOptions));
//give preference to user submitted auto_renew value.
$takeUserSubmittedAutoRenew = !empty($_POST) || $this->isSubmitted() ? TRUE : FALSE;
$this->assign('takeUserSubmittedAutoRenew', $takeUserSubmittedAutoRenew);
if ($isContributionMainPage) {
if (!$membershipPriceset) {
if (!$this->_membershipBlock['is_required']) {
$this->assign('showRadioNoThanks', TRUE);
$radio[''] = $this->createElement('radio', NULL, NULL, NULL, 'no_thanks', NULL);
$this->addGroup($radio, 'selectMembership', NULL);
} elseif ($this->_membershipBlock['is_required'] && count($radio) == 1) {
$temp = array_keys($radio);
$this->add('hidden', 'selectMembership', $temp[0], array('id' => 'selectMembership'));
$this->assign('singleMembership', TRUE);
$this->assign('showRadio', FALSE);
} else {
$this->addGroup($radio, 'selectMembership', NULL);
}
$this->addRule('selectMembership', ts('Please select one of the memberships.'), 'required');
} else {
$autoRenewOption = CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId);
$this->assign('autoRenewOption', $autoRenewOption);
}
if (!$this->_values['is_pay_later'] && is_array($this->_paymentProcessors) && ($allowAutoRenewMembership || $autoRenewOption)) {
$this->addElement('checkbox', 'auto_renew', ts('Please renew my membership automatically.'));
}
}
}
return $separateMembershipPayment;
}
示例4: getContactMembership
/**
* Function to return current membership of given contacts
*
* @param int $contactID contact id
* @static
*/
static function getContactMembership($contactID, $memType, $isTest, $membershipId = null)
{
$dao = new CRM_Member_DAO_Membership();
if ($membershipId) {
$dao->id = $membershipId;
}
$dao->contact_id = $contactID;
$dao->membership_type_id = $memType;
//fetch proper membership record.
if ($isTest) {
$dao->is_test = $isTest;
} else {
$dao->whereAdd('is_test IS NULL OR is_test = 0');
}
//avoid pending membership as current memebrship: CRM-3027
require_once 'CRM/Member/PseudoConstant.php';
$pendingStatusId = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
$dao->whereAdd("status_id != {$pendingStatusId}");
// order by start date to find mos recent membership first, CRM-4545
$dao->orderBy('start_date DESC');
if ($dao->find(true)) {
$membership = array();
CRM_Core_DAO::storeValues($dao, $membership);
$membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
return $membership;
}
return false;
}