Expand() public static method

public static Expand ( $objNode, QQCondition $objJoinCondition = null )
$objJoinCondition QQCondition
Example #1
0
 protected function Form_PreRender()
 {
     $objExpansionMap[UserAccount::ExpandCreatedByObject] = true;
     $objExpansionMap[UserAccount::ExpandRole] = true;
     // Get Total Count b/c of Pagination
     $this->dtgUserAccount->TotalItemCount = UserAccount::CountAll();
     if ($this->dtgUserAccount->TotalItemCount == 0) {
         $this->dtgUserAccount->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = $this->dtgUserAccount->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgUserAccount->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::UserAccount()->CreatedByObject)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::UserAccount()->Role)) {
             $this->dtgUserAccount->DataSource = UserAccount::LoadAll($objClauses);
         }
         $this->dtgUserAccount->ShowHeader = true;
     }
 }
 public function __construct(QPanel $pnlContent, $strReturnUrl)
 {
     $this->pnlContent = $pnlContent;
     $this->pnlContent->Template = dirname(__FILE__) . '/EditGroupParticipationDelegate.tpl.php';
     // Throw Exception if Group Cannot have Explicitly Defined Participants
     if (!$this->pnlContent->objGroup->IsGroupCanHaveExplicitlyDefinedParticipants()) {
         throw new Exception('Group Cannot have Explicitly Defined Participants');
     }
     $this->strReturnUrl = $strReturnUrl;
     $this->objParticipationArray = GroupParticipation::LoadArrayByPersonIdGroupId($this->pnlContent->objPerson->Id, $this->pnlContent->objGroup->Id, QQ::OrderBy(QQN::GroupParticipation()->GroupRole->Name, QQN::GroupParticipation()->DateStart), QQ::Clause(QQ::Expand(QQN::GroupParticipation()->GroupRole)));
     $this->chkIsAuthorizedSender = new QCheckBox($this->pnlContent);
     $this->chkIsAuthorizedSender->Name = '  Is Authorized Sender';
     if (GroupAuthorizedSender::LoadByGroupIdPersonId($this->pnlContent->objGroup->Id, $this->pnlContent->objPerson->Id)) {
         $this->chkIsAuthorizedSender->Checked = true;
     } else {
         $this->chkIsAuthorizedSender->Checked = false;
     }
     $this->lblCurrentRoles = new QLabel($this->pnlContent);
     $this->lblCurrentRoles->Name = 'Current Roles';
     $this->lblCurrentRoles->HtmlEntities = false;
     $this->lblCurrentRoles_Refresh();
     $this->dtgParticipations = new QDataGrid($this->pnlContent);
     $this->dtgParticipations->AddColumn(new QDataGridColumn('Role', '<?= $_CONTROL->ParentControl->objDelegate->RenderRole($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgParticipations->AddColumn(new QDataGridColumn('Participation Started', '<?= $_CONTROL->ParentControl->objDelegate->RenderDateStart($_ITEM); ?>', 'HtmlEntities=false', 'Width=150px'));
     $this->dtgParticipations->AddColumn(new QDataGridColumn('Participation Ended', '<?= $_CONTROL->ParentControl->objDelegate->RenderDateEnd($_ITEM); ?>', 'HtmlEntities=false', 'Width=150px'));
     $this->dtgParticipations->SetDataBinder('dtgParticipations_Bind', $this);
     $this->pxyEdit = new QControlProxy($this->pnlContent);
     $this->pxyEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this->pnlContent, 'pxyEdit_Click'));
     $this->pxyEdit->AddAction(new QClickEvent(), new QTerminateAction());
     $this->dlgEdit_Setup();
 }
 /**
  * Load a single AssetTransactionCheckout object with expansion map of Contact and UserAccount,
  * by TransactionId
  * @param integer $intAssetId
  * @return object $objAssetTransactionCheckout
  */
 public function LoadWithToContactToUserByTransactionId($intAssetTransactionId = null)
 {
     $objClauses = array();
     array_push($objClauses, QQ::Expand(QQN::AssetTransactionCheckout()->ToContact));
     array_push($objClauses, QQ::Expand(QQN::AssetTransactionCheckout()->ToUser));
     $objAssetTransactionCheckout = AssetTransactionCheckout::QuerySingle(QQ::Equal(QQN::AssetTransactionCheckout()->AssetTransactionId, $intAssetTransactionId), $objClauses);
     return $objAssetTransactionCheckout;
 }
