/** * 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 ParentPagerProgram */ public static function CreateOrUpdateForMsSqlRow($objRow) { $intServerIdentifier = $objRow['lngProgramID']; $strName = trim($objRow['strProgram']); $strDescription = trim($objRow['strDescription']); $objParentPagerProgram = ParentPagerProgram::LoadByServerIdentifier($intServerIdentifier); if (!$objParentPagerProgram) { $objParentPagerProgram = new ParentPagerProgram(); $objParentPagerProgram->ServerIdentifier = $intServerIdentifier; } $objParentPagerProgram->Name = $strName; $objParentPagerProgram->Description = $strDescription; $objParentPagerProgram->Save(); return $objParentPagerProgram; }
/** * 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 ParentPagerAttendantHistory */ public static function CreateOrUpdateForMsSqlRow($objRow) { $intServerIdentifier = $objRow['lngAttendantHistoryID']; $intIndividualIdentifier = $objRow['lngIndividualID']; $intStationIdentifier = $objRow['lngStationID']; $intPeriodIdentifier = $objRow['lngPeriodID']; $intProgramIdentifier = $objRow['lngProgramID']; $dttDateIn = new QDateTime($objRow['dtmStartDateTime']); $dttDateOut = new QDateTime($objRow['dtmEndDateTime']); $objParentPagerAttendantHistory = ParentPagerAttendantHistory::LoadByServerIdentifier($intServerIdentifier); if (!$objParentPagerAttendantHistory) { $objParentPagerAttendantHistory = new ParentPagerAttendantHistory(); $objParentPagerAttendantHistory->ServerIdentifier = $intServerIdentifier; } $objParentPagerAttendantHistory->ParentPagerIndividual = ParentPagerIndividual::LoadByServerIdentifier($intIndividualIdentifier); $objParentPagerAttendantHistory->ParentPagerStation = ParentPagerStation::LoadByServerIdentifier($intStationIdentifier); $objParentPagerAttendantHistory->ParentPagerPeriod = ParentPagerPeriod::LoadByServerIdentifier($intPeriodIdentifier); $objParentPagerAttendantHistory->ParentPagerProgram = ParentPagerProgram::LoadByServerIdentifier($intProgramIdentifier); $objParentPagerAttendantHistory->DateIn = $dttDateIn; $objParentPagerAttendantHistory->DateOut = $dttDateOut; $objParentPagerAttendantHistory->Save(); return $objParentPagerAttendantHistory; }
$strPkColumnName = 'lngPeriodID'; $intRowCount = GetRowCount($strTableName); $intCurrentRow = 0; $objResult = GetPkResultForTableColumn($strTableName, $strPkColumnName); while ($objRow = mssql_fetch_assoc($objResult)) { $objRow = GetRowForTableColumnRow($strTableName, $strPkColumnName, $objRow); ParentPagerPeriod::CreateOrUpdateForMsSqlRow($objRow); } $strTableName = 'tblProgram'; $strPkColumnName = 'lngProgramID'; $intRowCount = GetRowCount($strTableName); $intCurrentRow = 0; $objResult = GetPkResultForTableColumn($strTableName, $strPkColumnName); while ($objRow = mssql_fetch_assoc($objResult)) { $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); }
/** * 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 = ParentPagerProgram::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 ParentPagerProgram, given the clauses above $this->DataSource = ParentPagerProgram::QueryArray($objCondition, $objClauses); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objParentPagerIndividual) { $objObject->objParentPagerIndividual = ParentPagerIndividual::GetSoapObjectFromObject($objObject->objParentPagerIndividual, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerIndividualId = null; } } if ($objObject->objParentPagerStation) { $objObject->objParentPagerStation = ParentPagerStation::GetSoapObjectFromObject($objObject->objParentPagerStation, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerStationId = null; } } if ($objObject->objParentPagerPeriod) { $objObject->objParentPagerPeriod = ParentPagerPeriod::GetSoapObjectFromObject($objObject->objParentPagerPeriod, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerPeriodId = null; } } if ($objObject->objParentPagerProgram) { $objObject->objParentPagerProgram = ParentPagerProgram::GetSoapObjectFromObject($objObject->objParentPagerProgram, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParentPagerProgramId = null; } } if ($objObject->dttDateIn) { $objObject->dttDateIn = $objObject->dttDateIn->__toString(QDateTime::FormatSoap); } if ($objObject->dttDateOut) { $objObject->dttDateOut = $objObject->dttDateOut->__toString(QDateTime::FormatSoap); } return $objObject; }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, ParentPagerProgram::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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 ParentPagerProgramMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing ParentPagerProgram object creation - defaults to CreateOrEdit * @return ParentPagerProgramMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objParentPagerProgram = ParentPagerProgram::Load($intId); // ParentPagerProgram was found -- return it! if ($objParentPagerProgram) { return new ParentPagerProgramMetaControl($objParentObject, $objParentPagerProgram); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a ParentPagerProgram 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 ParentPagerProgramMetaControl($objParentObject, new ParentPagerProgram()); }
/** * Refresh this MetaControl with Data from the local ParentPagerAttendantHistory object. * @param boolean $blnReload reload ParentPagerAttendantHistory from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objParentPagerAttendantHistory->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objParentPagerAttendantHistory->Id; } } if ($this->txtServerIdentifier) { $this->txtServerIdentifier->Text = $this->objParentPagerAttendantHistory->ServerIdentifier; } if ($this->lblServerIdentifier) { $this->lblServerIdentifier->Text = $this->objParentPagerAttendantHistory->ServerIdentifier; } if ($this->lstParentPagerIndividual) { $this->lstParentPagerIndividual->RemoveAllItems(); if (!$this->blnEditMode) { $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->objParentPagerAttendantHistory->ParentPagerIndividual && $this->objParentPagerAttendantHistory->ParentPagerIndividual->Id == $objParentPagerIndividual->Id) { $objListItem->Selected = true; } $this->lstParentPagerIndividual->AddItem($objListItem); } } } if ($this->lblParentPagerIndividualId) { $this->lblParentPagerIndividualId->Text = $this->objParentPagerAttendantHistory->ParentPagerIndividual ? $this->objParentPagerAttendantHistory->ParentPagerIndividual->__toString() : null; } if ($this->lstParentPagerStation) { $this->lstParentPagerStation->RemoveAllItems(); $this->lstParentPagerStation->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerStationArray = ParentPagerStation::LoadAll(); if ($objParentPagerStationArray) { foreach ($objParentPagerStationArray as $objParentPagerStation) { $objListItem = new QListItem($objParentPagerStation->__toString(), $objParentPagerStation->Id); if ($this->objParentPagerAttendantHistory->ParentPagerStation && $this->objParentPagerAttendantHistory->ParentPagerStation->Id == $objParentPagerStation->Id) { $objListItem->Selected = true; } $this->lstParentPagerStation->AddItem($objListItem); } } } if ($this->lblParentPagerStationId) { $this->lblParentPagerStationId->Text = $this->objParentPagerAttendantHistory->ParentPagerStation ? $this->objParentPagerAttendantHistory->ParentPagerStation->__toString() : null; } if ($this->lstParentPagerPeriod) { $this->lstParentPagerPeriod->RemoveAllItems(); $this->lstParentPagerPeriod->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerPeriodArray = ParentPagerPeriod::LoadAll(); if ($objParentPagerPeriodArray) { foreach ($objParentPagerPeriodArray as $objParentPagerPeriod) { $objListItem = new QListItem($objParentPagerPeriod->__toString(), $objParentPagerPeriod->Id); if ($this->objParentPagerAttendantHistory->ParentPagerPeriod && $this->objParentPagerAttendantHistory->ParentPagerPeriod->Id == $objParentPagerPeriod->Id) { $objListItem->Selected = true; } $this->lstParentPagerPeriod->AddItem($objListItem); } } } if ($this->lblParentPagerPeriodId) { $this->lblParentPagerPeriodId->Text = $this->objParentPagerAttendantHistory->ParentPagerPeriod ? $this->objParentPagerAttendantHistory->ParentPagerPeriod->__toString() : null; } if ($this->lstParentPagerProgram) { $this->lstParentPagerProgram->RemoveAllItems(); $this->lstParentPagerProgram->AddItem(QApplication::Translate('- Select One -'), null); $objParentPagerProgramArray = ParentPagerProgram::LoadAll(); if ($objParentPagerProgramArray) { foreach ($objParentPagerProgramArray as $objParentPagerProgram) { $objListItem = new QListItem($objParentPagerProgram->__toString(), $objParentPagerProgram->Id); if ($this->objParentPagerAttendantHistory->ParentPagerProgram && $this->objParentPagerAttendantHistory->ParentPagerProgram->Id == $objParentPagerProgram->Id) { $objListItem->Selected = true; } $this->lstParentPagerProgram->AddItem($objListItem); } } } if ($this->lblParentPagerProgramId) { $this->lblParentPagerProgramId->Text = $this->objParentPagerAttendantHistory->ParentPagerProgram ? $this->objParentPagerAttendantHistory->ParentPagerProgram->__toString() : null; } if ($this->calDateIn) { $this->calDateIn->DateTime = $this->objParentPagerAttendantHistory->DateIn; } if ($this->lblDateIn) { $this->lblDateIn->Text = sprintf($this->objParentPagerAttendantHistory->DateIn) ? $this->objParentPagerAttendantHistory->__toString($this->strDateInDateTimeFormat) : null; } if ($this->calDateOut) { $this->calDateOut->DateTime = $this->objParentPagerAttendantHistory->DateOut; } if ($this->lblDateOut) { $this->lblDateOut->Text = sprintf($this->objParentPagerAttendantHistory->DateOut) ? $this->objParentPagerAttendantHistory->__toString($this->strDateOutDateTimeFormat) : null; } }