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


PHP CRM_Member_DAO_Membership::whereAdd方法代码示例

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


在下文中一共展示了CRM_Member_DAO_Membership::whereAdd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMembershipsForContact

 private function getMembershipsForContact($contact_id)
 {
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $contact_id;
     $dao->whereAdd('is_test IS NULL OR is_test = 0');
     // order by start date to find most recent membership first, CRM-4545
     $dao->orderBy('start_date DESC');
     $dao->find(false);
     $memberships = array();
     while ($dao->fetch()) {
         $startDate = new DateTime($dao->start_date);
         $endDate = new DateTime($dao->end_date);
         $memberships[$dao->id] = CRM_Member_PseudoConstant::membershipType($dao->membership_type_id) . ': ' . CRM_Member_PseudoConstant::membershipStatus($dao->status_id, null, 'label') . ' (' . $startDate->format('d-m-Y') . ' - ' . $endDate->format('d-m-Y') . ')';
     }
     return $memberships;
 }
开发者ID:dragonjon,项目名称:org.civicoop.membershippayment,代码行数:16,代码来源:Form.php

示例2: getAllContactMembership

 /**
  * Returns the membership types for a particular contact
  * who has lifetime membership without end date.
  *
  * @param int $contactID
  * @param bool $isTest
  * @param bool $onlyLifeTime
  *
  * @return array
  */
 public static function getAllContactMembership($contactID, $isTest = FALSE, $onlyLifeTime = FALSE)
 {
     $contactMembershipType = array();
     if (!$contactID) {
         return $contactMembershipType;
     }
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $contactID;
     $pendingStatusId = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
     $dao->whereAdd("status_id != {$pendingStatusId}");
     if ($isTest) {
         $dao->is_test = $isTest;
     } else {
         $dao->whereAdd('is_test IS NULL OR is_test = 0');
     }
     if ($onlyLifeTime) {
         $dao->whereAdd('end_date IS NULL');
     }
     $dao->find();
     while ($dao->fetch()) {
         $membership = array();
         CRM_Core_DAO::storeValues($dao, $membership);
         $contactMembershipType[$dao->membership_type_id] = $membership;
     }
     return $contactMembershipType;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:36,代码来源:Membership.php

示例3: updateMembershipStatus

 /**
  * Update membership status to deceased.
  * function return the status message for updated membership.
  *
  * @param array $deceasedParams
  *   having contact id and deceased value.
  *
  * @return null|string
  *   $updateMembershipMsg string  status message for updated membership.
  */
 public function updateMembershipStatus($deceasedParams)
 {
     $updateMembershipMsg = NULL;
     $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
     $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
     // process to set membership status to deceased for both active/inactive membership
     if ($contactId && $this->_contactType == 'Individual' && !empty($deceasedParams['is_deceased'])) {
         $session = CRM_Core_Session::singleton();
         $userId = $session->get('userID');
         if (!$userId) {
             $userId = $contactId;
         }
         // get deceased status id
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $deceasedStatusId = array_search('Deceased', $allStatus);
         if (!$deceasedStatusId) {
             return $updateMembershipMsg;
         }
         $today = time();
         if ($deceasedDate && strtotime($deceasedDate) > $today) {
             return $updateMembershipMsg;
         }
         // get non deceased membership
         $dao = new CRM_Member_DAO_Membership();
         $dao->contact_id = $contactId;
         $dao->whereAdd("status_id != {$deceasedStatusId}");
         $dao->find();
         $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $memCount = 0;
         while ($dao->fetch()) {
             // update status to deceased (for both active/inactive membership )
             CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->id, 'status_id', $deceasedStatusId);
             // add membership log
             $membershipLog = array('membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'modified_id' => $userId, 'modified_date' => date('Ymd'), 'membership_type_id' => $dao->membership_type_id, 'max_related' => $dao->max_related);
             CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
             //create activity when membership status is changed
             $activityParam = array('subject' => "Status changed from {$allStatus[$dao->status_id]} to {$allStatus[$deceasedStatusId]}", 'source_contact_id' => $userId, 'target_contact_id' => $dao->contact_id, 'source_record_id' => $dao->id, 'activity_type_id' => array_search('Change Membership Status', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
             $activityResult = civicrm_api('activity', 'create', $activityParam);
             $memCount++;
         }
         // set status msg
         if ($memCount) {
             $updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", array(1 => $memCount));
         }
     }
     return $updateMembershipMsg;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:58,代码来源:Contact.php

示例4: buildMembershipBlock

 /**
  * Build Membership  Block in Contribution Pages.
  *
  * @param int $cid
  *   Contact checked for having a current membership for a particular membership.
  * @param bool $isContributionMainPage
  *   Is this the main page? If so add form input fields.
  *   (or better yet don't have this functionality in a function shared with forms that don't share it).
  * @param int $selectedMembershipTypeID
  *   Selected membership id.
  * @param bool $thankPage
  *   Thank you page.
  * @param null $isTest
  *
  * @return bool
  *   Is this a separate membership payment
  */
 protected function buildMembershipBlock($cid, $isContributionMainPage = FALSE, $selectedMembershipTypeID = NULL, $thankPage = FALSE, $isTest = NULL)
 {
     $separateMembershipPayment = FALSE;
     if ($this->_membershipBlock) {
         $this->_currentMemberships = array();
         $membershipTypeIds = $membershipTypes = $radio = array();
         $membershipPriceset = !empty($this->_priceSetId) && $this->_useForMember ? TRUE : FALSE;
         $allowAutoRenewMembership = $autoRenewOption = FALSE;
         $autoRenewMembershipTypeOptions = array();
         $separateMembershipPayment = CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock);
         if ($membershipPriceset) {
             foreach ($this->_priceSet['fields'] as $pField) {
                 if (empty($pField['options'])) {
                     continue;
                 }
                 foreach ($pField['options'] as $opId => $opValues) {
                     if (empty($opValues['membership_type_id'])) {
                         continue;
                     }
                     $membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id'];
                 }
             }
         } elseif (!empty($this->_membershipBlock['membership_types'])) {
             $membershipTypeIds = explode(',', $this->_membershipBlock['membership_types']);
         }
         if (!empty($membershipTypeIds)) {
             //set status message if wrong membershipType is included in membershipBlock
             if (isset($this->_mid) && !$membershipPriceset) {
                 $membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
                 if (!in_array($membershipTypeID, $membershipTypeIds)) {
                     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('Invalid Membership'), 'error');
                 }
             }
             $membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIds);
             $this->_membershipTypeValues = $membershipTypeValues;
             $endDate = NULL;
             foreach ($membershipTypeIds as $value) {
                 $memType = $membershipTypeValues[$value];
                 if ($selectedMembershipTypeID != NULL) {
                     if ($memType['id'] == $selectedMembershipTypeID) {
                         $this->assign('minimum_fee', CRM_Utils_Array::value('minimum_fee', $memType));
                         $this->assign('membership_name', $memType['name']);
                         if (!$thankPage && $cid) {
                             $membership = new CRM_Member_DAO_Membership();
                             $membership->contact_id = $cid;
                             $membership->membership_type_id = $memType['id'];
                             if ($membership->find(TRUE)) {
                                 $this->assign('renewal_mode', TRUE);
                                 $memType['current_membership'] = $membership->end_date;
                                 $this->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
                             }
                         }
                         $membershipTypes[] = $memType;
                     }
                 } elseif ($memType['is_active']) {
                     $javascriptMethod = NULL;
                     $allowAutoRenewOpt = (int) $memType['auto_renew'];
                     if (is_array($this->_paymentProcessors)) {
                         foreach ($this->_paymentProcessors as $id => $val) {
                             if (!$val['is_recur']) {
                                 $allowAutoRenewOpt = 0;
                                 continue;
                             }
                         }
                     }
                     $javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );");
                     $autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $allowAutoRenewOpt * CRM_Utils_Array::value($value, CRM_Utils_Array::value('auto_renew', $this->_membershipBlock));
                     if ($allowAutoRenewOpt) {
                         $allowAutoRenewMembership = TRUE;
                     }
                     //add membership type.
                     $radio[$memType['id']] = $this->createElement('radio', NULL, NULL, NULL, $memType['id'], $javascriptMethod);
                     if ($cid) {
                         $membership = new CRM_Member_DAO_Membership();
                         $membership->contact_id = $cid;
                         $membership->membership_type_id = $memType['id'];
                         //show current membership, skip pending and cancelled membership records,
                         //because we take first membership record id for renewal
                         $membership->whereAdd('status_id != 5 AND status_id !=6');
                         if (!is_null($isTest)) {
                             $membership->is_test = $isTest;
                         }
                         //CRM-4297
//.........这里部分代码省略.........
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:ContributionBase.php

示例5: getContactMembership

 /**
  * Function to return current membership of given contacts 
  * 
  * @param int $contactID  contact id
  * @static
  */
 static function getContactMembership($contactID, $memType, $isTest, $membershipId = null)
 {
     $dao = new CRM_Member_DAO_Membership();
     if ($membershipId) {
         $dao->id = $membershipId;
     }
     $dao->contact_id = $contactID;
     $dao->membership_type_id = $memType;
     //fetch proper membership record.
     if ($isTest) {
         $dao->is_test = $isTest;
     } else {
         $dao->whereAdd('is_test IS NULL OR is_test = 0');
     }
     //avoid pending membership as current memebrship: CRM-3027
     require_once 'CRM/Member/PseudoConstant.php';
     $pendingStatusId = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
     $dao->whereAdd("status_id != {$pendingStatusId}");
     // order by start date to find mos recent membership first, CRM-4545
     $dao->orderBy('start_date DESC');
     if ($dao->find(true)) {
         $membership = array();
         CRM_Core_DAO::storeValues($dao, $membership);
         $membership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $membership['status_id'], 'is_current_member', 'id');
         return $membership;
     }
     return false;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:Membership.php

示例6: browse

 /**
  * called when action is browse.
  */
 public function browse()
 {
     $links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
     CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
     $addWhere = "membership_type_id IN (0)";
     if (!empty($membershipTypes)) {
         $addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
     }
     $membership = array();
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $this->_contactId;
     $dao->is_test = 0;
     $dao->whereAdd($addWhere);
     //$dao->orderBy('name');
     $dao->find();
     //CRM--4418, check for view, edit, delete
     $permissions = array(CRM_Core_Permission::VIEW);
     if (CRM_Core_Permission::check('edit memberships')) {
         $permissions[] = CRM_Core_Permission::EDIT;
     }
     if (CRM_Core_Permission::check('delete in CiviMember')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     // get deceased status id
     $allStatus = CRM_Member_PseudoConstant::membershipStatus();
     $deceasedStatusId = array_search('Deceased', $allStatus);
     //get all campaigns.
     $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
     //checks membership of contact itself
     while ($dao->fetch()) {
         $membership[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
         //carry campaign.
         $membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
         //get the membership status and type values.
         $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
         foreach (array('status', 'membership_type') as $fld) {
             $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
         }
         if (!empty($statusANDType[$dao->id]['is_current_member'])) {
             $membership[$dao->id]['active'] = TRUE;
         }
         if (empty($dao->owner_membership_id)) {
             // unset renew and followup link for deceased membership
             $currentMask = $mask;
             if ($dao->status_id == $deceasedStatusId) {
                 $currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
             }
             $isUpdateBilling = FALSE;
             // It would be better to determine if there is a recurring contribution &
             // is so get the entity for the recurring contribution (& skip if not).
             $paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($membership[$dao->id]['membership_id'], 'membership', 'obj');
             if (!empty($paymentObject)) {
                 // @todo - get this working with syntax style $paymentObject->supports(array
                 //('updateSubscriptionBillingInfo'));
                 $isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
             }
             // @todo - get this working with syntax style $paymentObject->supports(array
             //('CancelSubscriptionSupported'));
             $isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
             $links = self::links('all', NULL, NULL, $isCancelSupported, $isUpdateBilling);
             self::getPermissionedLinks($dao->membership_type_id, $links);
             $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('Renew') . '...', FALSE, 'membership.tab.row', 'Membership', $dao->id);
         } else {
             $links = self::links('view');
             self::getPermissionedLinks($dao->membership_type_id, $links);
             $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'membership.tab.row', 'Membership', $dao->id);
         }
         //does membership have auto renew CRM-7137.
         if (!empty($membership[$dao->id]['contribution_recur_id']) && !CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])) {
             $membership[$dao->id]['auto_renew'] = 1;
         } else {
             $membership[$dao->id]['auto_renew'] = 0;
         }
         // if relevant--membership is active and type allows inheritance--count related memberships
         if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id]) && CRM_Utils_Array::value('relationship_type_id', $statusANDType[$dao->id]) && empty($dao->owner_membership_id)) {
             // not an related membership
             $query = "\n SELECT COUNT(m.id)\n   FROM civicrm_membership m\n     LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id\n     LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id\n  WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0";
             $num_related = CRM_Core_DAO::singleValueQuery($query);
             $max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]);
             $membership[$dao->id]['related_count'] = $max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array(1 => $num_related, 2 => $max_related));
         } else {
             $membership[$dao->id]['related_count'] = ts('N/A');
         }
     }
     //Below code gives list of all Membership Types associated
     //with an Organization(CRM-2016)
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($this->_contactId);
     foreach ($membershipTypes as $key => $value) {
         $membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, array('id' => $value['id'], 'cid' => $this->_contactId), ts('more'), FALSE, 'membershipType.organization.action', 'MembershipType', $value['id']);
     }
     $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
     $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
     $this->assign('activeMembers', $activeMembers);
     $this->assign('inActiveMembers', $inActiveMembers);
     $this->assign('membershipTypes', $membershipTypes);
//.........这里部分代码省略.........
开发者ID:sarehag,项目名称:civicrm-core,代码行数:101,代码来源:Tab.php

示例7: 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


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