Example #4
0
 public function __construct(QcodoClass $objQcodoClass, $objParentControl, $strControlId = null)
 {
     parent::__construct($objParentControl, $strControlId);
     // We're looking at ALL Methods/Operations
     $this->objQcodoClass = $objQcodoClass;
     $this->strUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/' . $this->objQcodoClass->Name . '/Constants';
     $this->strTemplate = 'ConstantPanel.tpl.php';
     $this->objConstantArray = $this->objQcodoClass->GetQcodoConstantArray(QQ::Clause(QQ::OrderBy(QQN::QcodoConstant()->Variable->Name), QQ::Expand(QQN::QcodoConstant()->Variable)));
 }
 public function testSelectSubsetInExpand()
 {
     $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Select(QQN::Person()->LastName), QQ::Expand(QQN::Person()->ProjectAsManager, null, QQ::Select(QQN::Person()->ProjectAsManager->Spent)), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNull($objPerson->FirstName, "FirstName should be null, since it was not selected");
         $this->assertNotNull($objPerson->Id, "Id should not be null since it's always added to the select list");
         $this->assertNotNull($objPerson->_ProjectAsManager->Id, "ProjectAsManager->Id should not be null since id's are always added to the select list");
         $this->assertNull($objPerson->_ProjectAsManager->Name, "ProjectAsManager->Name should be null since it was not selected");
     }
 }
 protected function Go_Click()
 {
     QApplication::$blnLocalCache = false;
     $timeNoCache = -microtime(true);
     $a = Person::LoadAll();
     // noncached loads
     $timeNoCache += microtime(true);
     QApplication::$blnLocalCache = true;
     $timeLoad1Cached = -microtime(true);
     $a = Person::LoadAll();
     // noncached loads
     $timeLoad1Cached += microtime(true);
     $timeLoad2Cached = -microtime(true);
     $a = Person::LoadAll();
     // cached loads
     $timeLoad2Cached += microtime(true);
     QApplication::$blnLocalCache = new QCacheProviderLocalMemory(array());
     $timeLoad3Cached = -microtime(true);
     $a = Person::LoadAll();
     // noncached loads
     $timeLoad3Cached += microtime(true);
     $timeLoad4Cached = -microtime(true);
     $a = Person::LoadAll();
     // cached loads
     $timeLoad4Cached += microtime(true);
     $this->pnlTiny->Text = sprintf("Load No Cache: %2.1f%% \n", 100 * $timeNoCache / $timeNoCache) . sprintf("Populate Cache: %2.1f%% \n", 100 * $timeLoad1Cached / $timeNoCache) . sprintf("Load With Cache: %2.1f%% \n", 100 * $timeLoad2Cached / $timeNoCache) . sprintf("Populate LocalCacheProvider: %2.1f%% \n", 100 * $timeLoad3Cached / $timeNoCache) . sprintf("Load LocalCacheProvider: %2.1f%% \n", 100 * $timeLoad4Cached / $timeNoCache);
     $cond = QQ::Equal(QQN::Project()->ProjectStatusTypeId, ProjectStatusType::Open);
     $clauses[] = QQ::Expand(QQN::Project()->ManagerPerson);
     Project::ClearCache();
     Person::ClearCache();
     QApplication::$blnLocalCache = false;
     $timeNoCache = -microtime(true);
     $a = Project::QueryArray($cond, $clauses);
     // noncached loads
     $timeNoCache += microtime(true);
     QApplication::$blnLocalCache = true;
     $timeLoad1Cached = -microtime(true);
     $a = Project::QueryArray($cond, $clauses);
     // noncached loads
     $timeLoad1Cached += microtime(true);
     $timeLoad2Cached = -microtime(true);
     $a = Project::QueryArray($cond, $clauses);
     // cached loads
     $timeLoad2Cached += microtime(true);
     QApplication::$blnLocalCache = new QCacheProviderLocalMemory(array());
     $timeLoad3Cached = -microtime(true);
     $a = Project::QueryArray($cond, $clauses);
     // noncached loads
     $timeLoad3Cached += microtime(true);
     $timeLoad4Cached = -microtime(true);
     $a = Project::QueryArray($cond, $clauses);
     // cached loads
     $timeLoad4Cached += microtime(true);
     $this->pnlBig->Text = sprintf("Load No Cache: %2.1f%% \n", 100 * $timeNoCache / $timeNoCache) . sprintf("Populate Cache: %2.1f%% \n", 100 * $timeLoad1Cached / $timeNoCache) . sprintf("Load With Cache: %2.1f%% \n", 100 * $timeLoad2Cached / $timeNoCache) . sprintf("Populate LocalCacheProvider: %2.1f%% \n", 100 * $timeLoad3Cached / $timeNoCache) . sprintf("Load LocalCacheProvider: %2.1f%% \n", 100 * $timeLoad4Cached / $timeNoCache);
 }
 protected function Form_Create()
 {
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     $this->ctlShortcutMenu_Create();
     if ($_GET && $_GET['method'] == 'delete') {
         $objAudit = Audit::Load($_GET['intAuditId']);
         if ($objAudit) {
             $objAudit->Delete();
             QApplication::Redirect("./inventory_audit_list.php");
         }
     }
     // Load an array of Audit objects using join on UserAccount.
     $this->objAuditArray = Audit::LoadArrayByEntityQtypeId(2, QQ::Clause(QQ::Expand(QQN::Audit()->CreatedByObject)));
 }
