当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Member_DAO_Membership::find方法代码示例

本文整理汇总了PHP中CRM_Member_DAO_Membership::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_Membership::find方法的具体用法?PHP CRM_Member_DAO_Membership::find怎么用?PHP CRM_Member_DAO_Membership::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Member_DAO_Membership的用法示例。


在下文中一共展示了CRM_Member_DAO_Membership::find方法的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);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:UserDashboard.php

示例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);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:38,代码来源:UserDashboard.php

示例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);
 }
开发者ID:BCLibCoop,项目名称:bcla-civicrm-custom-overrides,代码行数:60,代码来源:UserDashboard.php

示例4: 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
     }
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:24,代码来源:Merger.php

示例5: createRelatedMemberships

 /**
  * function to create memberships for related contacts
  *
  * @param  array      $params       array of key - value pairs
  * @param  object     $membership   membership object
  *
  * @return null|relatedMembership     array of memberships if created
  * @static
  * @access public
  */
 static function createRelatedMemberships(&$params, &$membership)
 {
     static $relatedContactIds = array();
     // required since create method doesn't return all the
     // parameters in the returned membership object
     if (!$membership->find(true)) {
         return;
     }
     require_once 'CRM/Member/PseudoConstant.php';
     $deceasedStatusId = array_search('Deceased', CRM_Member_PseudoConstant::membershipStatus());
     $allRelatedContacts = array();
     $relatedContacts = array();
     if (!is_a($membership, 'CRM_Core_Error')) {
         $allRelatedContacts = CRM_Member_BAO_Membership::checkMembershipRelationship($membership->id, $membership->contact_id, CRM_Utils_Array::value('action', $params));
     }
     // check for loops. CRM-4213
     // remove repeated related contacts, which already inherited membership.
     $relatedContactIds[$membership->contact_id] = true;
     foreach ($allRelatedContacts as $cid => $status) {
         if (!CRM_Utils_Array::value($cid, $relatedContactIds)) {
             $relatedContactIds[$cid] = true;
             //don't create membership again for owner contact.
             $nestedRelationship = false;
             if ($membership->owner_membership_id) {
                 $nestedRelMembership = new CRM_Member_DAO_Membership();
                 $nestedRelMembership->id = $membership->owner_membership_id;
                 $nestedRelMembership->contact_id = $cid;
                 $nestedRelationship = $nestedRelMembership->find(true);
                 $nestedRelMembership->free();
             }
             if (!$nestedRelationship) {
                 $relatedContacts[$cid] = $status;
             }
         }
     }
     //lets cleanup related membership if any.
     if (empty($relatedContacts)) {
         require_once 'CRM/Member/BAO/Membership.php';
         CRM_Member_BAO_Membership::deleteRelatedMemberships($membership->id);
     } else {
         // Edit the params array
         unset($params['id']);
         // Reminder should be sent only to the direct membership
         unset($params['reminder_date']);
         // unset the custom value ids
         if (is_array(CRM_Utils_Array::value('custom', $params))) {
             foreach ($params['custom'] as $k => $v) {
                 unset($params['custom'][$k]['id']);
             }
         }
         if (!isset($params['membership_type_id'])) {
             $params['membership_type_id'] = $membership->membership_type_id;
         }
         foreach ($relatedContacts as $contactId => $relationshipStatus) {
             //use existing membership record.
             $relMembership = new CRM_Member_DAO_Membership();
             $relMembership->contact_id = $contactId;
             $relMembership->owner_membership_id = $membership->id;
             $relMemIds = array();
             if ($relMembership->find(true)) {
                 $params['id'] = $relMemIds['membership'] = $relMembership->id;
             }
             $params['contact_id'] = $contactId;
             $params['owner_membership_id'] = $membership->id;
             // set status_id as it might have been changed for
             // past relationship
             $params['status_id'] = $membership->status_id;
             if ($deceasedStatusId && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'is_deceased')) {
                 $params['status_id'] = $deceasedStatusId;
             } else {
                 if (CRM_Utils_Array::value('action', $params) & CRM_Core_Action::UPDATE && $relationshipStatus == CRM_Contact_BAO_Relationship::PAST) {
                     // FIXME : While updating/ renewing the
                     // membership, if the relationship is PAST then
                     // the membership of the related contact must be
                     // expired.
                     // For that, getting Membership Status for which
                     // is_current_member is 0. It works for the
                     // generated data as there is only one membership
                     // status having is_current_member = 0.
                     // But this wont work exactly if there will be
                     // more than one status having is_current_member = 0.
                     require_once 'CRM/Member/DAO/MembershipStatus.php';
                     $membershipStatus = new CRM_Member_DAO_MembershipStatus();
                     $membershipStatus->is_current_member = 0;
                     if ($membershipStatus->find(true)) {
                         $params['status_id'] = $membershipStatus->id;
                     }
                 }
             }
             //don't calculate status again in create( );
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Membership.php

示例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);
         }
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:95,代码来源:Tab.php

