protected function SetupAuthorizationLevel()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intAuthorizationLevelId = QApplication::QueryString('intAuthorizationLevelId');
     if ($intAuthorizationLevelId) {
         $this->objAuthorizationLevel = AuthorizationLevel::Load($intAuthorizationLevelId);
         if (!$this->objAuthorizationLevel) {
             throw new Exception('Could not find a AuthorizationLevel object with PK arguments: ' . $intAuthorizationLevelId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objAuthorizationLevel = new AuthorizationLevel();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
 protected function dtgAuthorizationLevel_Bind()
 {
     // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll()
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     $this->dtgAuthorizationLevel->TotalItemCount = AuthorizationLevel::CountAll();
     // Setup the $objClauses Array
     $objClauses = array();
     // 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->dtgAuthorizationLevel->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->dtgAuthorizationLevel->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be the array of all AuthorizationLevel objects, given the clauses above
     $this->dtgAuthorizationLevel->DataSource = AuthorizationLevel::LoadAll($objClauses);
 }
 /**
  * Refresh this MetaControl with Data from the local RoleModuleAuthorization object.
  * @param boolean $blnReload reload RoleModuleAuthorization from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objRoleModuleAuthorization->Reload();
     }
     if ($this->lblRoleModuleAuthorizationId) {
         if ($this->blnEditMode) {
             $this->lblRoleModuleAuthorizationId->Text = $this->objRoleModuleAuthorization->RoleModuleAuthorizationId;
         }
     }
     if ($this->lstRoleModule) {
         $this->lstRoleModule->RemoveAllItems();
         $this->lstRoleModule->AddItem(QApplication::Translate('- Select One -'), null);
         $objRoleModuleArray = RoleModule::LoadAll();
         if ($objRoleModuleArray) {
             foreach ($objRoleModuleArray as $objRoleModule) {
                 $objListItem = new QListItem($objRoleModule->__toString(), $objRoleModule->RoleModuleId);
                 if ($this->objRoleModuleAuthorization->RoleModule && $this->objRoleModuleAuthorization->RoleModule->RoleModuleId == $objRoleModule->RoleModuleId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRoleModule->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRoleModuleId) {
         $this->lblRoleModuleId->Text = $this->objRoleModuleAuthorization->RoleModule ? $this->objRoleModuleAuthorization->RoleModule->__toString() : null;
     }
     if ($this->lstAuthorization) {
         $this->lstAuthorization->RemoveAllItems();
         $this->lstAuthorization->AddItem(QApplication::Translate('- Select One -'), null);
         $objAuthorizationArray = Authorization::LoadAll();
         if ($objAuthorizationArray) {
             foreach ($objAuthorizationArray as $objAuthorization) {
                 $objListItem = new QListItem($objAuthorization->__toString(), $objAuthorization->AuthorizationId);
                 if ($this->objRoleModuleAuthorization->Authorization && $this->objRoleModuleAuthorization->Authorization->AuthorizationId == $objAuthorization->AuthorizationId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAuthorization->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAuthorizationId) {
         $this->lblAuthorizationId->Text = $this->objRoleModuleAuthorization->Authorization ? $this->objRoleModuleAuthorization->Authorization->__toString() : null;
     }
     if ($this->lstAuthorizationLevel) {
         $this->lstAuthorizationLevel->RemoveAllItems();
         $this->lstAuthorizationLevel->AddItem(QApplication::Translate('- Select One -'), null);
         $objAuthorizationLevelArray = AuthorizationLevel::LoadAll();
         if ($objAuthorizationLevelArray) {
             foreach ($objAuthorizationLevelArray as $objAuthorizationLevel) {
                 $objListItem = new QListItem($objAuthorizationLevel->__toString(), $objAuthorizationLevel->AuthorizationLevelId);
                 if ($this->objRoleModuleAuthorization->AuthorizationLevel && $this->objRoleModuleAuthorization->AuthorizationLevel->AuthorizationLevelId == $objAuthorizationLevel->AuthorizationLevelId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAuthorizationLevel->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAuthorizationLevelId) {
         $this->lblAuthorizationLevelId->Text = $this->objRoleModuleAuthorization->AuthorizationLevel ? $this->objRoleModuleAuthorization->AuthorizationLevel->__toString() : null;
     }
     if ($this->lstCreatedByObject) {
         $this->lstCreatedByObject->RemoveAllItems();
         $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null);
         $objCreatedByObjectArray = UserAccount::LoadAll();
         if ($objCreatedByObjectArray) {
             foreach ($objCreatedByObjectArray as $objCreatedByObject) {
                 $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId);
                 if ($this->objRoleModuleAuthorization->CreatedByObject && $this->objRoleModuleAuthorization->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCreatedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCreatedBy) {
         $this->lblCreatedBy->Text = $this->objRoleModuleAuthorization->CreatedByObject ? $this->objRoleModuleAuthorization->CreatedByObject->__toString() : null;
     }
     if ($this->calCreationDate) {
         $this->calCreationDate->DateTime = $this->objRoleModuleAuthorization->CreationDate;
     }
     if ($this->lblCreationDate) {
         $this->lblCreationDate->Text = sprintf($this->objRoleModuleAuthorization->CreationDate) ? $this->objRoleModuleAuthorization->__toString($this->strCreationDateDateTimeFormat) : null;
     }
     if ($this->lstModifiedByObject) {
         $this->lstModifiedByObject->RemoveAllItems();
         $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null);
         $objModifiedByObjectArray = UserAccount::LoadAll();
         if ($objModifiedByObjectArray) {
             foreach ($objModifiedByObjectArray as $objModifiedByObject) {
                 $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId);
                 if ($this->objRoleModuleAuthorization->ModifiedByObject && $this->objRoleModuleAuthorization->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstModifiedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblModifiedBy) {
         $this->lblModifiedBy->Text = $this->objRoleModuleAuthorization->ModifiedByObject ? $this->objRoleModuleAuthorization->ModifiedByObject->__toString() : null;
     }
     if ($this->lblModifiedDate) {
         if ($this->blnEditMode) {
             $this->lblModifiedDate->Text = $this->objRoleModuleAuthorization->ModifiedDate;
         }
     }
 }
 /**
  * Internally called method to assist with early binding of objects
  * on load methods.  Can only early-bind references that this class owns in the database.
  * @param string $strParentAlias the alias of the parent (if any)
  * @param string $strAlias the alias of this object
  * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding
  * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion)
  */
 public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion)
 {
     if ($strAlias) {
         $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `role_transaction_type_authorization` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`role_transaction_type_authorization_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`role_transaction_type_authorization_id` AS `%s__%s__role_transaction_type_authorization_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`role_id` AS `%s__%s__role_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`transaction_type_id` AS `%s__%s__transaction_type_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`authorization_level_id` AS `%s__%s__authorization_level_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`created_by` AS `%s__%s__created_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`creation_date` AS `%s__%s__creation_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_by` AS `%s__%s__modified_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_date` AS `%s__%s__modified_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias));
         $strParentAlias = $strParentAlias . '__' . $strAlias;
     }
     if (is_array($objExpansionMap)) {
         foreach ($objExpansionMap as $strKey => $objValue) {
             switch ($strKey) {
                 case 'role_id':
                     try {
                         Role::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 case 'transaction_type_id':
                     try {
                         TransactionType::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 case 'authorization_level_id':
                     try {
                         AuthorizationLevel::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 case 'created_by':
                     try {
                         UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 case 'modified_by':
                     try {
                         UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion);
                         break;
                     } catch (QCallerException $objExc) {
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 default:
                     throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey));
             }
         }
     }
 }
 protected function lstAuthorizationLevel_Create()
 {
     $this->lstAuthorizationLevel = new QListBox($this);
     $this->lstAuthorizationLevel->Name = QApplication::Translate('Authorization Level');
     $this->lstAuthorizationLevel->AddItem(QApplication::Translate('- Select One -'), null);
     $objAuthorizationLevelArray = AuthorizationLevel::LoadAll();
     if ($objAuthorizationLevelArray) {
         foreach ($objAuthorizationLevelArray as $objAuthorizationLevel) {
             $objListItem = new QListItem($objAuthorizationLevel->__toString(), $objAuthorizationLevel->AuthorizationLevelId);
             if ($this->objRoleModuleAuthorization->AuthorizationLevel && $this->objRoleModuleAuthorization->AuthorizationLevel->AuthorizationLevelId == $objAuthorizationLevel->AuthorizationLevelId) {
                 $objListItem->Selected = true;
             }
             $this->lstAuthorizationLevel->AddItem($objListItem);
         }
     }
 }
 /**
  * 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 = AuthorizationLevel::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 AuthorizationLevel, given the clauses above
     $this->DataSource = AuthorizationLevel::QueryArray($objCondition, $objClauses);
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, AuthorizationLevel::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 AuthorizationLevelMetaControl
  * @param integer $intAuthorizationLevelId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing AuthorizationLevel object creation - defaults to CreateOrEdit
  * @return AuthorizationLevelMetaControl
  */
 public static function Create($objParentObject, $intAuthorizationLevelId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intAuthorizationLevelId)) {
         $objAuthorizationLevel = AuthorizationLevel::Load($intAuthorizationLevelId);
         // AuthorizationLevel was found -- return it!
         if ($objAuthorizationLevel) {
             return new AuthorizationLevelMetaControl($objParentObject, $objAuthorizationLevel);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a AuthorizationLevel object with PK arguments: ' . $intAuthorizationLevelId);
             }
         }
         // 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 AuthorizationLevelMetaControl($objParentObject, new AuthorizationLevel());
 }
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objRoleModule) {
         $objObject->objRoleModule = RoleModule::GetSoapObjectFromObject($objObject->objRoleModule, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intRoleModuleId = null;
         }
     }
     if ($objObject->objAuthorization) {
         $objObject->objAuthorization = Authorization::GetSoapObjectFromObject($objObject->objAuthorization, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intAuthorizationId = null;
         }
     }
     if ($objObject->objAuthorizationLevel) {
         $objObject->objAuthorizationLevel = AuthorizationLevel::GetSoapObjectFromObject($objObject->objAuthorizationLevel, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intAuthorizationLevelId = null;
         }
     }
     if ($objObject->objCreatedByObject) {
         $objObject->objCreatedByObject = UserAccount::GetSoapObjectFromObject($objObject->objCreatedByObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCreatedBy = null;
         }
     }
     if ($objObject->dttCreationDate) {
         $objObject->dttCreationDate = $objObject->dttCreationDate->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->objModifiedByObject) {
         $objObject->objModifiedByObject = UserAccount::GetSoapObjectFromObject($objObject->objModifiedByObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intModifiedBy = null;
         }
     }
     return $objObject;
 }
 public function dtgAuthorizationLevel_Bind()
 {
     // Get Total Count b/c of Pagination
     $this->dtgAuthorizationLevel->TotalItemCount = AuthorizationLevel::CountAll();
     $objClauses = array();
     if ($objClause = $this->dtgAuthorizationLevel->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     if ($objClause = $this->dtgAuthorizationLevel->LimitClause) {
         array_push($objClauses, $objClause);
     }
     $this->dtgAuthorizationLevel->DataSource = AuthorizationLevel::LoadAll($objClauses);
 }