Example #8
0
 public function __get($strName)
 {
     switch ($strName) {
         case 'ShortDescriptionAsHtml':
             $strToReturn = QApplication::HtmlEntities(trim($this->strShortDescription));
             $strToReturn = str_replace("\r", '', $strToReturn);
             $strToReturn = str_replace("\n", '<br/>', $strToReturn);
             return $strToReturn;
         case 'Parameters':
             return $this->GetParameterArray(QQ::Clause(QQ::OrderBy(QQN::Parameter()->OrderNumber), QQ::Expand(QQN::Parameter()->Variable)));
             /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */
         /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */
         case 'InheritenceState':
             return $this->intInheritenceState;
             /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */
         /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */
         case 'OverridesOperation':
             return $this->objOverridesOperation;
             /* CAN BE USED ANYWHERE */
         /* CAN BE USED ANYWHERE */
         case 'Overrides':
             $objClass = $this->QcodoClass->ParentQcodoClass;
             while ($objClass) {
                 if ($objOperation = Operation::LoadByQcodoClassIdQcodoInterfaceIdName($objClass->Id, null, $this->strName)) {
                     return $objOperation;
                 }
                 $objClass = $objClass->ParentQcodoClass;
             }
             return null;
         case 'DisplayName':
             switch ($this->intInheritenceState) {
                 case InheritenceState::Interited:
                     return $this->strName . '&nbsp;<img src="/images/inherited_light.png" border="0" alt="Inherited"/>';
                 case InheritenceState::Overrides:
                     return $this->strName . '&nbsp;<img src="/images/overrides.png" border="0" alt="Overrides"/>';
                 default:
                     return $this->strName;
             }
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 protected function dtgLanguage_Create()
 {
     $this->dtgLanguage = new NarroLanguageDataGrid($this);
     $this->dtgLanguage->SortColumnIndex = 1;
     $this->dtgLanguage->SortDirection = 1;
     $this->dtgLanguage->AdditionalConditions = QQ::AndCondition(QQ::Equal(QQN::NarroLanguage()->Active, true), QQ::Equal(QQN::NarroLanguage()->NarroProjectProgressAsLanguage->ProjectId, $this->objProject->ProjectId));
     $this->dtgLanguage->AdditionalClauses = array(QQ::Expand(QQN::NarroLanguage()->NarroProjectProgressAsLanguage));
     $colLanguage = $this->dtgLanguage->MetaAddColumn(QQN::NarroLanguage()->LanguageName);
     $colLanguage->Name = t('Language');
     $colProgress = new QDataGridColumn(t('Progress'));
     $colProgress->Html = '<?=$_CONTROL->ParentControl->dtgLanguage_PercentTranslated_Render($_ITEM)?>';
     $colProgress->HtmlEntities = false;
     $colProgress->OrderByClause = QQ::OrderBy(QQN::NarroLanguage()->NarroProjectProgressAsLanguage->ProgressPercent, 1, QQN::NarroLanguage()->NarroProjectProgressAsLanguage->FuzzyTextCount, 1);
     $colProgress->ReverseOrderByClause = QQ::OrderBy(QQN::NarroLanguage()->NarroProjectProgressAsLanguage->ProgressPercent, 0, QQN::NarroLanguage()->NarroProjectProgressAsLanguage->FuzzyTextCount, 0);
     $this->dtgLanguage->AddColumn($colProgress);
     //$colLanguage = $this->dtgLanguage->MetaAddColumn(QQN::NarroLanguage()->NarroProjectProgressAsLanguage->ProgressPercent);
 }
Example #10
0
 protected function Form_Create()
 {
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     $this->ctlShortcutMenu_Create();
     //QApplication::$Database[1]->EnableProfiling();
     if ($_GET && $_GET['method'] == 'delete') {
         $objAudit = Audit::Load($_GET['intAuditId']);
         if ($objAudit) {
             // Set the relationship to ON DELETE CASCADE so that the AuditScans will be automatically deleted when deleting the Audit Object
             $objAudit->Delete();
             QApplication::Redirect("./asset_audit_list.php");
         }
     }
     // Load an array of Audit objects using join on UserAccount.
     $this->objAuditArray = Audit::LoadAll(QQ::Clause(QQ::Expand(QQN::Audit()->CreatedByObject)));
 }
 public function testAlias3()
 {
     $emptySelect = QQ::Select();
     $emptySelect->SetSkipPrimaryKey(true);
     $nVoyel = QQ::Alias(QQN::Person()->ProjectAsManager->Milestone, 'voyel');
     $nConson = QQ::Alias(QQN::Person()->ProjectAsManager->Milestone, 'conson');
     $objPersonArray = Person::QueryArray(QQ::IsNotNull($nConson->Id), QQ::Clause(QQ::Expand($nVoyel, QQ::In($nVoyel->Name, array('Milestone A', 'Milestone E', 'Milestone I')), $emptySelect), QQ::Expand($nConson, QQ::NotIn($nConson->Name, array('Milestone A', 'Milestone E', 'Milestone I')), $emptySelect), QQ::GroupBy(QQN::Person()->Id), QQ::Minimum($nVoyel->Name, 'min_voyel'), QQ::Minimum($nConson->Name, 'min_conson'), QQ::Expand(QQN::Person()->ProjectAsManager, null, $emptySelect), QQ::Minimum(QQN::Person()->ProjectAsManager->Id, 'dummy'), QQ::Select(QQN::Person()->FirstName, QQN::Person()->LastName)));
     $this->assertEquals(3, sizeof($objPersonArray));
     $obj = $this->verifyObjectPropertyHelper($objPersonArray, 'LastName', 'Doe');
     $this->assertNull($obj->GetVirtualAttribute('min_voyel'));
     $this->assertEquals('Milestone F', $obj->GetVirtualAttribute('min_conson'));
     $obj = $this->verifyObjectPropertyHelper($objPersonArray, 'LastName', 'Ho');
     $this->assertEquals('Milestone E', $obj->GetVirtualAttribute('min_voyel'));
     $this->assertEquals('Milestone D', $obj->GetVirtualAttribute('min_conson'));
     $obj = $this->verifyObjectPropertyHelper($objPersonArray, 'LastName', 'Wolfe');
     $this->assertEquals('Milestone A', $obj->GetVirtualAttribute('min_voyel'));
     $this->assertEquals('Milestone B', $obj->GetVirtualAttribute('min_conson'));
 }
Example #12
0
 /**
  * This will email the Username information (or Usernames) for a given Email address,
  * if any is found.  If none is found, this will do nothing.
  * @param string $strEmailAddress
  */
 public static function RetrieveUsernameForEmail($strEmailAddress)
 {
     // Look for associated accounts
     $objPublicLoginArray = PublicLogin::QueryArray(QQ::Equal(QQN::PublicLogin()->Person->PrimaryEmail->Address, $strEmailAddress), QQ::Expand(QQN::PublicLogin()->Person));
     // If none found, return
     if (!count($objPublicLoginArray)) {
         // Setup email info
         $strFromAddress = 'ALCF my.alcf Account Support <*****@*****.**>';
         $strToAddress = trim(strtolower($strEmailAddress));
         $strSubject = 'Account Support: Retreive Your Username';
         // Setup the SubstitutionArray
         $strArray = array();
         // Setup Always-Used Fields
         $strArray['CONTACT'] = strip_tags(Registry::GetValue('contact_sentence_my_alcf_support'));
         $strArray['EMAIL'] = $strEmailAddress;
         $strTemplateName = 'retrieve_username_none';
         OutgoingEmailQueue::QueueFromTemplate($strTemplateName, $strArray, $strToAddress, $strFromAddress, $strSubject);
         return;
     }
     // Setup email info
     $strFromAddress = 'ALCF my.alcf Account Support <*****@*****.**>';
     $strToAddress = trim(strtolower($strEmailAddress));
     $strSubject = 'Account Support: Retreive Your Username';
     // Setup the SubstitutionArray
     $strArray = array();
     // Setup Always-Used Fields
     $strArray['PERSON_NAME'] = $objPublicLoginArray[0]->Person->Name;
     $strArray['CONTACT'] = strip_tags(Registry::GetValue('contact_sentence_my_alcf_support'));
     if (count($objPublicLoginArray) == 1) {
         // Template
         $strTemplateName = 'retrieve_username_single';
         $strArray['USERNAME'] = $objPublicLoginArray[0]->Username;
     } else {
         // Template
         $strTemplateName = 'retrieve_username_multiple';
         $strUsernameList = array();
         foreach ($objPublicLoginArray as $objPublicLogin) {
             $strUsernameList[] = 'Username:  '******'USERNAMES'] = implode("\r\n", $strUsernameList);
     }
     OutgoingEmailQueue::QueueFromTemplate($strTemplateName, $strArray, $strToAddress, $strFromAddress, $strSubject);
 }
 public function __construct(NarroText $objText, $objParentObject, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     $this->blnAutoRenderChildren = true;
     $this->intTextId = $objText->TextId;
     $this->strText = sprintf('<span class="instructions">%s</span>', t('User comments'));
     $this->dtgComments = new NarroTextCommentDataGrid($this);
     $colComment = $this->dtgComments->MetaAddColumn(QQN::NarroTextComment()->CommentText);
     $colComment->HtmlEntities = false;
     $colComment->Html = '<?=$_CONTROL->ParentControl->colComment_Render($_ITEM)?>';
     $this->dtgComments->ShowFilter = false;
     $this->dtgComments->ShowHeader = false;
     $this->dtgComments->AdditionalConditions = QQ::Equal(QQN::NarroTextComment()->TextId, $objText->TextId);
     $this->dtgComments->AdditionalClauses = array(QQ::OrderBy(QQN::NarroTextComment()->Created, 1), QQ::Expand(QQN::NarroTextComment()->Language), QQ::Expand(QQN::NarroTextComment()->User));
     $this->txtComment = new QTextBox($this);
     $this->txtComment->Name = t('Comment');
     $this->txtComment->TextMode = QTextMode::MultiLine;
     $this->txtComment->PreferedRenderMethod = 'Render';
     $this->txtComment->Columns = 80;
     $this->txtComment->ToolTip = t('Enter your comments here');
     $this->txtComment->CssClass = 'comment';
     $this->txtComment->DisplayStyle = QDisplayStyle::Block;
     $this->txtComment->Display = QApplication::HasPermissionForThisLang('Can comment');
     $this->btnSave = new QImageButton($this);
     $this->btnSave->AlternateText = t('Add comment');
     $this->btnSave->CssClass = 'imgbutton save';
     $this->btnSave->ToolTip = $this->btnSave->AlternateText;
     $this->btnSave->ImageUrl = __NARRO_IMAGE_ASSETS__ . '/comment.png';
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
     $this->btnSave->Display = QApplication::HasPermissionForThisLang('Can comment');
 }
Example #14
0
 protected function Form_Create()
 {
     // Define the DataGrid -- note that the Meta DataGrid is a DataGrid, itself --
     // so let's just use it as a datagrid
     $this->dtgProjects = new ProjectDataGrid($this);
     // Only show projects whose status is "open"
     $this->dtgProjects->AdditionalConditions = QQ::Equal(QQN::Project()->ProjectStatusTypeId, ProjectStatusType::Open);
     //expand on the ManagerPerson's login, since we're displaying it
     $this->dtgProjects->AdditionalClauses = array(QQ::Expand(QQN::Project()->ManagerPerson), QQ::Expand(QQN::Project()->ManagerPerson->Login));
     // DataBinding is already configured -- so we do not need to worry about it
     // But remember that dtgProjects is just a regular datagrid, as well
     // So we can configure as we see fit, e.g. adding pagination or styling
     $this->dtgProjects->Paginator = new QPaginator($this->dtgProjects);
     $this->dtgProjects->ItemsPerPage = 6;
     $this->dtgProjects->AlternateRowStyle->CssClass = 'alternate';
     // All we need to do is to utilize the ProjectDataGrid built-in functionality
     // to create, define and setup the various columns that WE choose, in the order
     // that WE want.  NOTE that we use simple string-based property names, OR QQuery
     // node descriptors to specify what we want for each column.
     $this->dtgProjects->MetaAddColumn('Name');
     $this->dtgProjects->MetaAddColumn('StartDate');
     $this->dtgProjects->MetaAddColumn(QQN::Project()->EndDate);
     // We can easily add columns from linked/related tables.  However, to do this
     // you MUST use a QQuery node descriptor.  No string-based properties allowed.
     // Bonus: the Meta DataGrid will even automatically add sorting for columns in related tables.
     $colUsername = $this->dtgProjects->MetaAddColumn(QQN::Project()->ManagerPerson->Login->Username);
     // And remember, since it's a regular datagrid with regular columns,
     // we can stylize as we see fit
     $colUsername->BackColor = '#cef';
     $colUsername->Name = 'Manager\'s Username';
     // Also, note that MetaAddColumn and MetaAddTypeColumn can use attribute overriding as well
     $this->dtgProjects->MetaAddTypeColumn('ProjectStatusTypeId', 'ProjectStatusType', 'FontBold=true');
     $this->pxyExample = new QControlProxy($this);
     $this->pxyExample->AddAction(new QClickEvent(), new QAjaxAction('pxyExample_Click'));
     // FInally, there are even Meta methods to add an Edit Button column
     $this->dtgProjects->MetaAddEditProxyColumn($this->pxyExample, 'Click Me', 'Faux Edit Column');
 }
 protected function Form_Create()
 {
     // Define the DataGrid -- note that the DataGrid Connector is a DataGrid, itself --
     // so let's just use it as a datagrid
     $this->dtgProjects = new ProjectList($this);
     $this->dtgProjects->SetDataBinder('DefaultDataBinder', $this);
     // Only show projects whose status is "open"
     $this->objAdditionalConditions = QQ::Equal(QQN::Project()->ProjectStatusTypeId, ProjectStatusType::Open);
     //expand on the ManagerPerson's login, since we're displaying it
     $this->objAdditionalClauses = array(QQ::Expand(QQN::Project()->ManagerPerson), QQ::Expand(QQN::Project()->ManagerPerson->Login));
     // DataBinding is already configured -- so we do not need to worry about it
     // But remember that dtgProjects is just a regular datagrid, as well
     // So we can configure as we see fit, e.g. adding pagination or styling
     $this->dtgProjects->Paginator = new QPaginator($this->dtgProjects);
     $this->dtgProjects->ItemsPerPage = 6;
     $this->dtgProjects->AlternateRowCssClass = 'alternate';
     // All we need to do is to utilize the ProjectDataGrid built-in functionality
     // to create, define and setup the various columns that WE choose, in the order
     // that WE want.
     $this->dtgProjects->CreateNodeColumn('Name', QQN::Project()->Name);
     $this->dtgProjects->CreateNodeColumn('StartDate', QQN::Project()->StartDate);
     $this->dtgProjects->CreateNodeColumn("EndDate", QQN::Project()->EndDate);
     // We can easily add columns from linked/related tables.  However, to do this
     // you MUST use a QQuery node descriptor.  No string-based properties allowed.
     // Bonus: the DataGrid Connector will even automatically add sorting for columns in related tables.
     $colUsername = $this->dtgProjects->CreateNodeColumn('Username', QQN::Project()->ManagerPerson->Login->Username);
     // And remember, since it's a regular datagrid with regular columns,
     // we can stylize as we see fit
     $colUsername->CellParamsCallback = [$this, 'GetUserNameCellParams'];
     $colUsername->Name = 'Manager\'s Username';
     $colStatus = $this->dtgProjects->CreateNodeColumn('ProjectStatusType', QQN::Project()->ProjectStatusType);
     $colStatus->HtmlEntities = false;
     $colStatus->Format = '<strong>%s</strong>';
     $this->pxyExample = new QControlProxy($this);
     $this->pxyExample->AddAction(new QClickEvent(), new QAjaxAction('pxyExample_Click'));
 }
 public function dtgTranslation_Create()
 {
     $this->dtgTranslation = new NarroSuggestionDataGrid($this);
     $this->dtgTranslation->ShowFilter = false;
     $this->dtgTranslation->ShowHeader = false;
     $this->dtgTranslation->ShowFooter = false;
     $this->dtgTranslation->AdditionalClauses = array(QQ::Expand(QQN::NarroSuggestion()->User));
     $this->dtgTranslation->AdditionalConditions = QQ::AndCondition(QQ::Equal(QQN::NarroSuggestion()->LanguageId, QApplication::GetLanguageId()), QQ::Equal(QQN::NarroSuggestion()->TextId, $this->objContextInfo->Context->TextId));
     $colSuggestion = $this->dtgTranslation->MetaAddColumn('SuggestionValue');
     $colSuggestion->HtmlEntities = false;
     $colSuggestion->Html = '<?=$_CONTROL->ParentControl->dtgTranslaton_colSuggestion_Render($_ITEM)?>';
     $colActions = new QDataGridColumn('Actions');
     $colActions->HtmlEntities = false;
     $colActions->CssClass = 'actions';
     $colActions->Html = '<?=$_CONTROL->ParentControl->dtgTranslation_colActions_Render($_ITEM)?>';
     $this->dtgTranslation->AddColumn($colActions);
 }
Example #17
0
 protected function Form_Create()
 {
     if (QApplication::QueryString('intDownloadCsv')) {
         $this->RenderBegin(false);
         session_cache_limiter('must-revalidate');
         // force a "no cache" effect
         header("Pragma: hack");
         // IE chokes on "no cache", so set to something, anything, else.
         $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT";
         header($ExpStr);
         header('Content-Type: text/csv');
         header('Content-Disposition: csv; filename=skipped_records.csv');
         $file = fopen(sprintf("%s/%s_contact_skipped.csv", __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "r");
         ob_end_clean();
         while ($row = fgets($file, 1000)) {
             print $row;
             @ob_flush();
             flush();
         }
         QApplication::$JavaScriptArray = array();
         QApplication::$JavaScriptArrayHighPriority = array();
         $this->RenderEnd(false);
         exit;
     }
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     //$this->ctlShortcutMenu_Create();
     $this->pnlMain_Create();
     $this->pnlStepOne_Create();
     $this->Buttons_Create();
     $this->intStep = 1;
     $this->intSkippedRecordCount = 0;
     $this->blnImportEnd = true;
     $this->btnRemoveArray = array();
     $this->arrItemCustomField = array();
     $this->Labels_Create();
     $this->objDatabase = Asset::GetDatabase();
     // Load Custom Field
     foreach (CustomField::LoadArrayByActiveFlagEntity(1, EntityQtype::Contact) as $objCustomField) {
         $this->arrItemCustomField[$objCustomField->CustomFieldId] = $objCustomField;
     }
     $this->blnError = true;
     $intRoleId = QApplication::$objUserAccount->RoleId;
     $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, EntityQtype::Contact, 2);
     // Check the user have edit permissions
     if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) {
         $this->blnError = false;
     }
     if (isset($intCustomFieldIdArray) && count($intCustomFieldIdArray)) {
         //QApplication::$Database[1]->EnableProfiling();
         // Load restrict permisions for Custom Fields
         $objConditions = QQ::AndCondition(QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->RoleId, (string) $intRoleId), QQ::In(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->CustomFieldId, $intCustomFieldIdArray), QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->AuthorizedFlag, false));
         $objClauses = array();
         array_push($objClauses, QQ::Expand(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->EntityQtypeCustomFieldId));
         array_push($objClauses, QQ::OrderBy(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomFieldId));
         $arrRoleEntityQtypeCustomFieldAuthorization = RoleEntityQtypeCustomFieldAuthorization::QueryArray($objConditions, $objClauses);
         if ($arrRoleEntityQtypeCustomFieldAuthorization) {
             foreach ($arrRoleEntityQtypeCustomFieldAuthorization as $objRoleAuth) {
                 if (array_key_exists($objRoleAuth->EntityQtypeCustomField->CustomFieldId, $this->arrAssetCustomField)) {
                     unset($this->arrAssetCustomField[$objRoleAuth->EntityQtypeCustomField->CustomFieldId]);
                 }
             }
         }
         //QApplication::$Database[1]->OutputProfiling();
     }
     $this->intUserArray = array();
     // Load Users
     foreach (UserAccount::LoadAll() as $objUser) {
         $this->intUserArray[strtolower($objUser->Username)] = $objUser->UserAccountId;
     }
     $this->strAcceptibleMimeArray = array('text/plain' => 'txt', 'text/comma-separated-values' => 'csv', 'text/csv' => 'csv', 'text/x-comma-separated-values' => 'csv', 'application/vnd.ms-excel' => 'csv', 'application/csv' => 'csv', 'text/x-csv' => 'csv');
 }