示例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);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:82,代码来源:Tab.php

示例8: 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;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:47,代码来源:Contact.php

示例9: submit


//.........这里部分代码省略.........
         $formValues["state_province-{$this->_bltID}"] = $formValues["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($formValues["billing_state_province_id-{$this->_bltID}"]);
         $formValues["country-{$this->_bltID}"] = $formValues["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($formValues["billing_country_id-{$this->_bltID}"]);
         $formValues['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($formValues);
         $formValues['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($formValues);
         $formValues['ip_address'] = CRM_Utils_System::ipAddress();
         $formValues['amount'] = $params['total_amount'];
         $formValues['currencyID'] = $config->defaultCurrency;
         $formValues['description'] = ts("Contribution submitted by a staff person using member's credit card for signup");
         $formValues['invoiceID'] = md5(uniqid(rand(), TRUE));
         $formValues['financial_type_id'] = $params['financial_type_id'];
         // at this point we've created a contact and stored its address etc
         // all the payment processors expect the name and address to be in the
         // so we copy stuff over to first_name etc.
         $paymentParams = $formValues;
         $paymentParams['contactID'] = $this->_contributorContactID;
         //CRM-10377 if payment is by an alternate contact then we need to set that person
         // as the contact in the payment params
         if ($this->_contributorContactID != $this->_contactID) {
             if (!empty($formValues['soft_credit_type_id'])) {
                 $softParams['contact_id'] = $params['contact_id'];
                 $softParams['soft_credit_type_id'] = $formValues['soft_credit_type_id'];
             }
         }
         if (!empty($formValues['send_receipt'])) {
             $paymentParams['email'] = $this->_contributorEmail;
         }
         CRM_Core_Payment_Form::mapParams($this->_bltID, $formValues, $paymentParams, TRUE);
         // CRM-7137 -for recurring membership,
         // we do need contribution and recurring records.
         $result = NULL;
         if (!empty($paymentParams['is_recur'])) {
             $financialType = new CRM_Financial_DAO_FinancialType();
             $financialType->id = $params['financial_type_id'];
             $financialType->find(TRUE);
             $this->_params = $formValues;
             $contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, $paymentParams, NULL, array('contact_id' => $this->_contributorContactID, 'line_item' => $lineItem, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams), 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $formValues), 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $paymentParams), 'payment_instrument_id' => $this->_paymentProcessor['payment_instrument_id']), $financialType, TRUE, FALSE, $this->_bltID);
             //create new soft-credit record, CRM-13981
             if ($softParams) {
                 $softParams['contribution_id'] = $contribution->id;
                 $softParams['currency'] = $contribution->currency;
                 $softParams['amount'] = $contribution->total_amount;
                 CRM_Contribute_BAO_ContributionSoft::add($softParams);
             }
             $paymentParams['contactID'] = $this->_contactID;
             $paymentParams['contributionID'] = $contribution->id;
             $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
             $paymentParams['contributionPageID'] = $contribution->contribution_page_id;
             $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
             $ids['contribution'] = $contribution->id;
             $params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
         }
         if ($params['total_amount'] > 0.0) {
             $payment = $this->_paymentProcessor['object'];
             try {
                 $result = $payment->doPayment($paymentParams);
                 $formValues = array_merge($formValues, $result);
                 // Assign amount to template if payment was successful.
                 $this->assign('amount', $params['total_amount']);
             } catch (PaymentProcessorException $e) {
                 if (!empty($paymentParams['contributionID'])) {
                     CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $this->_contactID, $e->getMessage());
                 }
                 if (!empty($paymentParams['contributionRecurID'])) {
                     CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
                 }
                 CRM_Core_Error::displaySessionError($result);
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:67,代码来源:Membership.php

示例10: 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) {
         // seems like the session is corrupted and/or we lost the id trail
         // lets just bump this to a regular session error and redirect user to main page
         $this->controller->invalidKeyRedirect();
     }
     // this was used prior to the cleverer this_>getContactID - unsure now
     $this->_userID = $session->get('userID');
     $this->_contactID = $this->_membershipContactID = $this->getContactID();
     $this->_mid = NULL;
     if ($this->_contactID) {
         $this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
         if ($this->_mid) {
             $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->_contactID) {
                     $validMembership = FALSE;
                     $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
                     if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
                         $this->_membershipContactID = $membership->contact_id;
                         $this->assign('membershipContactID', $this->_membershipContactID);
                         $this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
                         $validMembership = TRUE;
                     } else {
                         $membershipType = new CRM_Member_BAO_MembershipType();
                         $membershipType->id = $membership->membership_type_id;
                         if ($membershipType->find(TRUE)) {
                             // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
                             // Convert to commma separated list.
                             $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                             $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                             if (array_key_exists($membership->contact_id, $permContacts)) {
                                 $this->_membershipContactID = $membership->contact_id;
                                 $validMembership = TRUE;
                             }
                         }
                     }
                     if (!$validMembership) {
                         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."), ts('Membership Invalid'), 'alert');
                     }
                 }
             } 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."), ts('Membership Invalid'), 'alert');
             }
             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();
         CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
         // check if form is active
         if (!CRM_Utils_Array::value('is_active', $this->_values)) {
             // 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::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $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);
         //FIXME: to support multiple payment processors
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:ContributionBase.php

示例11: 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;
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:24,代码来源:GenerateReportData.php

示例12: 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>";
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:BaseIPN.php

示例13: 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);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:ContributionBase.php

