本文整理汇总了PHP中CRM_Member_DAO_Membership类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_Membership类的具体用法?PHP CRM_Member_DAO_Membership怎么用?PHP CRM_Member_DAO_Membership使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Member_DAO_Membership类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例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: 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;
}
示例5: 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
}
}
示例6: 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);
}
}
}
示例7: 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);
}
}
示例8: _civicrm_membership_format_params
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params Associative array of property name/value
* pairs to insert in new contact.
* @param array $values The reformatted properties that we can use internally
*
* @param array $create Is the formatted Values array going to
* be used for CRM_Member_BAO_Membership:create()
*
* @return array|error
* @access public
*/
function _civicrm_membership_format_params(&$params, &$values, $create = FALSE)
{
require_once "CRM/Member/DAO/Membership.php";
require_once "CRM/Member/PseudoConstant.php";
$fields = CRM_Member_DAO_Membership::fields();
_civicrm_store_values($fields, $params, $values);
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
switch ($key) {
case 'membership_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_create_error("contact_id not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['membership_contact_id'];
unset($values['membership_contact_id']);
break;
case 'join_date':
case 'start_date':
case 'end_date':
case 'reminder_date':
case 'membership_start_date':
case 'membership_end_date':
if (!CRM_Utils_Rule::date($value)) {
return civicrm_create_error("{$key} not a valid date: {$value}");
}
// make sure we format dates to mysql friendly format
$values[$key] = CRM_Utils_Date::processDate($value, NULL, FALSE, 'Ymd');
break;
case 'membership_type_id':
if (!CRM_Utils_Array::value($value, CRM_Member_PseudoConstant::membershipType())) {
return civicrm_create_error('Invalid Membership Type Id');
}
$values[$key] = $value;
break;
case 'membership_type':
$membershipTypeId = CRM_Utils_Array::key(ucfirst($value), CRM_Member_PseudoConstant::membershipType());
if ($membershipTypeId) {
if (CRM_Utils_Array::value('membership_type_id', $values) && $membershipTypeId != $values['membership_type_id']) {
return civicrm_create_error('Mismatched membership Type and Membership Type Id');
}
} else {
return civicrm_create_error('Invalid Membership Type');
}
$values['membership_type_id'] = $membershipTypeId;
break;
case 'status_id':
if (!CRM_Utils_Array::value($value, CRM_Member_PseudoConstant::membershipStatus())) {
return civicrm_create_error('Invalid Membership Status Id');
}
$values[$key] = $value;
break;
default:
break;
}
}
_civicrm_custom_format_params($params, $values, 'Membership');
if ($create) {
// CRM_Member_BAO_Membership::create() handles membership_start_date,
// membership_end_date and membership_source. So, if $values contains
// membership_start_date, membership_end_date or membership_source,
// convert it to start_date, end_date or source
$changes = array('membership_start_date' => 'start_date', 'membership_end_date' => 'end_date', 'membership_source' => 'source');
foreach ($changes as $orgVal => $changeVal) {
if (isset($values[$orgVal])) {
$values[$changeVal] = $values[$orgVal];
unset($values[$orgVal]);
}
}
}
return NULL;
}
示例9: submit
//.........这里部分代码省略.........
// status calculation. similarly we did fix for import in CRM-3570.
if (empty($params['is_override'])) {
$params['exclude_is_admin'] = TRUE;
}
// process date params to mysql date format.
$dateTypes = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($formValues[$dateField]);
}
$memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL;
$calcDates = array();
foreach ($this->_memTypeSelected as $memType) {
if (empty($memTypeNumTerms)) {
$memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, 1);
}
$calcDates[$memType] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType, $joinDate, $startDate, $endDate, $memTypeNumTerms);
}
foreach ($calcDates as $memType => $calcDate) {
foreach (array_keys($dateTypes) as $d) {
//first give priority to form values then calDates.
$date = CRM_Utils_Array::value($d, $formValues);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$membershipTypeValues[$memType][$d] = CRM_Utils_Date::processDate($date);
}
}
// max related memberships - take from form or inherit from membership type
foreach ($this->_memTypeSelected as $memType) {
if (array_key_exists('max_related', $formValues)) {
$membershipTypeValues[$memType]['max_related'] = CRM_Utils_Array::value('max_related', $formValues);
}
$membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, 'Membership');
$membershipTypes[$memType] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memType);
}
$membershipType = implode(', ', $membershipTypes);
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails($ids['userId']);
//CRM-13981, allow different person as a soft-contributor of chosen type
if ($this->_contributorContactID != $this->_contactID) {
$params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($formValues['soft_credit_type_id'])) {
$softParams['soft_credit_type_id'] = $formValues['soft_credit_type_id'];
$softParams['contact_id'] = $this->_contactID;
}
}
if (!empty($formValues['record_contribution'])) {
$recordContribution = array('total_amount', 'financial_type_id', 'payment_instrument_id', 'trxn_id', 'contribution_status_id', 'check_number', 'campaign_id', 'receive_date');
foreach ($recordContribution as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
if (!$this->_onlinePendingContributionId) {
if (empty($formValues['source'])) {
$params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', array(1 => $membershipType, 2 => $userName));
} else {
$params['contribution_source'] = $formValues['source'];
}
}
if (empty($params['is_override']) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
$params['is_pay_later'] = 1;
$this->assign('is_pay_later', 1);
}
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = CRM_Utils_Array::value('receive_date', $formValues);
示例10: import
/**
* handle the values in import mode
*
* @param int $onDuplicate the code for what action to take on duplicates
* @param array $values the array of values belonging to this line
*
* @return boolean the result of this processing
* @access public
*/
function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Member_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
//assign join date equal to start date if join date is not provided
if (!$params['join_date'] && $params['membership_start_date']) {
$params['join_date'] = $params['membership_start_date'];
}
$session =& CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
$formatted = array();
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = true;
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'join_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
break;
case 'membership_start_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
break;
case 'membership_end_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
break;
case 'is_override':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID][2] == 'Date') {
CRM_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} else {
if ($customFields[$customFieldID][2] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
}
//date-Format part ends
static $indieFields = null;
if ($indieFields == null) {
require_once 'CRM/Member/DAO/Membership.php';
$tempIndieFields =& CRM_Member_DAO_Membership::import();
$indieFields = $tempIndieFields;
}
$formatValues = array();
foreach ($params as $key => $field) {
if ($field == null || $field === '') {
continue;
}
$formatValues[$key] = $field;
}
$formatError = _civicrm_membership_formatted_param($formatValues, $formatted, true);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
return CRM_Member_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Member_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, null, 'Membership');
} else {
//fix for CRM-2219 Update Membership
// onDuplicate == CRM_Member_Import_Parser::DUPLICATE_UPDATE
if (CRM_Utils_Array::value('is_override', $formatted) && !CRM_Utils_Array::value('status_id', $formatted)) {
array_unshift($values, "Required parameter missing: Status");
return CRM_Member_Import_Parser::ERROR;
//.........这里部分代码省略.........
示例11: 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;
}
}
示例12: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->_id) {
$pastContributionID = $session->get('pastContributionID');
if (!$pastContributionID) {
CRM_Core_Error::fatal(ts('We can\'t load the requested web page due to an incomplete link. This can be caused by using your browser\'s Back button or by using an incomplete or invalid link.'));
} else {
CRM_Core_Error::fatal(ts('This contribution has already been submitted. Click <a href=\'%1\'>here</a> if you want to make another contribution.', array(1 => CRM_Utils_System::url('civicrm/contribute/transact', 'reset=1&id=' . $pastContributionID))));
}
} else {
$session->set('pastContributionID', $this->_id);
}
$this->_userID = $session->get('userID');
$this->_mid = null;
if ($this->_userID) {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
if ($this->_mid) {
require_once 'CRM/Member/DAO/Membership.php';
$membership = new CRM_Member_DAO_Membership();
$membership->id = $this->_mid;
if ($membership->find(true)) {
$this->_defaultMemTypeId = $membership->membership_type_id;
if ($membership->contact_id != $this->_userID) {
require_once 'CRM/Contact/BAO/Relationship.php';
$employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
if (array_key_exists($membership->contact_id, $employers)) {
$this->_membershipContactID = $membership->contact_id;
$this->assign('membershipContactID', $this->_membershipContactID);
$this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
} else {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."));
}
}
} else {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."));
}
unset($membership);
}
}
// we do not want to display recently viewed items, so turn off
$this->assign('displayRecent', false);
// Contribution page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', true);
// action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
$this->assign('action', $this->_action);
// current mode
$this->_mode = $this->_action == 1024 ? 'test' : 'live';
$this->_values = $this->get('values');
$this->_fields = $this->get('fields');
$this->_bltID = $this->get('bltID');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_priceSetId = $this->get('priceSetId');
$this->_priceSet = $this->get('priceSet');
if (!$this->_values) {
// get all the values from the dao object
$this->_values = array();
$this->_fields = array();
require_once 'CRM/Contribute/BAO/ContributionPage.php';
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
// check if form is active
if (!$this->_values['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
// also check for billing informatin
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
$isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor_id', $this->_values))) {
$ppID = CRM_Utils_Array::value('payment_processor_id', $this->_values);
if (!$ppID) {
CRM_Core_Error::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
}
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
// check selected payment processor is active
if (empty($this->_paymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
//.........这里部分代码省略.........
示例13: 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);
}
}
示例14: _civicrm_membership_formatted_param
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @todo shouldn't it be moved to Membership.php?
*
* @param array $params Associative array of property name/value
* pairs to insert in new contact.
* @param array $values The reformatted properties that we can use internally
*
* @param array $create Is the formatted Values array going to
* be used for CRM_Member_BAO_Membership:create()
*
* @return array|CRM_Error
* @access public
*/
function _civicrm_membership_formatted_param(&$params, &$values, $create = false)
{
require_once "CRM/Member/DAO/Membership.php";
$fields =& CRM_Member_DAO_Membership::fields();
_civicrm_store_values($fields, $params, $values);
require_once 'CRM/Core/OptionGroup.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Membership');
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
//Handling Custom Data
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
if ($type == 'CheckBox' || $type == 'Multi-Select') {
$mulValues = explode(',', $value);
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
$values[$key] = array();
foreach ($mulValues as $v1) {
foreach ($customOption as $customValueID => $customLabel) {
$customValue = $customLabel['value'];
if (strtolower($customLabel['label']) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
if ($type == 'CheckBox') {
$values[$key][$customValue] = 1;
} else {
$values[$key][] = $customValue;
}
}
}
}
} else {
if ($type == 'Select' || $type == 'Radio') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
foreach ($customOption as $customValue => $customLabel) {
if (strtolower($customLabel) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
$values[$key] = $customValue;
}
}
}
}
}
switch ($key) {
case 'membership_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_create_error("contact_id not valid: {$value}");
}
$dao =& new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['membership_contact_id'];
unset($values['membership_contact_id']);
break;
case 'join_date':
case 'membership_start_date':
case 'membership_end_date':
if (!CRM_Utils_Rule::date($value)) {
return civicrm_create_error("{$key} not a valid date: {$value}");
}
break;
case 'membership_type_id':
$id = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipType", $value, 'id', 'name');
$values[$key] = $id;
break;
case 'status_id':
$id = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipStatus", $value, 'id', 'name');
$values[$key] = $id;
break;
case 'member_is_test':
$values['is_test'] = CRM_Utils_Array::value($key, $params, false);
unset($values['member_is_test']);
break;
default:
break;
}
}
if ($create) {
// CRM_Member_BAO_Membership::create() handles membership_start_date,
// membership_end_date and membership_source. So, if $values contains
// membership_start_date, membership_end_date or membership_source,
//.........这里部分代码省略.........
示例15: loadObjects
function loadObjects(&$input, &$ids, &$objects, $required)
{
$contribution =& $objects['contribution'];
$objects['membership'] = null;
$objects['contributionRecur'] = null;
$objects['contributionType'] = null;
$objects['event'] = null;
$objects['participant'] = null;
$objects['pledge_payment'] = null;
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionType = new CRM_Contribute_DAO_ContributionType();
$contributionType->id = $contribution->contribution_type_id;
if (!$contributionType->find(true)) {
CRM_Core_Error::debug_log_message("Could not find contribution type record: {$contributionTypeID}");
echo "Failure: Could not find contribution type record for {$contributionTypeID}<p>";
return false;
}
$objects['contributionType'] = $contributionType;
$paymentProcessorID = null;
if ($input['component'] == 'contribute') {
// retrieve the other optional objects first so
// stuff down the line can use this info and do things
// CRM-6056
if (isset($ids['membership'])) {
require_once 'CRM/Member/DAO/Membership.php';
$membership = new CRM_Member_DAO_Membership();
$membership->id = $ids['membership'];
if (!$membership->find(true)) {
CRM_Core_Error::debug_log_message("Could not find membership record: {$membershipID}");
echo "Failure: Could not find membership record: {$membershipID}<p>";
return false;
}
$membership->join_date = CRM_Utils_Date::isoToMysql($membership->join_date);
$membership->start_date = CRM_Utils_Date::isoToMysql($membership->start_date);
$membership->end_date = CRM_Utils_Date::isoToMysql($membership->end_date);
$membership->reminder_date = CRM_Utils_Date::isoToMysql($membership->reminder_date);
$objects['membership'] =& $membership;
}
if (isset($ids['pledge_payment'])) {
require_once 'CRM/Pledge/DAO/Payment.php';
$objects['pledge_payment'] = array();
foreach ($ids['pledge_payment'] as $key => $paymentID) {
$payment = new CRM_Pledge_DAO_Payment();
$payment->id = $paymentID;
if (!$payment->find(true)) {
CRM_Core_Error::debug_log_message("Could not find pledge payment record: {$pledge_paymentID}");
echo "Failure: Could not find pledge payment record: {$pledge_paymentID}<p>";
return false;
}
$objects['pledge_payment'][] = $payment;
}
}
if (isset($ids['contributionRecur'])) {
require_once 'CRM/Contribute/DAO/ContributionRecur.php';
$recur = new CRM_Contribute_DAO_ContributionRecur();
$recur->id = $ids['contributionRecur'];
if (!$recur->find(true)) {
CRM_Core_Error::debug_log_message("Could not find recur record: {$contributionRecurID}");
echo "Failure: Could not find recur record: {$contributionRecurID}<p>";
return false;
}
$objects['contributionRecur'] =& $recur;
//get payment processor id from recur object.
$paymentProcessorID = $recur->payment_processor_id;
}
//for normal contribution get the payment processor id.
if (!$paymentProcessorID) {
if ($contribution->contribution_page_id) {
// get the payment processor id from contribution page
$paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution->contribution_page_id, 'payment_processor_id');
}
//fail to load payment processor id.
if (!$paymentProcessorID && !$contribution->contribution_page_id && !CRM_Utils_Array::value('pledge_payment', $ids)) {
$loadObjectSuccess = true;
if ($required) {
$loadObjectSuccess = false;
CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
echo "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
}
return $loadObjectSuccess;
}
}
} else {
// we are in event mode
// make sure event exists and is valid
require_once 'CRM/Event/DAO/Event.php';
$event = new CRM_Event_DAO_Event();
$event->id = $ids['event'];
if ($ids['event'] && !$event->find(true)) {
CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
echo "Failure: Could not find event: {$eventID}<p>";
return false;
}
$objects['event'] =& $event;
require_once 'CRM/Event/DAO/Participant.php';
$participant = new CRM_Event_DAO_Participant();
$participant->id = $ids['participant'];
if ($ids['participant'] && !$participant->find(true)) {
CRM_Core_Error::debug_log_message("Could not find participant: {$participantID}");
echo "Failure: Could not find participant: {$participantID}<p>";
//.........这里部分代码省略.........