Example #18
0
 public function testExpand()
 {
     // Test intermediate nodes on expansion
     $clauses = QQ::Clause(QQ::Expand(QQN::Milestone()->Project->ManagerPerson));
     $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses);
     $this->assertTrue(!is_null($objMilestone->Name), "Milestone 1 has a name");
     $this->assertEqual($objMilestone->Name, "Milestone A", "Milestone 1 has name of Milestone A");
     $this->assertTrue(!is_null($objMilestone->Project->Name), "Project 1 has a name");
     $this->assertEqual($objMilestone->Project->Name, "ACME Website Redesign", "Project 1 has name of ACME Website Redesign");
     $this->assertTrue(!is_null($objMilestone->Project->ManagerPerson->FirstName), "Person 7 has a name");
     $this->assertEqual($objMilestone->Project->ManagerPerson->FirstName, "Karen", "Person 7 has first name of Karen");
     $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember), QQ::OrderBy(QQN::Project()->PersonAsTeamMember->Person->LastName, QQN::Project()->PersonAsTeamMember->Person->FirstName));
     // short reach
     $objProject = Project::QuerySingle(QQ::Equal(QQN::Project()->Id, 1), $clauses);
     $objPersonArray = $objProject->_PersonAsTeamMemberArray;
     $arrNamesOnly = array();
     foreach ($objPersonArray as $item) {
         $arrNamesOnly[] = $item->FirstName . " " . $item->LastName;
     }
     $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Project Team Member expansion is correct");
     // long reach
     $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Milestone()->Project->PersonAsTeamMember), QQ::OrderBy(QQN::Milestone()->Project->PersonAsTeamMember->Person->LastName, QQN::Milestone()->Project->PersonAsTeamMember->Person->FirstName));
     $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses);
     $objPersonArray = $objMilestone->Project->_PersonAsTeamMemberArray;
     $arrNamesOnly = array();
     foreach ($objPersonArray as $item) {
         $arrNamesOnly[] = $item->FirstName . " " . $item->LastName;
     }
     $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Long reach Milestone to Project Team Member expansion is correct");
 }
