/** * Given a Temp File Path, this will save the database record AND copy the file at the temporary file path * to the file assets directory for headshots * @param string $strTempFilePath * @return void */ public function SaveHeadShot($strTempFilePath) { // Figure out the Image Type $mixImageInfo = getimagesize($strTempFilePath); switch ($mixImageInfo['mime']) { case 'image/gif': $this->intImageTypeId = ImageType::gif; break; case 'image/jpeg': $this->intImageTypeId = ImageType::jpg; break; case 'image/png': $this->intImageTypeId = ImageType::png; break; default: throw new QCallerException('Image Type Not Supported: ' . $mixImageInfo['mime']); } // Start the Transaction HeadShot::GetDatabase()->TransactionBegin(); // Save the DB Record, Make Folders (if appicable) and Save the File $this->Save(); QApplication::MakeDirectory($this->Folder, 0777); copy($strTempFilePath, $this->Path); chmod($this->Path, 0777); // Commit the Transaction HeadShot::GetDatabase()->TransactionCommit(); }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = HeadShot::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from HeadShot, given the clauses above $this->DataSource = HeadShot::QueryArray($objCondition, $objClauses); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, HeadShot::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Given a temporary file path on the server, this will save the file as a HeadShot for this Person * @param string $strTempFilePath * @param QDateTime $dttDateUploaded optional parameter -- will be set to Now() if null is passed in * @return HeadShot */ public function SaveHeadShot($strTempFilePath, $dttDateUploaded = null) { $objHeadShot = new HeadShot(); $objHeadShot->PersonId = $this->intId; $objHeadShot->DateUploaded = $dttDateUploaded ? $dttDateUploaded : QDateTime::Now(); $objHeadShot->SaveHeadShot($strTempFilePath); return $objHeadShot; }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->dttDateOfBirth) { $objObject->dttDateOfBirth = $objObject->dttDateOfBirth->__toString(QDateTime::FormatSoap); } if ($objObject->dttDateDeceased) { $objObject->dttDateDeceased = $objObject->dttDateDeceased->__toString(QDateTime::FormatSoap); } if ($objObject->objCurrentHeadShot) { $objObject->objCurrentHeadShot = HeadShot::GetSoapObjectFromObject($objObject->objCurrentHeadShot, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCurrentHeadShotId = null; } } if ($objObject->objMailingAddress) { $objObject->objMailingAddress = Address::GetSoapObjectFromObject($objObject->objMailingAddress, false); } else { if (!$blnBindRelatedObjects) { $objObject->intMailingAddressId = null; } } if ($objObject->objStewardshipAddress) { $objObject->objStewardshipAddress = Address::GetSoapObjectFromObject($objObject->objStewardshipAddress, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipAddressId = null; } } if ($objObject->objPrimaryPhone) { $objObject->objPrimaryPhone = Phone::GetSoapObjectFromObject($objObject->objPrimaryPhone, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPrimaryPhoneId = null; } } if ($objObject->objPrimaryEmail) { $objObject->objPrimaryEmail = Email::GetSoapObjectFromObject($objObject->objPrimaryEmail, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPrimaryEmailId = null; } } if ($objObject->objCoPrimaryObject) { $objObject->objCoPrimaryObject = Person::GetSoapObjectFromObject($objObject->objCoPrimaryObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCoPrimary = null; } } return $objObject; }
public function btnSave_Click() { $this->objPerson->SetCurrentHeadShot(null); foreach ($this->imgHeadShotArrayToDelete as $imgHeadShot) { if ($imgHeadShot->ActionParameter) { $objHeadShot = HeadShot::Load($imgHeadShot->ActionParameter); if ($objHeadShot->PersonId == $this->objPerson->Id) { $objHeadShot->Delete(); } } } foreach ($this->imgHeadShotArray as $imgHeadShot) { if (!$imgHeadShot->ActionParameter) { $objHeadShot = $this->objPerson->SaveHeadShot($imgHeadShot->ImagePath); } else { $objHeadShot = HeadShot::Load($imgHeadShot->ActionParameter); } if ($this->strSelectedImageControlId == $imgHeadShot->ControlId) { $this->objPerson->SetCurrentHeadShot($objHeadShot); } } QApplication::ExecuteJavaScript('document.location = "#general";'); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this HeadShotMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing HeadShot object creation - defaults to CreateOrEdit * @return HeadShotMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objHeadShot = HeadShot::Load($intId); // HeadShot was found -- return it! if ($objHeadShot) { return new HeadShotMetaControl($objParentObject, $objHeadShot); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a HeadShot object with PK arguments: ' . $intId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new HeadShotMetaControl($objParentObject, new HeadShot()); }
/** * Refresh this MetaControl with Data from the local Person object. * @param boolean $blnReload reload Person from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objPerson->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objPerson->Id; } } if ($this->lstMembershipStatusType) { $this->lstMembershipStatusType->SelectedValue = $this->objPerson->MembershipStatusTypeId; } if ($this->lblMembershipStatusTypeId) { $this->lblMembershipStatusTypeId->Text = $this->objPerson->MembershipStatusTypeId ? MembershipStatusType::$NameArray[$this->objPerson->MembershipStatusTypeId] : null; } if ($this->lstMaritalStatusType) { $this->lstMaritalStatusType->SelectedValue = $this->objPerson->MaritalStatusTypeId; } if ($this->lblMaritalStatusTypeId) { $this->lblMaritalStatusTypeId->Text = $this->objPerson->MaritalStatusTypeId ? MaritalStatusType::$NameArray[$this->objPerson->MaritalStatusTypeId] : null; } if ($this->txtFirstName) { $this->txtFirstName->Text = $this->objPerson->FirstName; } if ($this->lblFirstName) { $this->lblFirstName->Text = $this->objPerson->FirstName; } if ($this->txtMiddleName) { $this->txtMiddleName->Text = $this->objPerson->MiddleName; } if ($this->lblMiddleName) { $this->lblMiddleName->Text = $this->objPerson->MiddleName; } if ($this->txtLastName) { $this->txtLastName->Text = $this->objPerson->LastName; } if ($this->lblLastName) { $this->lblLastName->Text = $this->objPerson->LastName; } if ($this->txtMailingLabel) { $this->txtMailingLabel->Text = $this->objPerson->MailingLabel; } if ($this->lblMailingLabel) { $this->lblMailingLabel->Text = $this->objPerson->MailingLabel; } if ($this->txtPriorLastNames) { $this->txtPriorLastNames->Text = $this->objPerson->PriorLastNames; } if ($this->lblPriorLastNames) { $this->lblPriorLastNames->Text = $this->objPerson->PriorLastNames; } if ($this->txtNickname) { $this->txtNickname->Text = $this->objPerson->Nickname; } if ($this->lblNickname) { $this->lblNickname->Text = $this->objPerson->Nickname; } if ($this->txtTitle) { $this->txtTitle->Text = $this->objPerson->Title; } if ($this->lblTitle) { $this->lblTitle->Text = $this->objPerson->Title; } if ($this->txtSuffix) { $this->txtSuffix->Text = $this->objPerson->Suffix; } if ($this->lblSuffix) { $this->lblSuffix->Text = $this->objPerson->Suffix; } if ($this->txtGender) { $this->txtGender->Text = $this->objPerson->Gender; } if ($this->lblGender) { $this->lblGender->Text = $this->objPerson->Gender; } if ($this->calDateOfBirth) { $this->calDateOfBirth->DateTime = $this->objPerson->DateOfBirth; } if ($this->lblDateOfBirth) { $this->lblDateOfBirth->Text = sprintf($this->objPerson->DateOfBirth) ? $this->objPerson->__toString($this->strDateOfBirthDateTimeFormat) : null; } if ($this->chkDobYearApproximateFlag) { $this->chkDobYearApproximateFlag->Checked = $this->objPerson->DobYearApproximateFlag; } if ($this->lblDobYearApproximateFlag) { $this->lblDobYearApproximateFlag->Text = $this->objPerson->DobYearApproximateFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->chkDobGuessedFlag) { $this->chkDobGuessedFlag->Checked = $this->objPerson->DobGuessedFlag; } if ($this->lblDobGuessedFlag) { $this->lblDobGuessedFlag->Text = $this->objPerson->DobGuessedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->txtAge) { $this->txtAge->Text = $this->objPerson->Age; } if ($this->lblAge) { $this->lblAge->Text = $this->objPerson->Age; } if ($this->chkDeceasedFlag) { $this->chkDeceasedFlag->Checked = $this->objPerson->DeceasedFlag; } if ($this->lblDeceasedFlag) { $this->lblDeceasedFlag->Text = $this->objPerson->DeceasedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->calDateDeceased) { $this->calDateDeceased->DateTime = $this->objPerson->DateDeceased; } if ($this->lblDateDeceased) { $this->lblDateDeceased->Text = sprintf($this->objPerson->DateDeceased) ? $this->objPerson->__toString($this->strDateDeceasedDateTimeFormat) : null; } if ($this->lstCurrentHeadShot) { $this->lstCurrentHeadShot->RemoveAllItems(); $this->lstCurrentHeadShot->AddItem(QApplication::Translate('- Select One -'), null); $objCurrentHeadShotArray = HeadShot::LoadAll(); if ($objCurrentHeadShotArray) { foreach ($objCurrentHeadShotArray as $objCurrentHeadShot) { $objListItem = new QListItem($objCurrentHeadShot->__toString(), $objCurrentHeadShot->Id); if ($this->objPerson->CurrentHeadShot && $this->objPerson->CurrentHeadShot->Id == $objCurrentHeadShot->Id) { $objListItem->Selected = true; } $this->lstCurrentHeadShot->AddItem($objListItem); } } } if ($this->lblCurrentHeadShotId) { $this->lblCurrentHeadShotId->Text = $this->objPerson->CurrentHeadShot ? $this->objPerson->CurrentHeadShot->__toString() : null; } if ($this->lstMailingAddress) { $this->lstMailingAddress->RemoveAllItems(); $this->lstMailingAddress->AddItem(QApplication::Translate('- Select One -'), null); $objMailingAddressArray = Address::LoadAll(); if ($objMailingAddressArray) { foreach ($objMailingAddressArray as $objMailingAddress) { $objListItem = new QListItem($objMailingAddress->__toString(), $objMailingAddress->Id); if ($this->objPerson->MailingAddress && $this->objPerson->MailingAddress->Id == $objMailingAddress->Id) { $objListItem->Selected = true; } $this->lstMailingAddress->AddItem($objListItem); } } } if ($this->lblMailingAddressId) { $this->lblMailingAddressId->Text = $this->objPerson->MailingAddress ? $this->objPerson->MailingAddress->__toString() : null; } if ($this->lstStewardshipAddress) { $this->lstStewardshipAddress->RemoveAllItems(); $this->lstStewardshipAddress->AddItem(QApplication::Translate('- Select One -'), null); $objStewardshipAddressArray = Address::LoadAll(); if ($objStewardshipAddressArray) { foreach ($objStewardshipAddressArray as $objStewardshipAddress) { $objListItem = new QListItem($objStewardshipAddress->__toString(), $objStewardshipAddress->Id); if ($this->objPerson->StewardshipAddress && $this->objPerson->StewardshipAddress->Id == $objStewardshipAddress->Id) { $objListItem->Selected = true; } $this->lstStewardshipAddress->AddItem($objListItem); } } } if ($this->lblStewardshipAddressId) { $this->lblStewardshipAddressId->Text = $this->objPerson->StewardshipAddress ? $this->objPerson->StewardshipAddress->__toString() : null; } if ($this->lstPrimaryPhone) { $this->lstPrimaryPhone->RemoveAllItems(); $this->lstPrimaryPhone->AddItem(QApplication::Translate('- Select One -'), null); $objPrimaryPhoneArray = Phone::LoadAll(); if ($objPrimaryPhoneArray) { foreach ($objPrimaryPhoneArray as $objPrimaryPhone) { $objListItem = new QListItem($objPrimaryPhone->__toString(), $objPrimaryPhone->Id); if ($this->objPerson->PrimaryPhone && $this->objPerson->PrimaryPhone->Id == $objPrimaryPhone->Id) { $objListItem->Selected = true; } $this->lstPrimaryPhone->AddItem($objListItem); } } } if ($this->lblPrimaryPhoneId) { $this->lblPrimaryPhoneId->Text = $this->objPerson->PrimaryPhone ? $this->objPerson->PrimaryPhone->__toString() : null; } if ($this->lstPrimaryEmail) { $this->lstPrimaryEmail->RemoveAllItems(); $this->lstPrimaryEmail->AddItem(QApplication::Translate('- Select One -'), null); $objPrimaryEmailArray = Email::LoadAll(); if ($objPrimaryEmailArray) { foreach ($objPrimaryEmailArray as $objPrimaryEmail) { $objListItem = new QListItem($objPrimaryEmail->__toString(), $objPrimaryEmail->Id); if ($this->objPerson->PrimaryEmail && $this->objPerson->PrimaryEmail->Id == $objPrimaryEmail->Id) { $objListItem->Selected = true; } $this->lstPrimaryEmail->AddItem($objListItem); } } } if ($this->lblPrimaryEmailId) { $this->lblPrimaryEmailId->Text = $this->objPerson->PrimaryEmail ? $this->objPerson->PrimaryEmail->__toString() : null; } if ($this->chkCanMailFlag) { $this->chkCanMailFlag->Checked = $this->objPerson->CanMailFlag; } if ($this->lblCanMailFlag) { $this->lblCanMailFlag->Text = $this->objPerson->CanMailFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->chkCanPhoneFlag) { $this->chkCanPhoneFlag->Checked = $this->objPerson->CanPhoneFlag; } if ($this->lblCanPhoneFlag) { $this->lblCanPhoneFlag->Text = $this->objPerson->CanPhoneFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->chkCanEmailFlag) { $this->chkCanEmailFlag->Checked = $this->objPerson->CanEmailFlag; } if ($this->lblCanEmailFlag) { $this->lblCanEmailFlag->Text = $this->objPerson->CanEmailFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->txtPrimaryAddressText) { $this->txtPrimaryAddressText->Text = $this->objPerson->PrimaryAddressText; } if ($this->lblPrimaryAddressText) { $this->lblPrimaryAddressText->Text = $this->objPerson->PrimaryAddressText; } if ($this->txtPrimaryCityText) { $this->txtPrimaryCityText->Text = $this->objPerson->PrimaryCityText; } if ($this->lblPrimaryCityText) { $this->lblPrimaryCityText->Text = $this->objPerson->PrimaryCityText; } if ($this->txtPrimaryStateText) { $this->txtPrimaryStateText->Text = $this->objPerson->PrimaryStateText; } if ($this->lblPrimaryStateText) { $this->lblPrimaryStateText->Text = $this->objPerson->PrimaryStateText; } if ($this->txtPrimaryZipCodeText) { $this->txtPrimaryZipCodeText->Text = $this->objPerson->PrimaryZipCodeText; } if ($this->lblPrimaryZipCodeText) { $this->lblPrimaryZipCodeText->Text = $this->objPerson->PrimaryZipCodeText; } if ($this->txtPrimaryPhoneText) { $this->txtPrimaryPhoneText->Text = $this->objPerson->PrimaryPhoneText; } if ($this->lblPrimaryPhoneText) { $this->lblPrimaryPhoneText->Text = $this->objPerson->PrimaryPhoneText; } if ($this->chkPublicCreationFlag) { $this->chkPublicCreationFlag->Checked = $this->objPerson->PublicCreationFlag; } if ($this->lblPublicCreationFlag) { $this->lblPublicCreationFlag->Text = $this->objPerson->PublicCreationFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstCoPrimaryObject) { $this->lstCoPrimaryObject->RemoveAllItems(); $this->lstCoPrimaryObject->AddItem(QApplication::Translate('- Select One -'), null); $objCoPrimaryObjectArray = Person::LoadAll(); if ($objCoPrimaryObjectArray) { foreach ($objCoPrimaryObjectArray as $objCoPrimaryObject) { $objListItem = new QListItem($objCoPrimaryObject->__toString(), $objCoPrimaryObject->Id); if ($this->objPerson->CoPrimaryObject && $this->objPerson->CoPrimaryObject->Id == $objCoPrimaryObject->Id) { $objListItem->Selected = true; } $this->lstCoPrimaryObject->AddItem($objListItem); } } } if ($this->lblCoPrimary) { $this->lblCoPrimary->Text = $this->objPerson->CoPrimaryObject ? $this->objPerson->CoPrimaryObject->__toString() : null; } if ($this->lstHouseholdAsHead) { $this->lstHouseholdAsHead->RemoveAllItems(); $this->lstHouseholdAsHead->AddItem(QApplication::Translate('- Select One -'), null); $objHouseholdArray = Household::LoadAll(); if ($objHouseholdArray) { foreach ($objHouseholdArray as $objHousehold) { $objListItem = new QListItem($objHousehold->__toString(), $objHousehold->Id); if ($objHousehold->HeadPersonId == $this->objPerson->Id) { $objListItem->Selected = true; } $this->lstHouseholdAsHead->AddItem($objListItem); } } // Because Household's HouseholdAsHead is not null, if a value is already selected, it cannot be changed. if ($this->lstHouseholdAsHead->SelectedValue) { $this->lstHouseholdAsHead->Enabled = false; } else { $this->lstHouseholdAsHead->Enabled = true; } } if ($this->lblHouseholdAsHead) { $this->lblHouseholdAsHead->Text = $this->objPerson->HouseholdAsHead ? $this->objPerson->HouseholdAsHead->__toString() : null; } if ($this->lstPublicLogin) { $this->lstPublicLogin->RemoveAllItems(); $this->lstPublicLogin->AddItem(QApplication::Translate('- Select One -'), null); $objPublicLoginArray = PublicLogin::LoadAll(); if ($objPublicLoginArray) { foreach ($objPublicLoginArray as $objPublicLogin) { $objListItem = new QListItem($objPublicLogin->__toString(), $objPublicLogin->Id); if ($objPublicLogin->PersonId == $this->objPerson->Id) { $objListItem->Selected = true; } $this->lstPublicLogin->AddItem($objListItem); } } } if ($this->lblPublicLogin) { $this->lblPublicLogin->Text = $this->objPerson->PublicLogin ? $this->objPerson->PublicLogin->__toString() : null; } if ($this->lstCheckingAccountLookups) { $this->lstCheckingAccountLookups->RemoveAllItems(); $objAssociatedArray = $this->objPerson->GetCheckingAccountLookupArray(); $objCheckingAccountLookupArray = CheckingAccountLookup::LoadAll(); if ($objCheckingAccountLookupArray) { foreach ($objCheckingAccountLookupArray as $objCheckingAccountLookup) { $objListItem = new QListItem($objCheckingAccountLookup->__toString(), $objCheckingAccountLookup->Id); foreach ($objAssociatedArray as $objAssociated) { if ($objAssociated->Id == $objCheckingAccountLookup->Id) { $objListItem->Selected = true; } } $this->lstCheckingAccountLookups->AddItem($objListItem); } } } if ($this->lblCheckingAccountLookups) { $objAssociatedArray = $this->objPerson->GetCheckingAccountLookupArray(); $strItems = array(); foreach ($objAssociatedArray as $objAssociated) { $strItems[] = $objAssociated->__toString(); } $this->lblCheckingAccountLookups->Text = implode($strGlue, $strItems); } if ($this->lstCommunicationLists) { $this->lstCommunicationLists->RemoveAllItems(); $objAssociatedArray = $this->objPerson->GetCommunicationListArray(); $objCommunicationListArray = CommunicationList::LoadAll(); if ($objCommunicationListArray) { foreach ($objCommunicationListArray as $objCommunicationList) { $objListItem = new QListItem($objCommunicationList->__toString(), $objCommunicationList->Id); foreach ($objAssociatedArray as $objAssociated) { if ($objAssociated->Id == $objCommunicationList->Id) { $objListItem->Selected = true; } } $this->lstCommunicationLists->AddItem($objListItem); } } } if ($this->lblCommunicationLists) { $objAssociatedArray = $this->objPerson->GetCommunicationListArray(); $strItems = array(); foreach ($objAssociatedArray as $objAssociated) { $strItems[] = $objAssociated->__toString(); } $this->lblCommunicationLists->Text = implode($strGlue, $strItems); } if ($this->lstNameItems) { $this->lstNameItems->RemoveAllItems(); $objAssociatedArray = $this->objPerson->GetNameItemArray(); $objNameItemArray = NameItem::LoadAll(); if ($objNameItemArray) { foreach ($objNameItemArray as $objNameItem) { $objListItem = new QListItem($objNameItem->__toString(), $objNameItem->Id); foreach ($objAssociatedArray as $objAssociated) { if ($objAssociated->Id == $objNameItem->Id) { $objListItem->Selected = true; } } $this->lstNameItems->AddItem($objListItem); } } } if ($this->lblNameItems) { $objAssociatedArray = $this->objPerson->GetNameItemArray(); $strItems = array(); foreach ($objAssociatedArray as $objAssociated) { $strItems[] = $objAssociated->__toString(); } $this->lblNameItems->Text = implode($strGlue, $strItems); } }