Esempio n. 1
0
 public function GetPriorMembershipText()
 {
     $strPriors = null;
     foreach ($this->objPerson->GetMembershipArray(QQ::OrderBy(QQN::Membership()->DateStart, false)) as $objMembership) {
         if ($objMembership->DateEnd) {
             $strPriors .= sprintf('<br/><em>Prior membership from %s to %s</em>', $objMembership->DateStart->__toString('MMMM D, YYYY'), $objMembership->DateEnd->__toString('MMMM D, YYYY'));
         }
     }
     return $strPriors;
 }
Esempio n. 2
0
 protected function dtgNewMembers_Bind()
 {
     $dtAfterValue = new QDateTime($this->dtxAfterValue->Text);
     $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text);
     $objcondition = QQ::Equal(QQN::Membership()->Person->AttributeValue->Attribute->Name, 'Post-2016');
     $this->dtgNewMembers->TotalItemCount = Membership::CountArrayByStartDateRange($dtAfterValue, $dtBeforeValue, $objcondition);
     $objMembershipArray = Membership::LoadArrayByStartDateRange($dtAfterValue, $dtBeforeValue, $objcondition, $this->dtgNewMembers->LimitClause);
     $this->dtgNewMembers->DataSource = $objMembershipArray;
     $this->iTotalCount = count($objMembershipArray);
     $this->CalculateMaritalAndAgeStatus($objMembershipArray);
     $this->CalculateAttributeStatistics($objMembershipArray);
 }
Esempio n. 3
0
 protected function Form_Create()
 {
     $this->lblLabel = new QLabel($this);
     $this->lblLabel->Text = "Members who left after ";
     $this->dtxBeforeValue = new QDateTimeTextBox($this);
     $this->dtxBeforeValue->Name = "Members who Exited Before:";
     $this->dtxBeforeValue->Required = true;
     $this->beforeCalValue = new QCalendar($this, $this->dtxBeforeValue);
     $this->dtxBeforeValue->RemoveAllActions(QClickEvent::EventName);
     $this->dtxBeforeValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change'));
     $this->dtxBeforeValue->Text = QApplication::PathInfo(1);
     $this->dtxAfterValue = new QDateTimeTextBox($this);
     $this->dtxAfterValue->Name = "Members who exited After:";
     $this->dtxAfterValue->Required = true;
     $this->afterCalValue = new QCalendar($this, $this->dtxAfterValue);
     $this->dtxAfterValue->RemoveAllActions(QClickEvent::EventName);
     $this->dtxAfterValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change'));
     $this->dtxAfterValue->Text = QApplication::PathInfo(0);
     $this->dtgExitingMembers = new QDataGrid($this);
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Name', '<?= $_ITEM->Person->FullName; ?>', 'Width=270px'));
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Membership End Date', '<?= $_ITEM->DateEnd; ?>', 'Width=270px'));
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Termination Reason', '<?= $_ITEM->TerminationReason; ?>', 'Width=270px'));
     $dtAfterValue = new QDateTime($this->dtxAfterValue->Text);
     $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text);
     $objcondition = QQ::Equal(QQN::Membership()->Person->AttributeValue->Attribute->Name, 'Post-2016');
     $objMembershipArray = Membership::LoadArrayByEndDateRange($dtAfterValue, $dtBeforeValue, $objcondition);
     $this->iTotalCount = count($objMembershipArray);
     $this->dtgExitingMembers->DataSource = $objMembershipArray;
     $chartArray = array();
     $terminationReason = array();
     foreach ($objMembershipArray as $member) {
         if (array_key_exists($member->TerminationReason, $terminationReason)) {
             $terminationReason[$member->TerminationReason]++;
         } else {
             $terminationReason[$member->TerminationReason] = 1;
         }
     }
     ksort($terminationReason, SORT_STRING);
     foreach ($terminationReason as $key => $value) {
         $objItem = new memberArray();
         $objItem->reason = $key;
         $objItem->count = $value;
         $chartArray[] = $objItem;
     }
     QApplication::ExecuteJavaScript('initializeChart(' . json_encode($chartArray) . ');');
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 /**
  * Count Memberships
  * by DateStart Index(es)
  * @param QDateTime $dttDateStart
  * @return int
  */
 public static function CountByDateStart($dttDateStart, $objOptionalClauses = null)
 {
     // Call Membership::QueryCount to perform the CountByDateStart query
     return Membership::QueryCount(QQ::Equal(QQN::Membership()->DateStart, $dttDateStart), $objOptionalClauses);
 }
Esempio n. 6
0
 /**
  * Used internally by the Meta-based Add Column tools.
  *
  * Given a QQNode or a Text String, this will return a Membership-based QQNode.
  * It will also verify that it is a proper Membership-based QQNode, and will throw an exception otherwise.
  *
  * @param mixed $mixContent
  * @return QQNode
  */
 protected function ResolveContentItem($mixContent)
 {
     if ($mixContent instanceof QQNode) {
         if (!$mixContent->_ParentNode) {
             throw new QCallerException('Content QQNode cannot be a Top Level Node');
         }
         if ($mixContent->_RootTableName == 'membership') {
             if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             }
             $objCurrentNode = $mixContent;
             while ($objCurrentNode = $objCurrentNode->_ParentNode) {
                 if (!$objCurrentNode instanceof QQNode) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
                 if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
             }
             return $mixContent;
         } else {
             throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "membership".');
         }
     } else {
         if (is_string($mixContent)) {
             switch ($mixContent) {
                 case 'Id':
                     return QQN::Membership()->Id;
                 case 'PersonId':
                     return QQN::Membership()->PersonId;
                 case 'Person':
                     return QQN::Membership()->Person;
                 case 'DateStart':
                     return QQN::Membership()->DateStart;
                 case 'DateEnd':
                     return QQN::Membership()->DateEnd;
                 case 'TerminationReason':
                     return QQN::Membership()->TerminationReason;
                 default:
                     throw new QCallerException('Simple Property not found in MembershipDataGrid content: ' . $mixContent);
             }
         } else {
             if ($mixContent instanceof QQAssociationNode) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             } else {
                 throw new QCallerException('Invalid Content type');
             }
         }
     }
 }
 public function dtgMemberships_Bind()
 {
     $this->dtgMemberships->DataSource = $this->objPerson->GetMembershipArray(QQ::OrderBy(QQN::Membership()->DateStart, false));
 }
Esempio n. 8
0
 public static function LoadArrayByEndDateRange($dttAfterDateStart, $dttBeforeDateStart, $objCondition = null, $objOptionalClauses = null)
 {
     // This will return an array of Membership objects
     $objCondition = QQ::AndCondition($objCondition, QQ::AndCondition(QQ::GreaterOrEqual(QQN::Membership()->DateEnd, $dttAfterDateStart), QQ::LessOrEqual(QQN::Membership()->DateEnd, $dttBeforeDateStart)));
     return Membership::QueryArray($objCondition, $objOptionalClauses);
 }