Example #19
0
 protected function dtrVotes_Bind()
 {
     $this->dtrVotes->DataSource = $this->objIssue->GetIssueVoteArray(array(QQ::OrderBy(QQN::IssueVote()->Person->DisplayName), QQ::Expand(QQN::IssueVote()->Person->FirstName)));
     if (count($this->dtrVotes->DataSource) >= 8) {
         $this->dtrVotes->Height = '100px';
     } else {
         if (count($this->dtrVotes->DataSource) <= 3) {
             $this->dtrVotes->Height = '50px';
         } else {
             $this->dtrVotes->Height = null;
         }
     }
 }
 public function testSelect()
 {
     $objTest = new TypeTest();
     $objTest->TestFloat = 2.0;
     $objTest->Save();
     $objTest2 = new TypeTest();
     $objTest2->TestFloat = 3.0;
     $objTest2->Save();
     $objResArray = TypeTest::QueryArray(QQ::GreaterThan(QQ::Virtual('power2', QQ::Power(QQN::TypeTest()->TestFloat, 2.0)), 1.0), QQ::Clause(QQ::OrderBy(QQ::Virtual('power2')), QQ::Expand(QQ::Virtual('power2')), QQ::Select(QQ::Virtual('power2'))));
     $this->assertEquals(2, count($objResArray));
     if (2 == count($objResArray)) {
         $objRes = $objResArray[0];
         $this->assertNotNull($objRes);
         if ($objRes) {
             $this->assertNull($objRes->TestFloat);
             $this->assertEquals(4.0, $objRes->GetVirtualAttribute('power2'));
         }
         $objRes = $objResArray[1];
         $this->assertNotNull($objRes);
         if ($objRes) {
             $this->assertNull($objRes->TestFloat);
             $this->assertEquals(9.0, $objRes->GetVirtualAttribute('power2'));
         }
     }
     $objTest->Delete();
     $objTest2->Delete();
 }
