public function Validate() { if (!parent::Validate()) { return false; } if ($this->strText != '') { $dttDateTime = new QDateTime($this->strText); if ($dttDateTime->IsDateNull()) { $this->strValidationError = QApplication::Translate("invalid date"); return false; } if (!is_null($this->Minimum)) { if ($dttDateTime->IsEarlierThan($this->Minimum)) { $this->strValidationError = QApplication::Translate("date is earlier than minimum allowed"); return false; } } if (!is_null($this->Maximum)) { if ($dttDateTime->IsLaterThan($this->Maximum)) { $this->strValidationError = QApplication::Translate("date is later than maximum allowed"); return false; } } } $this->strValidationError = ''; return true; }
/** * Validate the control. * @return bool */ public function Validate() { if (!parent::Validate()) { return false; } if ($this->strText != '') { $dttDateTime = new QDateTime($this->strText, null, QDateTime::DateOnlyType); if ($dttDateTime->IsDateNull()) { $this->ValidationError = QApplication::Translate("Invalid date"); return false; } if (!is_null($this->Minimum)) { if ($dttDateTime->IsEarlierThan($this->Minimum)) { if ($this->strMinDateErrorMsg) { $this->ValidationError = $this->strMinDateErrorMsg; } else { $this->ValidationError = QApplication::Translate("Date is earlier than minimum allowed"); } return false; } } if (!is_null($this->Maximum)) { if ($dttDateTime->IsLaterThan($this->Maximum)) { if ($this->strMaxDateErrorMsg) { $this->ValidationError = $this->strMaxDateErrorMsg; } else { $this->ValidationError = QApplication::Translate("Date is later than maximum allowed"); } return false; } } } return true; }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { $this->objPerson->Title = $this->lstTitle->SelectedValue; $this->objPerson->FirstName = trim($this->txtFirstName->Text); $this->objPerson->MiddleName = trim($this->txtMiddleName->Text); $this->objPerson->LastName = trim($this->txtLastName->Text); $this->objPerson->Suffix = $this->lstSuffix->SelectedValue; $this->objPerson->Nickname = trim($this->txtNickname->Text); $this->objPerson->PriorLastNames = trim($this->txtPriorLastNames->Text); $this->objPerson->MailingLabel = trim($this->txtMailingLabel->Text); $this->objPerson->Gender = trim($this->lstGender->SelectedValue); // Date of Birth Stuff switch ($this->lstDateOfBirth->SelectedValue) { case self::DobNone: $this->objPerson->DateOfBirth = null; $this->objPerson->DobGuessedFlag = null; $this->objPerson->DobYearApproximateFlag = null; break; case self::DobExact: $this->objPerson->DateOfBirth = $this->dtxDateOfBirth->DateTime; $this->objPerson->DobGuessedFlag = false; $this->objPerson->DobYearApproximateFlag = false; break; case self::DobApproximateDay: if ($this->objPerson->DateOfBirth) { $dttDate = new QDateTime($this->objPerson->DateOfBirth); $dttDate->Year = QDateTime::Now()->Year; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } } else { $dttDate = QDateTime::Now(); $dttDate->Month -= 6; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = true; $this->objPerson->DobYearApproximateFlag = false; break; case self::DobApproximateYear: $dttDate = QDateTime::Now(); $dttDate->Month = $this->lstMonth->SelectedValue; $dttDate->Day = $this->lstDay->SelectedValue; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = false; $this->objPerson->DobYearApproximateFlag = true; break; case self::DobApproximateYearAndDay: if ($this->objPerson->DateOfBirth) { $dttDate = new QDateTime($this->objPerson->DateOfBirth); $dttDate->Year = QDateTime::Now()->Year; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } } else { $dttDate = QDateTime::Now(); $dttDate->Month -= 6; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = true; $this->objPerson->DobYearApproximateFlag = true; break; default: throw new Exception('Invalid DOB Type'); } $this->objPerson->RefreshAge(false); // Deceased Flag and Date if ($this->objPerson->DeceasedFlag = $this->chkDeceased->Checked) { $this->objPerson->DateDeceased = $this->dtxDateDeceased->DateTime; // Also unsubscribe from church newsletter $objList = CommunicationList::LoadByToken('allchurch_nl'); if ($objList->IsPersonAssociated($this->objPerson)) { $objList->UnassociatePerson($this->objPerson); } } else { $this->objPerson->DateDeceased = null; } $this->objPerson->Save(); $this->objPerson->RefreshNameItemAssociations(); // Refresh Name of teh Household (if applicable) if ($this->objPerson->HouseholdAsHead) { $this->objPerson->HouseholdAsHead->RefreshName(); } foreach ($this->objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { $objHouseholdParticipation->Household->RefreshMembers(); } QApplication::ExecuteJavaScript('document.location = "#general";'); }