示例#1
0
 /**
  * Recalculates this member's Membership Status and updates MembershipStatusTypeId
  * based on the calculation.  Will call save if asked to do so
  * @param boolean $blnSave whether or not to call save after updating
  * @return integer the new/updated TypeId
  */
 public function RefreshMembershipStatusTypeId($blnSave = true)
 {
     // If this Individual record isn't saved yet, then we are automatically not a member
     if (!$this->intId) {
         $this->intMembershipStatusTypeId = MembershipStatusType::NonMember;
         if ($blnSave) {
             $this->Save();
         }
         return $this->intMembershipStatusTypeId;
     }
     // Pull the most recent Membership
     $objMembership = Membership::QuerySingle(QQ::Equal(QQN::Membership()->PersonId, $this->intId), QQ::OrderBy(QQN::Membership()->DateStart, false));
     // If no membership
     if (!$objMembership) {
         // TODO: Check to see if "Child of Member"
         $this->intMembershipStatusTypeId = MembershipStatusType::NonMember;
         if ($blnSave) {
             $this->Save();
         }
         return $this->intMembershipStatusTypeId;
     }
     // If no EndDate, or EndDate is in the future
     if (!$objMembership->DateEnd || $objMembership->DateEnd->IsLaterThan(QDateTime::Now(false))) {
         $this->intMembershipStatusTypeId = MembershipStatusType::Member;
         if ($blnSave) {
             $this->Save();
         }
         return $this->intMembershipStatusTypeId;
     }
     // Check to see if we're deceased
     if ($objMembership->TerminationReason == MembershipStatusType::ToString(MembershipStatusType::Deceased)) {
         $this->intMembershipStatusTypeId = MembershipStatusType::Deceased;
         if ($blnSave) {
             $this->Save();
         }
         return $this->intMembershipStatusTypeId;
     }
     // Otherwise, we are a Past member
     $this->intMembershipStatusTypeId = MembershipStatusType::FormerMember;
     if ($blnSave) {
         $this->Save();
     }
     return $this->intMembershipStatusTypeId;
 }
示例#2
0
 /**
  * Load a single Membership object,
  * by Id Index(es)
  * @param integer $intId
  * @return Membership
  */
 public static function LoadById($intId, $objOptionalClauses = null)
 {
     return Membership::QuerySingle(QQ::Equal(QQN::Membership()->Id, $intId), $objOptionalClauses);
 }