Example #21
0
	and in doing so they can unnecessarily overengineer some pieces of functionality.
	If the focus is on getting the application functional, first, then after the application is in
	a usable state, you can profile the functionality that tends to get used more often and simply
	focus on optimizing this smaller subset of heavily-used functionality.</p>

	<p>For information about Expanding through Association Tables, please refer to the
	<a href="../qcubed_query/association.php">Handling Association Tables example</a>.</p>
</div>

<div id="demoZone">
	<h2>List All Projects and its Manager</h2>
<?php 
// Enable Profiling (we're assuming the Examples Site Database is at index 1)
// NOTE: Profiling should only be enabled when you are actively wanting to profile a specific PHP script.
// Because of SIGNIFICANT performance degradation, it should otherwise always be off.
QApplication::$Database[1]->EnableProfiling();
// Load the Project array
// The following line of code is the ONLY line of code we will modify
$objProjectArray = Project::LoadAll(QQ::Clause(QQ::Expand(QQN::Project()->ManagerPerson)));
foreach ($objProjectArray as $objProject) {
    _p(QApplication::HtmlEntities($objProject->Name) . ' is managed by ' . $objProject->ManagerPerson->FirstName . ' ' . $objProject->ManagerPerson->LastName);
    _p('<br/>', false);
}
_p('<br/>', false);
// Output Profiling Data
QApplication::$Database[1]->OutputProfiling();
?>
</div>

<?php 
require '../includes/footer.inc.php';
Example #22
0
	<h3>Get All People Who Are on a Project Managed by Karen Wolfe (Person ID #7)</h3>
<?php 
$objPersonArray = Person::QueryArray(QQ::Equal(QQN::Person()->ProjectAsTeamMember->Project->ManagerPersonId, 7), QQ::Clause(QQ::Distinct(), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName);
    _p('<br/>', false);
}
?>



	<br/>
	<h3>Get All People Who Are on a Project Managed by Karen Wolfe (Person ID #7)<br/>showing the Project which is involved in the JOIN via Expand()</h3>
	<i>Notice how some people may be listed twice, once for each project which he or she is part of that is managed by Karen Wolfe.</i><br/><br/>
<?php 
$objPersonArray = Person::QueryArray(QQ::Equal(QQN::Person()->ProjectAsTeamMember->Project->ManagerPersonId, 7), QQ::Clause(QQ::Expand(QQN::Person()->ProjectAsTeamMember->Project), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    printf('%s %s (via the "%s" project)<br/>', QApplication::HtmlEntities($objPerson->FirstName), QApplication::HtmlEntities($objPerson->LastName), QApplication::HtmlEntities($objPerson->_ProjectAsTeamMember->Name));
}
?>



	<br/>
	<h3>Same as above, but this time, use ExpandAsArray()</h3>
	<i>Notice how each person is only listed once... but each person has an internal/virtual <b>_ProjectAsTeamMemberArray</b> which may list more than one project.</i><br/><br/>
<?php 
$objPersonArray = Person::QueryArray(QQ::Equal(QQN::Person()->ProjectAsTeamMember->Project->ManagerPersonId, 7), QQ::Clause(QQ::ExpandAsArray(QQN::Person()->ProjectAsTeamMember), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName, QQN::Person()->ProjectAsTeamMember->Project->Name)));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName);
    _p('<br/>', false);
Example #23
0
 protected function Accordion_Bind()
 {
     $this->accordion->DataSource = Person::LoadAll([QQ::Expand(QQN::Person()->Address)]);
 }
Example #24
0
 protected function dtgShipmentReceipt_Bind()
 {
     // Get Total Count for Pagination
     $objClauses = array();
     $this->ctlAssetEdit->dtgShipmentReceipt->TotalItemCount = AssetTransaction::CountShipmentReceiptByAssetId($this->ctlAssetEdit->objAsset->AssetId);
     if ($this->ctlAssetEdit->dtgShipmentReceipt->TotalItemCount === 0) {
         $this->ctlAssetEdit->lblShipmentReceipt->Display = false;
         $this->ctlAssetEdit->dtgShipmentReceipt->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->ctlAssetEdit->dtgShipmentReceipt->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Transaction->Shipment)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Transaction->Receipt)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->DestinationLocation)) {
             array_push($objClauses, $objClause);
         }
         $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->ctlAssetEdit->objAsset->AssetId), QQ::OrCondition(QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6), QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 7)));
         $this->ctlAssetEdit->dtgShipmentReceipt->DataSource = AssetTransaction::QueryArray($objCondition, $objClauses);
     }
 }