示例14: 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";
                }
            }
        }
    }
}
开发者ID:robbrandt,项目名称:bsa-joinrenew,代码行数:38,代码来源:joinrenew.php

示例15: moveRecurringRecord

 public function moveRecurringRecord($submittedValues)
 {
     // Move recurring record to another contact
     if (!empty($submittedValues['contact_id']) && $submittedValues['contact_id'] != $this->_contactID) {
         $selected_cid = $submittedValues['contact_id'];
         // FIXME: Not getting the below value in $submittedValues
         // So taking the value from $_POST
         if (isset($_POST['membership_record'])) {
             $membership_record = $_POST['membership_record'];
         }
         // Update contact id in civicrm_contribution_recur table
         $recurring = new CRM_Contribute_BAO_ContributionRecur();
         $recurring->id = $this->_id;
         if ($recurring->find(TRUE)) {
             $recurParams = (array) $recurring;
             $recurParams['contact_id'] = $selected_cid;
             CRM_Contribute_BAO_ContributionRecur::create($recurParams);
         }
         // Update contact id in civicrm_contribution table, if 'Move Existing Contributions?' is ticked
         if (isset($submittedValues['move_existing_contributions']) && $submittedValues['move_existing_contributions'] == 1) {
             $contribution = new CRM_Contribute_DAO_Contribution();
             $contribution->contribution_recur_id = $this->_id;
             $contribution->find();
             while ($contribution->fetch()) {
                 $contributionParams = (array) $contribution;
                 $contributionParams['contact_id'] = $selected_cid;
                 // Update contact_id of contributions
                 // related to the recurring contribution
                 CRM_Contribute_BAO_Contribution::create($contributionParams);
             }
         }
     }
     if (!empty($membership_record)) {
         // Remove the contribution_recur_id from existing membership
         if (!empty($this->_membershipID)) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_membershipID;
             if ($membership->find(TRUE)) {
                 $membershipParams = (array) $membership;
                 $membershipParams['contribution_recur_id'] = 'NULL';
                 CRM_Member_BAO_Membership::add($membershipParams);
             }
         }
         // Update contribution_recur_id to the new membership
         $membership = new CRM_Member_DAO_Membership();
         $membership->id = $membership_record;
         if ($membership->find(TRUE)) {
             $membershipParams = (array) $membership;
             $membershipParams['contribution_recur_id'] = $this->_id;
             CRM_Member_BAO_Membership::add($membershipParams);
         }
     }
 }
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.offlinerecurringcontributions,代码行数:53,代码来源:ContributionRecur.php


注:本文中的CRM_Member_DAO_Membership::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。