/** * This will create a new record or update an existing record given the MS SQL Data Row * @param string[] $objRow the mssql_fetch_assoc row result from MS SQL Server * @return ParentPagerHousehold */ public static function CreateOrUpdateForMsSqlRow($objRow) { $intServerIdentifier = $objRow['lngHouseHoldID']; $strName = trim($objRow['strHouseHold']); $objParentPagerHousehold = ParentPagerHousehold::LoadByServerIdentifier($intServerIdentifier); if (!$objParentPagerHousehold) { $objParentPagerHousehold = new ParentPagerHousehold(); $objParentPagerHousehold->ServerIdentifier = $intServerIdentifier; $objParentPagerHousehold->HiddenFlag = false; $objParentPagerHousehold->ParentPagerSyncStatusTypeId = ParentPagerSyncStatusType::NotYetSynced; } $objParentPagerHousehold->Name = $strName; $objParentPagerHousehold->Save(); return $objParentPagerHousehold; }
/** * This will create a new record or update an existing record given the MS SQL Data Row * @param string[] $objRow the mssql_fetch_assoc row result from MS SQL Server * @return ParentPagerIndividual */ public static function CreateOrUpdateForMsSqlRow($objRow) { $intServerIdentifier = $objRow['lngIndividualID']; $strFirstName = trim($objRow['strFirstName']); $strMiddleName = trim($objRow['strMiddleName']); $strLastName = trim($objRow['strLastName']); $strPrefix = trim($objRow['strPrefix']); $strSuffix = trim($objRow['strSuffix']); $strNickname = trim($objRow['strNickName']); $intGraduationYear = $objRow['sintGraduationYear']; $strDateOfBirth = trim($objRow['dtBirthDate']); $strGender = trim(strtoupper($objRow['chrGender'])); if (!$strGender) { $strGender = null; } $strHouseholdId = trim($objRow['lngHouseholdID']); $objParentPagerIndividual = ParentPagerIndividual::LoadByServerIdentifier($intServerIdentifier); if (!$objParentPagerIndividual) { $objParentPagerIndividual = new ParentPagerIndividual(); $objParentPagerIndividual->ServerIdentifier = $intServerIdentifier; $objParentPagerIndividual->HiddenFlag = false; $objParentPagerIndividual->ParentPagerSyncStatusTypeId = ParentPagerSyncStatusType::NotYetSynced; } $objParentPagerIndividual->FirstName = $strFirstName; $objParentPagerIndividual->MiddleName = $strMiddleName; $objParentPagerIndividual->LastName = $strLastName; $objParentPagerIndividual->Prefix = $strPrefix; $objParentPagerIndividual->Suffix = $strSuffix; $objParentPagerIndividual->Nickname = $strNickname; $objParentPagerIndividual->GraduationYear = $intGraduationYear; $objParentPagerIndividual->DateOfBirth = $strDateOfBirth ? new QDateTime($strDateOfBirth) : null; $objParentPagerIndividual->Gender = $strGender; if ($strHouseholdId) { $objParentPagerIndividual->ParentPagerHousehold = ParentPagerHousehold::LoadByServerIdentifier($strHouseholdId); } $objParentPagerIndividual->Save(); return $objParentPagerIndividual; }
/** * Refresh this MetaControl with Data from the local ParentPagerIndividual object. * @param boolean $blnReload reload ParentPagerIndividual from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objParentPagerIndividual->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objParentPagerIndividual->Id; } } if ($this->txtServerIdentifier) { $this->txtServerIdentifier->Text = $this->objParentPagerIndividual->ServerIdentifier; } if ($this->lblServerIdentifier) { $this->lblServerIdentifier->Text = $this->objParentPagerIndividual->ServerIdentifier; } if ($this->lstPerson) { $this->lstPerson->RemoveAllItems(); $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null); $objPersonArray = Person::LoadAll(); if ($objPersonArray) { foreach ($objPersonArray as $objPerson) { $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id); if ($this->objParentPagerIndividual->Person && $this->objParentPagerIndividual->Person->Id == $objPerson->Id) { $objListItem->Selected = true; } $this->lstPerson->AddItem($objListItem); } } } if ($this->lblPersonId) { $this->lblPersonId->Text = $this->objParentPagerIndividual->Person ? $this->objParentPagerIndividual->Person->__toString() : null; } if ($this->chkHiddenFlag) { $this->chkHiddenFlag->Checked = $this->objParentPagerIndividual->HiddenFlag; } if ($this->lblHiddenFlag) { $this->lblHiddenFlag->Text = $this->objParentPagerIndividual->HiddenFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstParentPagerSyncStatusType) { $this->lstParentPagerSyncStatusType->SelectedValue = $this->objParentPagerIndividual->ParentPagerSyncStatusTypeId; } if ($this->lblParentPagerSyncStatusTypeId) { $this->lblParentPagerSyncStatusTypeId->Text = $this->objParentPagerIndividual->ParentPagerSyncStatusTypeId ? ParentPagerSyncStatusType::$NameArray[$this->objParentPagerIndividual->ParentPagerSyncStatusTypeId] : null; } if ($this->lstParentPagerHousehold) { $this->lstParentPagerHousehold->RemoveAllItems(); $this->lstParentPagerHousehold->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerHouseholdArray = ParentPagerHousehold::LoadAll(); if ($objParentPagerHouseholdArray) { foreach ($objParentPagerHouseholdArray as $objParentPagerHousehold) { $objListItem = new QListItem($objParentPagerHousehold->__toString(), $objParentPagerHousehold->Id); if ($this->objParentPagerIndividual->ParentPagerHousehold && $this->objParentPagerIndividual->ParentPagerHousehold->Id == $objParentPagerHousehold->Id) { $objListItem->Selected = true; } $this->lstParentPagerHousehold->AddItem($objListItem); } } } if ($this->lblParentPagerHouseholdId) { $this->lblParentPagerHouseholdId->Text = $this->objParentPagerIndividual->ParentPagerHousehold ? $this->objParentPagerIndividual->ParentPagerHousehold->__toString() : null; } if ($this->txtFirstName) { $this->txtFirstName->Text = $this->objParentPagerIndividual->FirstName; } if ($this->lblFirstName) { $this->lblFirstName->Text = $this->objParentPagerIndividual->FirstName; } if ($this->txtMiddleName) { $this->txtMiddleName->Text = $this->objParentPagerIndividual->MiddleName; } if ($this->lblMiddleName) { $this->lblMiddleName->Text = $this->objParentPagerIndividual->MiddleName; } if ($this->txtLastName) { $this->txtLastName->Text = $this->objParentPagerIndividual->LastName; } if ($this->lblLastName) { $this->lblLastName->Text = $this->objParentPagerIndividual->LastName; } if ($this->txtPrefix) { $this->txtPrefix->Text = $this->objParentPagerIndividual->Prefix; } if ($this->lblPrefix) { $this->lblPrefix->Text = $this->objParentPagerIndividual->Prefix; } if ($this->txtSuffix) { $this->txtSuffix->Text = $this->objParentPagerIndividual->Suffix; } if ($this->lblSuffix) { $this->lblSuffix->Text = $this->objParentPagerIndividual->Suffix; } if ($this->txtNickname) { $this->txtNickname->Text = $this->objParentPagerIndividual->Nickname; } if ($this->lblNickname) { $this->lblNickname->Text = $this->objParentPagerIndividual->Nickname; } if ($this->txtGraduationYear) { $this->txtGraduationYear->Text = $this->objParentPagerIndividual->GraduationYear; } if ($this->lblGraduationYear) { $this->lblGraduationYear->Text = $this->objParentPagerIndividual->GraduationYear; } if ($this->txtGender) { $this->txtGender->Text = $this->objParentPagerIndividual->Gender; } if ($this->lblGender) { $this->lblGender->Text = $this->objParentPagerIndividual->Gender; } if ($this->calDateOfBirth) { $this->calDateOfBirth->DateTime = $this->objParentPagerIndividual->DateOfBirth; } if ($this->lblDateOfBirth) { $this->lblDateOfBirth->Text = sprintf($this->objParentPagerIndividual->DateOfBirth) ? $this->objParentPagerIndividual->__toString($this->strDateOfBirthDateTimeFormat) : null; } }
/** * Refresh this MetaControl with Data from the local ParentPagerAddress object. * @param boolean $blnReload reload ParentPagerAddress from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objParentPagerAddress->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objParentPagerAddress->Id; } } if ($this->txtServerIdentifier) { $this->txtServerIdentifier->Text = $this->objParentPagerAddress->ServerIdentifier; } if ($this->lblServerIdentifier) { $this->lblServerIdentifier->Text = $this->objParentPagerAddress->ServerIdentifier; } if ($this->lstParentPagerIndividual) { $this->lstParentPagerIndividual->RemoveAllItems(); $this->lstParentPagerIndividual->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerIndividualArray = ParentPagerIndividual::LoadAll(); if ($objParentPagerIndividualArray) { foreach ($objParentPagerIndividualArray as $objParentPagerIndividual) { $objListItem = new QListItem($objParentPagerIndividual->__toString(), $objParentPagerIndividual->Id); if ($this->objParentPagerAddress->ParentPagerIndividual && $this->objParentPagerAddress->ParentPagerIndividual->Id == $objParentPagerIndividual->Id) { $objListItem->Selected = true; } $this->lstParentPagerIndividual->AddItem($objListItem); } } } if ($this->lblParentPagerIndividualId) { $this->lblParentPagerIndividualId->Text = $this->objParentPagerAddress->ParentPagerIndividual ? $this->objParentPagerAddress->ParentPagerIndividual->__toString() : null; } if ($this->lstParentPagerHousehold) { $this->lstParentPagerHousehold->RemoveAllItems(); $this->lstParentPagerHousehold->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerHouseholdArray = ParentPagerHousehold::LoadAll(); if ($objParentPagerHouseholdArray) { foreach ($objParentPagerHouseholdArray as $objParentPagerHousehold) { $objListItem = new QListItem($objParentPagerHousehold->__toString(), $objParentPagerHousehold->Id); if ($this->objParentPagerAddress->ParentPagerHousehold && $this->objParentPagerAddress->ParentPagerHousehold->Id == $objParentPagerHousehold->Id) { $objListItem->Selected = true; } $this->lstParentPagerHousehold->AddItem($objListItem); } } } if ($this->lblParentPagerHouseholdId) { $this->lblParentPagerHouseholdId->Text = $this->objParentPagerAddress->ParentPagerHousehold ? $this->objParentPagerAddress->ParentPagerHousehold->__toString() : null; } if ($this->txtAddress1) { $this->txtAddress1->Text = $this->objParentPagerAddress->Address1; } if ($this->lblAddress1) { $this->lblAddress1->Text = $this->objParentPagerAddress->Address1; } if ($this->txtAddress2) { $this->txtAddress2->Text = $this->objParentPagerAddress->Address2; } if ($this->lblAddress2) { $this->lblAddress2->Text = $this->objParentPagerAddress->Address2; } if ($this->txtAddress3) { $this->txtAddress3->Text = $this->objParentPagerAddress->Address3; } if ($this->lblAddress3) { $this->lblAddress3->Text = $this->objParentPagerAddress->Address3; } if ($this->txtCity) { $this->txtCity->Text = $this->objParentPagerAddress->City; } if ($this->lblCity) { $this->lblCity->Text = $this->objParentPagerAddress->City; } if ($this->txtState) { $this->txtState->Text = $this->objParentPagerAddress->State; } if ($this->lblState) { $this->lblState->Text = $this->objParentPagerAddress->State; } if ($this->txtZipCode) { $this->txtZipCode->Text = $this->objParentPagerAddress->ZipCode; } if ($this->lblZipCode) { $this->lblZipCode->Text = $this->objParentPagerAddress->ZipCode; } }
/** * Deletes all associated ParentPagerHouseholds * @return void */ public function DeleteAllParentPagerHouseholds() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateParentPagerHousehold on this unsaved Household.'); } // Get the Database Object for this Class $objDatabase = Household::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (ParentPagerHousehold::LoadArrayByHouseholdId($this->intId) as $objParentPagerHousehold) { $objParentPagerHousehold->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `parent_pager_household` WHERE `household_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
/** * 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 ParentPagerHouseholdMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing ParentPagerHousehold object creation - defaults to CreateOrEdit * @return ParentPagerHouseholdMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objParentPagerHousehold = ParentPagerHousehold::Load($intId); // ParentPagerHousehold was found -- return it! if ($objParentPagerHousehold) { return new ParentPagerHouseholdMetaControl($objParentObject, $objParentPagerHousehold); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a ParentPagerHousehold 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 ParentPagerHouseholdMetaControl($objParentObject, new ParentPagerHousehold()); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objPerson) { $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPersonId = null; } } if ($objObject->objParentPagerHousehold) { $objObject->objParentPagerHousehold = ParentPagerHousehold::GetSoapObjectFromObject($objObject->objParentPagerHousehold, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerHouseholdId = null; } } if ($objObject->dttDateOfBirth) { $objObject->dttDateOfBirth = $objObject->dttDateOfBirth->__toString(QDateTime::FormatSoap); } return $objObject; }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objParentPagerIndividual) { $objObject->objParentPagerIndividual = ParentPagerIndividual::GetSoapObjectFromObject($objObject->objParentPagerIndividual, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerIndividualId = null; } } if ($objObject->objParentPagerHousehold) { $objObject->objParentPagerHousehold = ParentPagerHousehold::GetSoapObjectFromObject($objObject->objParentPagerHousehold, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerHouseholdId = null; } } return $objObject; }
$objRow = GetRowForTableColumnRow($strTableName, $strPkColumnName, $objRow); ParentPagerProgram::CreateOrUpdateForMsSqlRow($objRow); } //////////////////////////// // ParentPager Household //////////////////////////// $strTableName = 'tblHousehold'; $strPkColumnName = 'lngHouseHoldID'; $intRowCount = GetRowCount($strTableName); $intCurrentRow = 0; $objResult = GetPkResultForTableColumn($strTableName, $strPkColumnName); while ($objRow = mssql_fetch_assoc($objResult)) { printf('[%5s/%5s]', $intCurrentRow++, $intRowCount); $objRow = GetRowForTableColumnRow($strTableName, $strPkColumnName, $objRow); print ' - ID #' . $objRow[$strPkColumnName] . ' - ' . $objRow['strHouseHold'] . "\r\n"; ParentPagerHousehold::CreateOrUpdateForMsSqlRow($objRow); } /////////////////////////// // ParentPager Individual //////////////////////////// $strTableName = 'tblIndividual'; $strPkColumnName = 'lngIndividualID'; $intRowCount = GetRowCount($strTableName); $intCurrentRow = 0; $objResult = GetPkResultForTableColumn($strTableName, $strPkColumnName); while ($objRow = mssql_fetch_assoc($objResult)) { printf('[%5s/%5s]', $intCurrentRow++, $intRowCount); $objRow = GetRowForTableColumnRow($strTableName, $strPkColumnName, $objRow); print ' - ID #' . $objRow[$strPkColumnName] . ' - ' . $objRow['strFirstName'] . ' ' . $objRow['strLastName'] . "\r\n"; ParentPagerIndividual::CreateOrUpdateForMsSqlRow($objRow); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, ParentPagerHousehold::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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 = ParentPagerHousehold::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 ParentPagerHousehold, given the clauses above $this->DataSource = ParentPagerHousehold::QueryArray($objCondition, $objClauses); }