Example #25
0
 /**
  * Sets the address record as the "Current" address, and all others as "Previous"
  * Address MUST be associated with the household or this will throw an exception
  * @param Address $objCurrentAddress
  * @return void
  */
 public function SetAsCurrentAddress(Address $objCurrentAddress)
 {
     if ($objCurrentAddress->HouseholdId != $this->intId) {
         throw new QCallerException('Address does not belong to this Household');
     }
     // Get any home address and home phone records for this household (and any from-split households)
     $intAddressIdArray = array();
     $intPhoneIdArray = array();
     foreach ($this->GetAddressArray() as $objAddress) {
         if ($objAddress->Id != $objCurrentAddress->Id && $objAddress->CurrentFlag) {
             $objAddress->CurrentFlag = false;
             $objAddress->Save();
         }
         $intAddressIdArray[$objAddress->Id] = true;
         foreach ($objAddress->GetPhoneArray() as $objPhone) {
             $intPhoneIdArray[$objPhone->Id] = true;
         }
     }
     // Add any old HomeAddresses from previous households
     foreach ($this->GetHouseholdSplitAsSplitArray() as $objHouseholdSplit) {
         foreach ($objHouseholdSplit->Household->GetAddressArray() as $objAddress) {
             $intAddressIdArray[$objAddress->Id] = true;
             foreach ($objAddress->GetPhoneArray() as $objPhone) {
                 $intPhoneIdArray[$objPhone->Id] = true;
             }
         }
     }
     if (!$objCurrentAddress->CurrentFlag) {
         $objCurrentAddress->CurrentFlag = true;
         $objCurrentAddress->Save();
     }
     // Update "MailingAddress" and "StewardshipAddress" info for HouseholdParticipants
     // Update "PrimaryAddressText" info for HouseholdParticipants
     foreach ($this->GetHouseholdParticipationArray(QQ::Expand(QQN::HouseholdParticipation()->Person->Id)) as $objHouseholdParticipation) {
         $objPerson = $objHouseholdParticipation->Person;
         if (array_key_exists($objPerson->MailingAddressId, $intAddressIdArray)) {
             $objPerson->MailingAddress = $objCurrentAddress;
         }
         if (array_key_exists($objPerson->StewardshipAddressId, $intAddressIdArray)) {
             $objPerson->StewardshipAddress = $objCurrentAddress;
         }
         if (array_key_exists($objPerson->PrimaryPhoneId, $intPhoneIdArray)) {
             $objPerson->PrimaryPhone = $objCurrentAddress->PrimaryPhone;
         }
         $objPerson->RefreshPrimaryContactInfo();
     }
 }
Example #26
0
 public function SetupAsset($objCaller = null)
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     // Overridden from AssetEditFormBase to add the $objCaller parameter
     $intAssetId = QApplication::QueryString('intAssetId');
     if ($intAssetId) {
         //$objCaller->objAsset = Asset::Load($intAssetId);
         // To minimize the count of queries
         $objClauses = array();
         array_push($objClauses, QQ::Expand(QQN::Asset()->AssetModel));
         array_push($objClauses, QQ::Expand(QQN::Asset()->AssetModel->Category));
         array_push($objClauses, QQ::Expand(QQN::Asset()->AssetModel->Manufacturer));
         array_push($objClauses, QQ::Expand(QQN::Asset()->ParentAsset));
         array_push($objClauses, QQ::Expand(QQN::Asset()->Location));
         array_push($objClauses, QQ::Expand(QQN::Asset()->CreatedByObject));
         $objCaller->objAsset = Asset::QuerySingle(QQ::Equal(QQN::Asset()->AssetId, $intAssetId), $objClauses);
         if (!$objCaller->objAsset) {
             throw new Exception('Could not find a Asset object with PK arguments: ' . $intAssetId);
         }
         $objCaller->strTitleVerb = QApplication::Translate('Edit');
         $objCaller->blnEditMode = true;
         $this->blnEditChild = true;
     } else {
         $objCaller->objAsset = new Asset();
         $objCaller->strTitleVerb = QApplication::Translate('Create');
         $objCaller->blnEditMode = false;
     }
     QApplication::AuthorizeEntity($objCaller->objAsset, $objCaller->blnEditMode);
 }
Example #27
0
 protected function dtgAudit_Bind()
 {
     if ($this->rblDiscrepancy->SelectedValue == 'discrepancies') {
         $objConditions = QQ::AndCondition(QQ::Equal(QQN::AuditScan()->AuditId, $_GET['intAuditId']), QQ::NotEqual(QQN::AuditScan()->Count, QQN::AuditScan()->SystemCount));
     } else {
         $objConditions = QQ::Equal(QQN::AuditScan()->AuditId, $_GET['intAuditId']);
     }
     $objAuditScanArray = AuditScan::QueryArray($objConditions, QQ::Clause(QQ::Expand(QQN::AuditScan()->Location), $this->dtgAudit->OrderByClause));
     if ($objAuditScanArray) {
         foreach ($objAuditScanArray as $objAuditScan) {
             $objAuditScan->InventoryModel = InventoryModel::QuerySingle(QQ::Equal(QQN::InventoryModel()->InventoryModelId, $objAuditScan->EntityId), QQ::Clause(QQ::Expand(QQN::InventoryModel()->InventoryModelCode)));
         }
     }
     if (count($objAuditScanArray) == 0) {
         $this->dtgAudit->ShowHeader = false;
     } else {
         $this->dtgAudit->ShowHeader = true;
     }
     $this->dtgAudit->DataSource = $objAuditScanArray;
 }
