protected function Form_Create() { $this->mctObject = ClassInstructorMetaControl::CreateFromPathInfo($this, QMetaControlCreateType::CreateOnRecordNotFound); if ($this->mctObject->EditMode) { $this->strPageTitle .= 'Edit Instructor'; } else { $this->strPageTitle .= 'Create New Instructor'; } $this->lstLogin = $this->mctObject->lstLogin_Create(null, QQ::OrCondition(QQ::AndCondition(QQ::IsNull(QQN::Login()->ClassInstructor->Id), QQ::Equal(QQN::Login()->LoginActiveFlag, true), QQ::Equal(QQN::Login()->DomainActiveFlag, true)), QQ::Equal(QQN::Login()->Id, $this->mctObject->ClassInstructor->LoginId)), QQ::OrderBy(QQN::Login()->FirstName, QQN::Login()->LastName)); $this->txtDisplayName = $this->mctObject->txtDisplayName_Create(); $this->txtDisplayName->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->btnSave = new QButton($this); $this->btnSave->CssClass = 'primary'; $this->btnSave->Text = $this->mctObject->EditMode ? 'Update' : 'Create'; $this->btnSave->CausesValidation = true; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnSave->AddAction(new QClickEvent(), new QTerminateAction()); $this->btnCancel = new QLinkButton($this); $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->Text = 'Cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); if ($this->mctObject->EditMode) { $this->btnDelete = new QLinkButton($this); $this->btnDelete->CssClass = 'delete'; $this->btnDelete->Text = 'Delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to PERMANENTLY DELETE this?')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } }
public function dtgStaff_Bind() { $objConditions = QQ::All(); if ($this->lstMinistry->SelectedValue) { $objConditions = QQ::AndCondition($objConditions, QQ::Equal(QQN::Login()->Ministry->MinistryId, $this->lstMinistry->SelectedValue)); } if ($this->lstActiveFlag->SelectedValue) { $objConditions = QQ::AndCondition($objConditions, QQ::Equal(QQN::Login()->DomainActiveFlag, true), QQ::Equal(QQN::Login()->LoginActiveFlag, true)); } else { $objConditions = QQ::AndCondition($objConditions, QQ::OrCondition(QQ::Equal(QQN::Login()->DomainActiveFlag, false), QQ::Equal(QQN::Login()->LoginActiveFlag, false))); } $this->dtgStaff->TotalItemCount = Login::QueryCount($objConditions); // 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->dtgStaff->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgStaff->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from Login, given the clauses above $this->dtgStaff->DataSource = Login::QueryArray($objConditions, $objClauses); }
protected function dtgGroupRegistration_Bind() { $objConditions = QQ::All(); $objClauses = QQ::Clause($this->dtgGroupRegistrations->OrderByClause); if (!$this->chkShowInactive->Checked) { $objConditions = QQ::AndCondition($objConditions, QQ::OrCondition(QQ::Equal(QQN::GroupRegistrations()->ProcessedFlag, false), QQ::IsNull(QQN::GroupRegistrations()->ProcessedFlag))); } $this->dtgGroupRegistrations->DataSource = GroupRegistrations::QueryArray($objConditions, $objClauses); }
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"); } }
public function auto_Bind($strFormId, $strControlId, $term) { $cond = QQ::OrCondition(QQ::Like(QQN::Person()->FirstName, '%' . $term . '%'), QQ::Like(QQN::Person()->LastName, '%' . $term . '%')); $a = Person::QueryArray($cond); $items = array(); foreach ($a as $obj) { $items[] = new QListItem($obj->FirstName . ' ' . $obj->LastName, $obj->Id); } $this->auto2->DataSource = $items; }
protected function BindData() { if ($strFilter = $this->dtgTable->Search["search"]) { $objCondition = QQ::OrCondition(QQ::Like(QQN::Person()->FirstName, '%' . $strFilter . '%'), QQ::Like(QQN::Person()->LastName, '%' . $strFilter . '%')); } else { $objCondition = QQ::All(); } $this->dtgTable->TotalItemCount = Person::QueryCount($objCondition); $objClauses[] = $this->dtgTable->OrderByClause; $objClauses[] = $this->dtgTable->LimitClause; $this->dtgTable->DataSource = Person::QueryArray($objCondition, $objClauses); }
protected function GetAssetLog() { $objClauses = array(); array_push($objClauses, QQ::OrderBy(QQN::Assetsauditlog()->RealReturnDate)); if ($this->txtSearchTerm->Text == "") { $condition = QQ::Equal(QQN::Assetsauditlog()->Owner, $_SESSION['User']); $myassets = Assetsauditlog::QueryArray($condition, $objClauses); } else { $objCondition = QQ::AndCondition(QQ::OrCondition(QQ::Like(QQN::Assetsauditlog()->Asin, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Assetsauditlog()->Email, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Assetsauditlog()->Title, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Assetsauditlog()->FullName, '%' . $this->txtSearchTerm->Text . '%')), QQ::Equal(QQN::Assetsauditlog()->Owner, $_SESSION['User'])); $objDbResult = Assetsauditlog::QueryArray($objCondition, $objClauses); $myassets = $objDbResult; } return $myassets; }
protected function getList($strTerm = null, $blnHtml = false) { if ($strTerm) { $cond = QQ::OrCondition(QQ::Like(QQN::Person()->FirstName, '%' . $strTerm . '%'), QQ::Like(QQN::Person()->LastName, '%' . $strTerm . '%')); } else { $cond = QQ::All(); } $clauses[] = QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName); $lst = Person::QueryArray($cond, $clauses); $a = array(); foreach ($lst as $objPerson) { $item = new QListItem($objPerson->FirstName . ' ' . $objPerson->LastName, $objPerson->Id); if ($blnHtml) { $item->Label = '<em>' . $objPerson->FirstName . ' ' . $objPerson->LastName . '</em>'; } $a[] = $item; } return $a; }
protected function GetShareDetails() { $objClauses = array(); array_push($objClauses, QQ::OrderBy(QQN::Sharedetails()->ReturnDate)); if ($objClause = $this->dtrShareDetails->LimitClause) { array_push($objClauses, $this->dtrShareDetails->LimitClause); } if ($this->txtSearchTerm->Text == "") { $objCondition = QQ::Equal(QQN::Sharedetails()->Owner, $_SESSION['User']); $myassets = Sharedetails::QueryArray($objCondition, $objClauses); } else { $objCondition = QQ::AndCondition(QQ::OrCondition(QQ::Like(QQN::Sharedetails()->Asin, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Sharedetails()->Email, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Sharedetails()->TakenDate, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Sharedetails()->ReturnDate, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Sharedetails()->Title, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Sharedetails()->FullName, '%' . $this->txtSearchTerm->Text . '%')), QQ::Equal(QQN::Myassets()->Owner, $_SESSION['User'])); $objDbResult = Sharedetails::QueryArray($objCondition, $objClauses); $myassets = $objDbResult; } //$this->dtrShareDetails->TotalItemCount = Sharedetails::QueryCount($condition); $this->arrShareDetails = $myassets; return $objCondition; }
public function dtgGroups_Bind() { if ($this->chkViewAll->Checked) { $objClause = QQ::AndCondition(QQ::Equal(QQN::Group()->GroupParticipation->PersonId, $this->objPerson->Id), QQ::In(QQN::Group()->GroupTypeId, array(GroupType::RegularGroup, GroupType::GrowthGroup))); } else { $objClause = QQ::AndCondition(QQ::Equal(QQN::Group()->GroupParticipation->PersonId, $this->objPerson->Id), QQ::IsNull(QQN::Group()->GroupParticipation->DateEnd), QQ::In(QQN::Group()->GroupTypeId, array(GroupType::RegularGroup, GroupType::GrowthGroup))); } // Admins can view anything if (QApplication::$Login->RoleTypeId == RoleType::ChMSAdministrator) { } else { // Non-Admins can only view non-confidential groups // OR groups that they are associated with $intMinistryIdArray = array(); foreach (QApplication::$Login->GetMinistryArray() as $objMinistry) { $intMinistryIdArray[] = $objMinistry->Id; } $objSubClause = QQ::OrCondition(QQ::Equal(QQN::Group()->ConfidentialFlag, false), QQ::In(QQN::Group()->MinistryId, $intMinistryIdArray)); $objClause = QQ::AndCondition($objClause, $objSubClause); } $this->dtgGroups->DataSource = Group::QueryArray($objClause, QQ::Distinct()); }
public static function GetContacts($strKeyword = null) { if (!is_null($strKeyword)) { $condition = QQ::AndCondition(QQ::OrCondition(QQ::Like(QQN::Peopledetails()->FullName, '%' . $strKeyword . '%'), QQ::Like(QQN::Peopledetails()->Email, '%' . $strKeyword . '%'), QQ::Like(QQN::Peopledetails()->Address, '%' . $strKeyword . '%'), QQ::Like(QQN::Peopledetails()->Phone, '%' . $strKeyword . '%')), QQ::Equal(QQN::Peopledetails()->Owner, $_SESSION['User'])); $objPeopleArray = Peopledetails::QueryArray($condition); return $objPeopleArray; } else { $condition = QQ::Equal(QQN::Peopledetails()->Owner, $_SESSION['User']); $objPeopleArray = Peopledetails::QueryArray($condition); return $objPeopleArray; } }
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); } }
/** * Get an ordered lists of householdsplit objects for this household * in reverse chronological order. * @return HouseholdSplit[] */ public function GetSplitArray() { return HouseholdSplit::QueryArray(QQ::OrCondition(QQ::Equal(QQN::HouseholdSplit()->HouseholdId, $this->Id), QQ::Equal(QQN::HouseholdSplit()->SplitHouseholdId, $this->Id)), QQ::OrderBy(QQN::HouseholdSplit()->DateSplit, false)); }
protected function update_autocompleteList($strFormId, $strControlId, $strParameter) { $strLookup = $strParameter; $objControl = $this->GetControl($strControlId); $cond = QQ::OrCondition(QQ::Like(QQN::Person()->FirstName, '%' . $strLookup . '%'), QQ::Like(QQN::Person()->LastName, '%' . $strLookup . '%')); $clauses[] = QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName); $lst = Person::QueryArray($cond, $clauses); /* * If you implement Person::__toString in the model->Person.class.php file, you * could just pass the $lst to the DataSource. If you want to add a 'label' item * to the display, you can override toJsObject in the People.class.php file. * * For puposes of this example, we will build a custom list using list items below. * */ //$this->AjaxAutocomplete->DataSource = $lst; $a = array(); foreach ($lst as $objPerson) { $item = new QListItem($objPerson->FirstName . ' ' . $objPerson->LastName, $objPerson->Id); if ($objControl->DisplayHtml) { $item->Label = '<em>' . $objPerson->FirstName . ' ' . $objPerson->LastName . '</em>'; } $a[] = $item; } $objControl->DataSource = $a; }
/** * Count InventoryTransactions * by InventoryModelId Index(es), but only those transactions that are Shipments or Receipts * @param integer $intAssetId * @param boolean $blnInclude - include only shipments and receipts or all other transactions * @return int */ public static function CountShipmentReceiptByInventoryModelId($intInventoryModelId, $blnInclude = true) { // Call AssetTransaction::QueryCount to perform the CountByAssetId query if ($blnInclude) { $arrToReturn = InventoryTransaction::QueryCount(QQ::AndCondition(QQ::Equal(QQN::InventoryTransaction()->InventoryLocation->InventoryModelId, $intInventoryModelId), QQ::OrCondition(QQ::Equal(QQN::InventoryTransaction()->Transaction->TransactionTypeId, 6), QQ::Equal(QQN::InventoryTransaction()->Transaction->TransactionTypeId, 7)))); } else { $arrToReturn = InventoryTransaction::QueryCount(QQ::AndCondition(QQ::Equal(QQN::InventoryTransaction()->InventoryLocation->InventoryModelId, $intInventoryModelId), QQ::NotEqual(QQN::InventoryTransaction()->Transaction->TransactionTypeId, 6), QQ::NotEqual(QQN::InventoryTransaction()->Transaction->TransactionTypeId, 7))); } return $arrToReturn; }
protected function dtrText_Conditions($blnReset = false) { $this->arrConditions = array(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->LanguageId, QApplication::GetLanguageId()), QQ::Equal(QQN::NarroContextInfo()->Context->Active, true), QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, true))); if ($blnReset) { $this->intMaxRowCount = 0; } $this->arrClauses = array(QQ::Expand(QQN::NarroContextInfo()->Context), QQ::Expand(QQN::NarroContextInfo()->Context->Text), QQ::Expand(QQN::NarroContextInfo()->Context->File), QQ::Expand(QQN::NarroContextInfo()->Context->Project), QQ::Expand(QQN::NarroContextInfo()->ValidSuggestion)); if ($this->lstProject->SelectedValue > 0) { $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->lstProject->SelectedValue); } switch ($this->lstFilter->SelectedValue) { case self::SHOW_NOT_TRANSLATED: $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, false); break; case self::SHOW_NOT_APPROVED: $this->arrConditions[] = QQ::AndCondition(QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true)); break; case self::SHOW_APPROVED: $this->arrConditions[] = QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId); break; case self::SHOW_APPROVED_AND_NOT_APPROVED: $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true); break; case self::SHOW_NOT_APPROVED_AND_NOT_TRANSLATED: $this->arrConditions[] = QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId); break; case self::SHOW_NOT_APPROVED_AND_WITHOUT_VOTES: $this->arrConditions[] = QQ::Equal(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0); break; case self::SHOW_NOT_APPROVED_AND_WITH_VOTES: $this->arrConditions[] = QQ::NotEqual(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0); break; case self::SHOW_IDENTICAL_APPROVED: $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText); $this->arrClauses[] = QQ::Distinct(); $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionId), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId)); break; case self::SHOW_IDENTICAL: $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText); $this->arrClauses[] = QQ::Distinct(); $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId)); break; case self::SHOW_ALL: default: } if ($this->txtFile->Text != t('all files') && $this->txtFile->Text != '') { if (preg_match("/^'.+'\$/", $this->txtFile->Text)) { $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1)); } elseif (preg_match('/^".+"$/', $this->txtFile->Text)) { $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1)); } else { $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->File->FilePath, '%' . $this->txtFile->Text . '%'); } } if ($this->txtSearch->Text) { if (preg_match("/^'.+'\$/", $this->txtSearch->Text)) { $strLikeSearch = substr($this->txtSearch->Text, 1, -1); } elseif (preg_match('/^".+"$/', $this->txtSearch->Text)) { $strLikeSearch = substr($this->txtSearch->Text, 1, -1); } else { $strLikeSearch = '%' . $this->txtSearch->Text . '%'; } switch ($this->lstSearchIn->SelectedValue) { case self::SEARCH_IN_TEXTS: $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch); break; case self::SEARCH_IN_TRANSLATIONS: $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText); $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())); break; case self::SEARCH_IN_AUTHORS: $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText); $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())); break; case self::SEARCH_IN_CONTEXTS: $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch)); break; case self::SEARCH_IN_ALL: default: $this->arrClauses[] = QQ::Distinct(); $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch)); } } switch ($this->lstSort->SelectedValue) { case self::SORT_TEXT: $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextValue, $this->lstSortDir->SelectedValue); break; case self::SORT_TEXT_LENGTH: $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextWordCount, $this->lstSortDir->SelectedValue); break; case self::SORT_TRANSLATION: $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->ValidSuggestion->SuggestionValue, $this->lstSortDir->SelectedValue); break; case self::SORT_TRANSLATION_DATE: $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Modified, $this->lstSortDir->SelectedValue); break; } }
<h2>Select all People where: the first name is alphabetically "greater than" the last name</h2> <ul> <?php $objPersonArray = Person::QueryArray(QQ::GreaterThan(QQN::Person()->FirstName, QQN::Person()->LastName)); foreach ($objPersonArray as $objPerson) { _p('<li>' . $objPerson->FirstName . ' ' . $objPerson->LastName . '</li>', false); } ?> </ul> <h2>Select all Projects where: the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website"</h2> <ul> <?php $objProjectArray = Project::QueryArray(QQ::OrCondition(QQ::GreaterThan(QQN::Project()->ManagerPerson->FirstName, QQN::Project()->ManagerPerson->LastName), QQ::Like(QQN::Project()->Name, '%Website%'))); foreach ($objProjectArray as $objProject) { _p(sprintf('<li>%s (managed by %s %s)</li>', $objProject->Name, $objProject->ManagerPerson->FirstName, $objProject->ManagerPerson->LastName), false); } ?> </ul> <h2>Select all Projects where: the Project ID <= 2 AND (the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website")</h2> <ul> <?php $objProjectArray = Project::QueryArray(QQ::AndCondition(QQ::OrCondition(QQ::GreaterThan(QQN::Project()->ManagerPerson->FirstName, QQN::Project()->ManagerPerson->LastName), QQ::Like(QQN::Project()->Name, '%Website%')), QQ::LessOrEqual(QQN::Project()->Id, 2))); foreach ($objProjectArray as $objProject) { _p(sprintf('<li>%s (managed by %s %s)</li>', $objProject->Name, $objProject->ManagerPerson->FirstName, $objProject->ManagerPerson->LastName), false); } ?> </ul> </div> <?php require '../includes/footer.inc.php';
protected function GetPeopleData() { $objClauses = array(); array_push($objClauses, QQ::OrderBy(QQN::Peopledetails()->FullName)); if ($objClause = $this->dtrPeople->LimitClause) { array_push($objClauses, $this->dtrPeople->LimitClause); } if ($this->txtSearchPeople->Text != '') { $condition = QQ::OrCondition(QQ::Like(QQN::Peopledetails()->FullName, '%' . $this->txtSearchPeople->Text . '%'), QQ::Like(QQN::Peopledetails()->Email, '%' . $this->txtSearchPeople->Text . '%'), QQ::Like(QQN::Peopledetails()->Phone, '%' . $this->txtSearchPeople->Text . '%')); $result = Peopledetails::QueryArray($condition, $objClause); $this->dtrPeople->DataSource = $result; $this->dtrPeople->TotalItemCount = Peopledetails::QueryCount($condition); } else { $result = Peopledetails::QueryArray(QQ::All(), $objClause); $this->dtrPeople->DataSource = $result; $this->dtrPeople->TotalItemCount = Peopledetails::QueryCount(QQ::All()); } }
private function GetAssetsData($productgroup) { $objClauses = array(); array_push($objClauses, QQ::OrderBy(QQN::Myassets()->Title)); if ($objClause = $this->dtrMyLibrary->LimitClause) { array_push($objClauses, $this->dtrMyLibrary->LimitClause); } if ($this->txtSearchTerm->Text == "") { $condition = QQ::AndCondition(QQ::Equal(QQN::Myassets()->ProductGroup, $productgroup), QQ::Equal(QQN::Myassets()->Owner, $_SESSION['User'])); $arrResult = Myassets::QueryArray($condition, $objClauses); $this->dtrMyLibrary->TotalItemCount = Myassets::QueryCount($condition); $this->dtrMyLibrary->DataSource = $arrResult; } else { $objCondition = QQ::AndCondition(QQ::OrCondition(QQ::Like(QQN::Myassets()->Title, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Author, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Artist, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Actor, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Director, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Publisher, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Label, '%' . $this->txtSearchTerm->Text . '%'), QQ::Like(QQN::Myassets()->Isbn, '%' . $this->txtSearchTerm->Text . '%')), QQ::Equal(QQN::Myassets()->ProductGroup, $productgroup), QQ::Equal(QQN::Myassets()->Owner, $_SESSION['User'])); $objDbResult = Myassets::QueryArray($objCondition, $objClauses); $myassets = $objDbResult; $this->dtrMyLibrary->TotalItemCount = Myassets::QueryCount($objCondition); if ($this->dtrMyLibrary->TotalItemCount > 0) { $this->dtrMyLibrary->DataSource = $myassets; } else { QApplicationBase::DisplayAlert('No ' . $productgroup . 's exists for the searched term'); } } }
/** * Gets all associated ACTIVE GroupParticipations as an array of GroupParticipation objects * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return GroupParticipation[] */ public function GetActiveGroupParticipationArray($objOptionalClauses = null) { if (is_null($this->intId)) { return array(); } try { return GroupParticipation::QueryArray(QQ::AndCondition(QQ::Equal(QQN::GroupParticipation()->GroupId, $this->intId), QQ::OrCondition(QQ::IsNull(QQN::GroupParticipation()->DateEnd), QQ::GreaterThan(QQN::GroupParticipation()->DateEnd, QDateTime::Now()))), $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
protected function Form_Create() { $this->lblHeading = new QLabel($this); if (QApplication::PathInfo(0)) { $objSignupForm = SignupForm::Load(QApplication::PathInfo(0)); if (!$objSignupForm) { QApplication::Redirect('/events/'); } if (!$objSignupForm->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) { QApplication::Redirect('/events/'); } $this->strPageTitle .= 'Edit Form'; $this->lblHeading->Text = 'Edit ' . $objSignupForm->Type . ' Form'; switch ($objSignupForm->SignupFormTypeId) { case SignupFormType::Event: $objChild = $objSignupForm->EventSignupForm; break; case SignupFormType::Course: $objChild = $objSignupForm->ClassMeeting; break; default: throw new Exception('Invalid SignupFormTypeId: ' . $objSignupForm->SignupFormTypeId); } } else { if (!QApplication::PathInfo(1)) { QApplication::Redirect('/events/'); } $objSignupForm = new SignupForm(); $objSignupForm->SignupFormTypeId = QApplication::PathInfo(1); $objSignupForm->DateCreated = QDateTime::Now(); $objSignupForm->ActiveFlag = true; $this->strPageTitle .= 'Create New Form'; $this->lblHeading->Text = 'Create New ' . $objSignupForm->Type . ' Form'; switch ($objSignupForm->SignupFormTypeId) { case SignupFormType::Event: $objChild = new EventSignupForm(); break; case SignupFormType::Course: $objChild = new ClassMeeting(); break; default: throw new Exception('Invalid SignupFormTypeId: ' . $objSignupForm->SignupFormTypeId); } } // Setup MCTs for Signup and Child $this->mctSignupForm = new SignupFormMetaControl($this, $objSignupForm); switch ($objSignupForm->SignupFormTypeId) { case SignupFormType::Event: $this->mctSignupChild = new EventSignupFormMetaControl($this, $objChild); break; case SignupFormType::Course: $this->mctSignupChild = new ClassMeetingMetaControl($this, $objChild); break; default: throw new Exception('Invalid SignupFormTypeId: ' . $objSignupForm->SignupFormTypeId); } $this->txtName = $this->mctSignupForm->txtName_Create(); $this->txtName->Select(); $this->txtName->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtName->Required = true; $this->txtDescription = $this->mctSignupForm->txtDescription_Create(); $this->txtInformationUrl = $this->mctSignupForm->txtInformationUrl_Create(); $this->chkAllowMultipleFlag = $this->mctSignupForm->chkAllowMultipleFlag_Create(); $this->chkAllowMultipleFlag->Name = 'Allow Multiple Registrations?'; $this->chkAllowMultipleFlag->Text = 'Check if people are allowed to be registered multiple times.'; $this->chkAllowOtherFlag = $this->mctSignupForm->chkAllowOtherFlag_Create(); $this->chkAllowOtherFlag->Name = 'Allow Registering for Others?'; $this->chkAllowOtherFlag->Text = 'Check if people are allowed to register on behalf of someone else.'; $this->chkAllowOtherFlag->Visible = false; $this->chkActiveFlag = $this->mctSignupForm->chkActiveFlag_Create(); $this->chkActiveFlag->Name = 'Active?'; $this->chkActiveFlag->Text = 'Check if this is an "Active" form.'; $this->txtToken = $this->mctSignupForm->txtToken_Create(); $this->txtToken->Name = 'Custom Signup Web Address'; $this->txtToken->HtmlBefore = '<span>https://my.alcf.net/signup/event.php / </span>'; $this->chkConfidentialFlag = $this->mctSignupForm->chkConfidentialFlag_Create(); $this->chkConfidentialFlag->Name = 'Confidential?'; $this->chkConfidentialFlag->Text = 'Check if this form is considered a "Confidential" form.'; $this->chkNoLoginSupportFlag = $this->mctSignupForm->chkLoginNotRequiredFlag_Create(); $this->chkNoLoginSupportFlag->Name = 'Support No Login?'; $this->chkNoLoginSupportFlag->Text = 'Check if you would like to allow users to signup without having to log in.'; $this->txtFundingAccount = $this->mctSignupForm->txtFundingAccount_Create(); if ($this->mctSignupForm->SignupForm->CountFormProducts()) { $this->txtFundingAccount->Required = true; } $this->lstDonationStewardshipFund = $this->mctSignupForm->lstDonationStewardshipFund_Create(null, QQ::Equal(QQN::StewardshipFund()->ActiveFlag, true), QQ::OrderBy(QQN::StewardshipFund()->Name)); $this->lstDonationStewardshipFund->Name = 'Funding Account for Donations'; if ($this->mctSignupForm->SignupForm->IsDonationAccepted()) { $this->lstDonationStewardshipFund->Required = true; } // Setup Ministry with Rules if (QApplication::$Login->RoleTypeId == RoleType::ChMSAdministrator) { $this->lstMinistry = $this->mctSignupForm->lstMinistry_Create(null, null, QQ::OrderBy(QQN::Ministry()->Name)); } else { $intMinistryIdArray = array(); foreach (QApplication::$Login->GetMinistryArray() as $objMinistry) { $intMinistryIdArray[] = $objMinistry->Id; } $this->lstMinistry = $this->mctSignupForm->lstMinistry_Create(null, QQ::In(QQN::Ministry()->Id, $intMinistryIdArray), QQ::OrderBy(QQN::Ministry()->Name)); } if ($this->mctSignupForm->EditMode) { $this->lstMinistry->Enabled = false; } // Communciation $this->txtSupportEmail = $this->mctSignupForm->txtSupportEmail_Create(); $this->txtEmailNotification = $this->mctSignupForm->txtEmailNotification_Create(); // Setup Limit $this->txtSignupLimit = $this->mctSignupForm->txtSignupLimit_Create(); $this->txtSignupLimit->Minimum = 0; // TODO: Implement Gender-Specific Limits $this->txtSignupMaleLimit = $this->mctSignupForm->txtSignupMaleLimit_Create(); $this->txtSignupMaleLimit->Visible = false; $this->txtSignupMaleLimit->Minimum = 0; $this->txtSignupFemaleLimit = $this->mctSignupForm->txtSignupFemaleLimit_Create(); $this->txtSignupFemaleLimit->Minimum = 0; $this->txtSignupFemaleLimit->Visible = false; // Setup Controls for Child switch ($objSignupForm->SignupFormTypeId) { case SignupFormType::Event: $this->dtxDateStart = $this->mctSignupChild->dtxDateStart_Create(); $this->calDateStart = $this->mctSignupChild->calDateStart_Create(); $this->dtxDateEnd = $this->mctSignupChild->dtxDateEnd_Create(); $this->calDateEnd = $this->mctSignupChild->calDateEnd_Create(); $this->txtLocation = $this->mctSignupChild->txtLocation_Create(); break; case SignupFormType::Course: $this->lstClassTerm = $this->mctSignupChild->lstClassTerm_Create(null, QQ::OrCondition(QQ::Equal(QQN::ClassTerm()->ActiveFlag, true), QQ::Equal(QQN::ClassTerm()->Id, $this->mctSignupChild->ClassMeeting->ClassTermId))); $this->lstClassCourse = $this->mctSignupChild->lstClassCourse_Create(null, null, QQ::OrderBy(QQN::ClassCourse()->Code)); $this->lstClassInstructor = $this->mctSignupChild->lstClassInstructor_Create(null, null, QQ::OrderBy(QQN::ClassInstructor()->DisplayName)); $this->calDateStart = $this->mctSignupChild->calDateStart_Create(); $this->calDateEnd = $this->mctSignupChild->calDateEnd_Create(); $this->txtLocation = $this->mctSignupChild->txtLocation_Create(); $this->lstMeetingDay = $this->mctSignupChild->lstMeetingDay_Create(); $this->lstMeetingStartTime = $this->mctSignupChild->lstMeetingStartTime_Create(); $this->lstMeetingEndTime = $this->mctSignupChild->lstMeetingEndTime_Create(); // Make some upates to the default fields $this->txtName->Enabled = false; $this->lstClassCourse->AddAction(new QChangeEvent(), new QAjaxAction('lstClassCourse_Change')); break; default: throw new Exception('Invalid SignupFormTypeId: ' . $objSignupForm->SignupFormTypeId); } // Buttons $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->CausesValidation = true; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); // Delete? if ($this->mctSignupForm->EditMode) { $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; if ($this->mctSignupForm->SignupForm->CountSignupEntries()) { $this->btnDelete->AddAction(new QClickEvent(), new QAlertAction('This signup form already has signup entries and therefore cannot be deleted. An alternative option would be to simply mark this form as "Inactive".')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } else { $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this Signup Form? This cannot be undone.')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } } }
protected function update_autocompleteList() { $strTyped = $this->AjaxAutocomplete->Text; $cond = QQ::OrCondition(QQ::Like(QQN::Person()->FirstName, '%' . $strTyped . '%'), QQ::Like(QQN::Person()->LastName, '%' . $strTyped . '%')); $clauses[] = QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName); $lst = Person::QueryArray($cond, $clauses); // If you implement Person::__toString in the model->Person.class.php file, you // could just pass the $lst to the DataSource. // Instead, we will build the list using autcomplete list items //$this->AjaxAutocomplete->DataSource = $lst; $a = array(); foreach ($lst as $objPerson) { $a[] = new QListItem($objPerson->FirstName . ' ' . $objPerson->LastName, $objPerson->Id); } $this->AjaxAutocomplete->DataSource = $a; }
public function dtgUser_Bind() { if ($this->txtSearch->Text != '') { $objSearchCondition = QQ::OrCondition(QQ::Like(QQN::NarroUser()->RealName, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Username, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Email, sprintf('%%%s%%', $this->txtSearch->Text))); } else { $objSearchCondition = QQ::All(); } // 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->dtgUser->TotalItemCount = NarroUser::QueryCount($objSearchCondition); // 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->dtgUser->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgUser->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all NarroUser objects, given the clauses above $this->dtgUser->DataSource = NarroUser::QueryArray($objSearchCondition, $objClauses); QApplication::ExecuteJavaScript('highlight_datagrid();'); }
protected function CalculateQqCondition(QueryCondition $objQueryCondition, QQNode $objQqNode, QQCondition $objQqConditionToAdd = null) { // Get the comparison Query Operation we are using $objOperation = $objQueryCondition->QueryOperation; // Get the QQ Factory Name we are using -- this becomes the Qq Method Name we run to construct // the QcodoQueryCondition $strMethodName = $objOperation->QqFactoryName; // Generate the QcodoQueryCondition switch ($objQueryCondition->QueryNode->QueryDataTypeId) { case QueryDataType::BooleanValue: if ($objQueryCondition->Value) { $objQqCondition = QQ::Equal($objQqNode, true); } else { $objQqCondition = QQ::OrCondition(QQ::Equal($objQqNode, false), QQ::IsNull($objQqNode)); } break; default: if ($objOperation->ArgumentFlag) { $strArgument = $objOperation->ArgumentPrepend . $objQueryCondition->Value . $objOperation->ArgumentPostpend; $objQqCondition = QQ::$strMethodName($objQqNode, $strArgument); } else { $objQqCondition = QQ::$strMethodName($objQqNode); } break; } if ($objQqConditionToAdd) { $objQqCondition = QQ::AndCondition($objQqConditionToAdd, $objQqCondition); } return $objQqCondition; }
/** * Check if Receipt contains company * by FromContactId Index(es) * @param integer $intContactId * @return bool */ public static function hasCompany($intCompanyId) { try { $intReceipts = Receipt::QueryCount(QQ::OrCondition(QQ::Equal(QQN::Receipt()->FromCompanyId, $intCompanyId), QQ::Equal(QQN::Receipt()->ToContact->CompanyId, $intCompanyId))); return $intReceipts > 0 ? true : false; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
public function dtgParentPagerIndividual_Bind() { $objCondition = QQ::All(); if (strlen($strText = trim($this->txtServerIdentifier->Text))) { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::ParentPagerIndividual()->ServerIdentifier, $strText)); } if (strlen($strText = trim($this->txtFirstName->Text))) { $objCondition = QQ::AndCondition($objCondition, QQ::Like(QQN::ParentPagerIndividual()->FirstName, $strText . '%')); } if (strlen($strText = trim($this->txtLastName->Text))) { $objCondition = QQ::AndCondition($objCondition, QQ::Like(QQN::ParentPagerIndividual()->LastName, $strText . '%')); } if ($intId = $this->lstParentPagerSyncStatusTypeId->SelectedValue) { if ($intId == -1) { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::ParentPagerIndividual()->HiddenFlag, true)); } else { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::ParentPagerIndividual()->ParentPagerSyncStatusTypeId, $intId), QQ::OrCondition(QQ::Equal(QQN::ParentPagerIndividual()->HiddenFlag, false), QQ::IsNull(QQN::ParentPagerIndividual()->HiddenFlag))); } } if ($strValue = $this->lstGender->SelectedValue) { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::ParentPagerIndividual()->Gender, $strValue)); } if (strlen($strText = trim($this->txtGraduationYear->Text))) { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::ParentPagerIndividual()->GraduationYear, $strText)); } $this->dtgParentPagerIndividuals->MetaDataBinder($objCondition); }
public function dtgChildHistory_Bind() { $this->dtgChildHistory->MetaDataBinder(QQ::OrCondition(QQ::Equal(QQN::ParentPagerChildHistory()->ParentPagerIndividualId, $this->objParentPagerIndividual->Id), QQ::Equal(QQN::ParentPagerChildHistory()->PickupByParentPagerIndividualId, $this->objParentPagerIndividual->Id), QQ::Equal(QQN::ParentPagerChildHistory()->DropoffByParentPagerIndividualId, $this->objParentPagerIndividual->Id))); }
public function dtgPeople_Bind() { $objConditions = QQ::All(); $objClauses = array(); if ($strName = trim($this->txtName->Text)) { Person::PrepareQqForSearch($strName, $objConditions, $objClauses); } if ($strName = trim($this->txtFirstName->Text)) { $objConditions = QQ::AndCondition($objConditions, QQ::Like(QQN::Person()->FirstName, $strName . '%')); } if ($strName = trim($this->txtLastName->Text)) { $objConditions = QQ::AndCondition($objConditions, QQ::Like(QQN::Person()->LastName, $strName . '%')); } if ($strName = trim($this->txtCity->Text)) { $objConditions = QQ::AndCondition($objConditions, QQ::Like(QQN::Person()->PrimaryCityText, $strName . '%')); } if ($strName = trim($this->txtZipcode->Text)) { $objConditions = QQ::AndCondition($objConditions, QQ::Like(QQN::Person()->PrimaryZipCodeText, $strName . '%')); } if ($strName = trim($this->txtEmail->Text)) { $objConditions = QQ::AndCondition($objConditions, QQ::Like(QQN::Person()->PrimaryEmail->Address, $strName . '%')); } if ($strName = trim($this->txtPhone->Text)) { $strFormatted = sprintf("%s-%s-%s", substr($strName, 0, 3), substr($strName, 3, 3), substr($strName, 6)); $objClauses[] = QQ::Distinct(); $objConditions = QQ::AndCondition($objConditions, QQ::OrCondition(QQ::Like(QQN::Person()->Phone->Number, $strName . '%'), QQ::Like(QQN::Person()->HouseholdParticipation->Household->Address->Phone->Number, $strName . '%'), QQ::Like(QQN::Person()->Phone->Number, $strFormatted . '%'), QQ::Like(QQN::Person()->HouseholdParticipation->Household->Address->Phone->Number, $strFormatted . '%'))); } if (!is_null($strValue = $this->lstGender->SelectedValue)) { $objConditions = QQ::AndCondition($objConditions, QQ::Equal(QQN::Person()->Gender, $strValue)); } if (!is_null($strValue = $this->lstMemberStatus->SelectedValue)) { $objConditions = QQ::AndCondition($objConditions, QQ::Equal(QQN::Person()->MembershipStatusTypeId, $strValue)); } $this->dtgPeople->MetaDataBinder($objConditions, $objClauses); }
protected function dtrAssetHistory_Bind() { // Get Total Count for Pagination $this->dtrAssetHistory->TotalItemCount = AssetTransaction::CountAssetTransaction($this->ctlAssetEdit->objAsset->AssetId); $objClauses = array(); $objClause = QQ::OrderBy(QQN::AssetTransaction()->Transaction->CreationDate, false); array_push($objClauses, $objClause); $objCondition = QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $this->ctlAssetEdit->objAsset->AssetId), QQ::OrCondition(QQ::In(QQN::AssetTransaction()->Transaction->TransactionTypeId, array(1, 2, 3, 6, 7, 8, 9, 10, 11)))); $intItemsPerPage = $this->dtrAssetHistory->ItemsPerPage; $intItemOffset = ($this->dtrAssetHistory->PageNumber - 1) * $intItemsPerPage; $arrDataSource = array_slice(AssetTransaction::QueryArray($objCondition, $objClauses), $intItemOffset, $intItemsPerPage); $this->dtrAssetHistory->DataSource = $arrDataSource; }
<div id="demoZone"> <h2>Get All People, Specifying the Project They Manage (if any), for Projects that have 'ACME' or 'HR' in it</h2> <p><em>Notice how some people may be listed twice, if they manage more than one project.</em></p> <ul> <?php $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Expand(QQN::Person()->ProjectAsManager), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName))); foreach ($objPersonArray as $objPerson) { printf('<li>%s %s (managing the "%s" project)</li>', QApplication::HtmlEntities($objPerson->FirstName), QApplication::HtmlEntities($objPerson->LastName), QApplication::HtmlEntities($objPerson->_ProjectAsManager->Name), false); } ?> </ul> <h3>Same as above, but this time, use ExpandAsArray()</h3> <em>Notice how each person is only listed once... but each person has an internal/virtual <strong>_ProjectAsManagerArray</strong> which may list more than one project.</em></p> <?php $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::ExpandAsArray(QQN::Person()->ProjectAsManager), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName))); foreach ($objPersonArray as $objPerson) { _p('<li>' . $objPerson->FirstName . ' ' . $objPerson->LastName, false); // Now, instead of using the _ProjectAsManager virtual attribute, we will use // the _ProjectAsManagerArray virtual attribute, which gives us an array of Project objects $strProjectNameArray = array(); foreach ($objPerson->_ProjectAsManagerArray as $objProject) { array_push($strProjectNameArray, QApplication::HtmlEntities($objProject->Name)); } printf(' via: %s</li>', implode(', ', $strProjectNameArray)); } ?> </div> <?php require '../includes/footer.inc.php';