Example #28
0
 /**
  * Returns a Location object from the most recent shipment transaction for this asset
  *
  * @return Object Location
  */
 public function GetLastShippedFromLocation()
 {
     $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->AssetId), QQ::Equal(QQN::AssetTransaction()->Transaction->TransactionTypeId, 6));
     $objClauses = array();
     $objExpansionClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation);
     $objOrderByClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false);
     $objLimitClause = QQ::LimitInfo(1, 0);
     array_push($objClauses, $objExpansionClause);
     array_push($objClauses, $objOrderByClause);
     array_push($objClauses, $objLimitClause);
     $AssetTransactionArray = AssetTransaction::QueryArray($objCondition, $objClauses);
     if (count($AssetTransactionArray) > 0) {
         $Location = $AssetTransactionArray[0]->SourceLocation;
     } else {
         $Location = null;
     }
     return $Location;
 }
Example #29
0
 protected function Form_Create()
 {
     // check rigths for the Inventory to Ship
     $this->blnShowInventory = true;
     $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3);
     if ($objRoleModule->AccessFlag) {
         $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2);
         if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) {
             $this->blnShowInventory = false;
         }
     } else {
         $this->blnShowInventory = false;
     }
     // Call Setup Receipt to either load existing or create new receipt
     $this->SetupReceipt();
     // Create the Header Menu
     $this->ctlHeaderMenu_Create();
     // Create the Shortcut Menu
     $this->ctlShortcutMenu_Create();
     // Create the labels
     $this->lblHeaderReceipt_Create();
     $this->lblFromCompany_Create();
     $this->lblFromContact_Create();
     $this->lblToContact_Create();
     $this->lblToAddress_Create();
     $this->lblReceiptNumber_Create();
     $this->pnlNote_Create();
     $this->lblDueDate_Create();
     $this->lblReceiptDate_Create();
     // Create the inputs
     $this->lstFromCompany_Create();
     $this->lblNewFromCompany_Create();
     $this->lstFromContact_Create();
     $this->lblNewFromContact_Create();
     $this->lstToContact_Create();
     $this->lblNewToContact_Create();
     $this->lstToAddress_Create();
     $this->lblNewToAddress_Create();
     $this->txtNote_Create();
     // Create all custom asset fields - this must be here for tab ordering
     $this->customFields_Create();
     if ($this->blnShowInventory) {
         $this->txtNewInventoryModelCode_Create();
         $this->ctlInventorySearchTool_Create();
         $this->txtQuantity_Create();
         $this->btnAddInventory_Create();
     }
     $this->txtNewAssetCode_Create();
     $this->rblAssetType_Create();
     $this->lstAssetModel_Create();
     $this->chkAutoGenerateAssetCode_Create();
     $this->calDueDate_Create();
     $this->calDateReceived_Create();
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         $this->txtReceiptNumber_Create();
     }
     // Create the buttons
     $this->btnSave_Create();
     $this->btnEdit_Create();
     $this->btnCancel_Create();
     $this->btnDelete_Create();
     $this->atcAttach_Create();
     $this->pnlAttachments_Create();
     $this->btnAddAsset_Create();
     $this->ctlAssetSearchTool_Create();
     //Set display logic of Built-In Fields
     $this->UpdateBuiltInFields();
     // Set display logic of certain Entities
     $this->UpdateAddressAccess();
     $this->UpdateCompanyAccess();
     $this->UpdateContactAccess();
     // Check prerequisites for scheduling receipts
     $this->CheckPrerequisites();
     // Create the datagrids
     $this->dtgAssetTransact_Create();
     $this->dtgInventoryTransact_Create();
     // New entities Dialog
     $this->dlgNew_Create();
     // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time
     if ($this->blnEditMode) {
         $objClauses = array();
         if ($objClause = $this->dtgAssetTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgAssetTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) {
             array_push($objClauses, $objClause);
         }
         $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $objClauses = null;
         $objClauses = array();
         if ($objClause = $this->dtgInventoryTransact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         /*if ($objClause = $this->dtgInventoryTransact->LimitClause)
         		array_push($objClauses, $objClause);*/
         if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) {
         }
         array_push($objClauses, $objClause);
         $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses);
         $this->DisplayLabels();
     } elseif (!$this->blnEditMode) {
         $this->DisplayInputs();
     }
     // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit
     if (!$this->blnEditMode) {
         $intAssetId = QApplication::QueryString('intAssetId');
         // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button
         if ($intAssetId) {
             $objAsset = Asset::Load($intAssetId);
             if ($objAsset) {
                 $this->txtNewAssetCode->Text = $objAsset->AssetCode;
                 $this->btnAddAsset_Click($this, null, null);
             }
         }
         $intInventoryModelId = QApplication::QueryString('intInventoryModelId');
         // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box
         if ($intInventoryModelId) {
             $objInventoryModel = InventoryModel::Load($intInventoryModelId);
             if ($objInventoryModel) {
                 $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode;
                 $this->txtQuantity->Focus();
             }
         }
     }
 }
Example #30
0
	<p>Note: the code below generates <a href="http://docs.hp.com/en/36216-90103/ch03s02.html">
	correlated (dependent) subqueries</a>. These are frequently not the
	fastest way to run queries against your SQL engine. If there is an
	opportunity to rewrite your subquery using simple joins, do it - this
	will improve the performance of your applications dramatically.</p>

	<p>In general, it's a good idea to use EXPLAIN statements to determine
	the query execution plan of the SQL statement that QQuery generates
	to determine what the SQL engine will actually do to run your queries.
	This is one of the best ways to improve the performance of your
	database-driven application.</p>
</div>

<div id="demoZone">
	<h2>Select names of project managers whose projects are over budget by at least $20</h2>
<?php 
QApplication::$Database[1]->EnableProfiling();
$objPersonArray = Person::QueryArray(QQ::IsNotNull(QQ::Virtual('over_budget_projects', QQ::SubSql("SELECT COUNT(*)\n\t\t\t\t\t\t\tFROM project\n\t\t\t\t\t\t\tWHERE (spent - budget > 20)\n\t\t\t\t\t\t\t\tAND manager_person_id={1}\n\t\t\t\t\t\t\tGROUP BY manager_person_id", QQN::Person()->Id))), QQ::Clause(QQ::OrderBy(QQ::Virtual('over_budget_projects'), false), QQ::Expand(QQ::Virtual('over_budget_projects'))));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName . ': ' . $objPerson->GetVirtualAttribute("over_budget_projects") . " project(s) over budget");
    _p('<br/>', false);
}
?>
	<p><?php 
QApplication::$Database[1]->OutputProfiling();
?>
</p>
</div>

<?php 
require '../includes/footer.inc.php';