public static In ( QQNode $objQueryNode, $mixValuesArray ) | ||
$objQueryNode | QQNode |
protected function Form_Create() { // Load the MetaControl and Ensure Edit Permissions $this->mctList = CommunicationListMetaControl::Create($this, QApplication::PathInfo(0), QMetaControlCreateType::CreateOnRecordNotFound); if ($this->mctList->EditMode) { if (!$this->mctList->CommunicationList->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) { $this->RedirectToView(); } } $this->txtName = $this->mctList->txtName_Create(); $this->txtName->Required = true; $this->txtDescription = $this->mctList->txtDescription_Create(); $this->txtDescription->Required = false; $this->txtDescription->TextMode = QTextMode::MultiLine; $this->txtDescription->Height = '50px'; $this->txtToken = $this->mctList->txtToken_Create(); $this->txtToken->Name = 'Email Address'; $this->txtToken->HtmlAfter = '<span> @ groups.alcf.net</span>'; $this->lstType = $this->mctList->lstEmailBroadcastType_Create(); $this->lstType->Instructions = '<span class="help" onclick="displayHelp(\'helpEmailBroadcastType\')"><img src="/assets/images/icons/help.png" alt="help"></span>'; $this->chkSubscribable = $this->mctList->chkSubscribable_Create(); if (QApplication::$Login->RoleTypeId == RoleType::ChMSAdministrator) { $this->lstMinistry = $this->mctList->lstMinistry_Create(null, null, QQ::OrderBy(QQN::Ministry()->Name)); } else { $intMinistryIdArray = array(); foreach (QApplication::$Login->GetMinistryArray() as $objMinistry) { $intMinistryIdArray[] = $objMinistry->Id; } $this->lstMinistry = $this->mctList->lstMinistry_Create(null, QQ::In(QQN::Ministry()->Id, $intMinistryIdArray), QQ::OrderBy(QQN::Ministry()->Name)); } if ($this->mctList->EditMode) { $this->lstMinistry->Enabled = false; } $this->strPageTitle = 'Email List - ' . ($this->mctList->EditMode ? 'Edit' : 'Create New'); $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnSave->CausesValidation = true; $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); if ($this->mctList->EditMode) { $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to permanently DELETE this Email List? This will also delete ALL the messages as well!')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } }
public function dtgMembers_Bind() { $objCondition = QQ::In(QQN::Person()->GroupParticipation->GroupId, $this->intGroupIdArray); $objCondition = QQ::AndCondition($objCondition, QQ::IsNull(QQN::Person()->GroupParticipation->DateEnd)); $this->dtgMembers->TotalItemCount = Person::QueryCount($objCondition); $objClauses = array(QQ::Distinct()); if ($objClause = $this->dtgMembers->LimitClause) { $objClauses[] = $objClause; } if ($objClause = $this->dtgMembers->OrderByClause) { $objClauses[] = $objClause; } $this->dtgMembers->DataSource = Person::QueryArray($objCondition, $objClauses); }
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')); }
public function RenderCount($objGroup) { // Count differently if it's a group Category or Growth Group if ($objGroup->Type == GroupType::$NameArray[GroupType::GroupCategory]) { // Setup Group Array $objGroupArray = $objGroup->GetThisAndChildren(); $intGroupIdArray = array(); foreach ($objGroupArray as $objGroup) { $intGroupIdArray[] = $objGroup->Id; } $objCondition = QQ::In(QQN::Person()->GroupParticipation->GroupId, $intGroupIdArray); $objCondition = QQ::AndCondition($objCondition, QQ::IsNull(QQN::Person()->GroupParticipation->DateEnd)); $strReturn = Person::QueryCount($objCondition); return "<b>" . $strReturn . "</b>"; } else { $objCondition = QQ::Equal(QQN::Person()->GroupParticipation->GroupId, $objGroup->Id); $objCondition = QQ::AndCondition($objCondition, QQ::IsNull(QQN::Person()->GroupParticipation->DateEnd)); return Person::QueryCount($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()); }
protected function Form_Create() { $this->lblLabel = new QLabel($this); $this->lblLabel->HtmlEntities = false; $this->lblLabel->Text = "<h2>Generate Volunteers Report for: </h2>"; $this->btnGenerateReport = new QButton($this); $this->btnGenerateReport->Text = "Generate Report"; $this->btnGenerateReport->CssClass = "primary"; $this->btnGenerateReport->AddAction(new QClickEvent(), new QAjaxAction('generateReport_Click')); $afterArray = explode(",", QApplication::PathInfo(1)); $this->lstAfterMonth = new QListBox($this); $this->lstAfterMonth->AddItem('Jan', 'Jan'); $this->lstAfterMonth->AddItem('Feb', 'Feb'); $this->lstAfterMonth->AddItem('Mar', 'Mar'); $this->lstAfterMonth->AddItem('Apr', 'Apr'); $this->lstAfterMonth->AddItem('May', 'May'); $this->lstAfterMonth->AddItem('Jun', 'Jun'); $this->lstAfterMonth->AddItem('Jul', 'Jul'); $this->lstAfterMonth->AddItem('Aug', 'Aug'); $this->lstAfterMonth->AddItem('Sep', 'Sep'); $this->lstAfterMonth->AddItem('Oct', 'Oct'); $this->lstAfterMonth->AddItem('Nov', 'Nov'); $this->lstAfterMonth->AddItem('Dec', 'Dec'); if (QApplication::PathInfo(1)) { $this->lstAfterMonth->SelectedValue = $afterArray[0]; } $this->lstAfterYear = new QListBox($this); $this->lstAfterYear->AddItem('2010', '2010'); $this->lstAfterYear->AddItem('2011', '2011'); $this->lstAfterYear->AddItem('2012', '2012'); $this->lstAfterYear->AddItem('2013', '2013'); $this->lstAfterYear->AddItem('2014', '2014'); if (QApplication::PathInfo(1)) { $this->lstAfterYear->SelectedValue = $afterArray[1]; } $beforeArray = explode(",", QApplication::PathInfo(0)); $this->lstBeforeMonth = new QListBox($this); $this->lstBeforeMonth->AddItem('Jan', 'Jan'); $this->lstBeforeMonth->AddItem('Feb', 'Feb'); $this->lstBeforeMonth->AddItem('Mar', 'Mar'); $this->lstBeforeMonth->AddItem('Apr', 'Apr'); $this->lstBeforeMonth->AddItem('May', 'May'); $this->lstBeforeMonth->AddItem('Jun', 'Jun'); $this->lstBeforeMonth->AddItem('Jul', 'Jul'); $this->lstBeforeMonth->AddItem('Aug', 'Aug'); $this->lstBeforeMonth->AddItem('Sep', 'Sep'); $this->lstBeforeMonth->AddItem('Oct', 'Oct'); $this->lstBeforeMonth->AddItem('Nov', 'Nov'); $this->lstBeforeMonth->AddItem('Dec', 'Dec'); if (QApplication::PathInfo(0)) { $this->lstBeforeMonth->SelectedValue = $beforeArray[0]; } $this->lstBeforeYear = new QListBox($this); $this->lstBeforeYear->AddItem('2010', '2010'); $this->lstBeforeYear->AddItem('2011', '2011'); $this->lstBeforeYear->AddItem('2012', '2012'); $this->lstBeforeYear->AddItem('2013', '2013'); $this->lstBeforeYear->AddItem('2014', '2014'); if (QApplication::PathInfo(0)) { $this->lstBeforeYear->SelectedValue = $beforeArray[1]; } $this->lstMinistryDepartments = new QListBox($this); QApplication::PathInfo(2) == 'Select' ? $this->lstMinistryDepartments->AddItem('-- Select A Department Or Ministry --', 'Select', true) : $this->lstMinistryDepartments->AddItem('-- Select A Department Or Ministry --', 'Select'); QApplication::PathInfo(2) == 'All' ? $this->lstMinistryDepartments->AddItem('All', 'All', true) : $this->lstMinistryDepartments->AddItem('All', 'All'); QApplication::PathInfo(2) == 'OutreachEvangelismCare' ? $this->lstMinistryDepartments->AddItem('Department: Outreach, Evangelism, and Care', 'OutreachEvangelismCare', true) : $this->lstMinistryDepartments->AddItem('Department: Outreach, Evangelism, and Care', 'OutreachEvangelismCare'); QApplication::PathInfo(2) == 'AdministrativeOperations' ? $this->lstMinistryDepartments->AddItem('Department: Administrative Operations', 'AdministrativeOperations', true) : $this->lstMinistryDepartments->AddItem('Department: Administrative Operations', 'AdministrativeOperations'); QApplication::PathInfo(2) == 'Discipleship' ? $this->lstMinistryDepartments->AddItem('Department: Discipleship', 'Discipleship', true) : $this->lstMinistryDepartments->AddItem('Department: Discipleship', 'Discipleship'); QApplication::PathInfo(2) == 'MinistryOperations' ? $this->lstMinistryDepartments->AddItem('Department: Ministry Operations', 'MinistryOperations', true) : $this->lstMinistryDepartments->AddItem('Department: Ministry Operations', 'MinistryOperations'); QApplication::PathInfo(2) == 'WorshipArts' ? $this->lstMinistryDepartments->AddItem('Department: Worship Arts', 'WorshipArts', true) : $this->lstMinistryDepartments->AddItem('Department: Worship Arts', 'WorshipArts'); QApplication::PathInfo(2) == 'WorshipService' ? $this->lstMinistryDepartments->AddItem('Department: Worship Service', 'WorshipService', true) : $this->lstMinistryDepartments->AddItem('Department: Worship Service', 'WorshipService'); foreach (Ministry::LoadAll() as $objMinistry) { QApplication::PathInfo(2) == $objMinistry->Token ? $this->lstMinistryDepartments->AddItem('Ministry: ' . $objMinistry->Name, $objMinistry->Token, true) : $this->lstMinistryDepartments->AddItem('Ministry: ' . $objMinistry->Name, $objMinistry->Token); } // May or may not display a table $this->dtgVolunteers = new QDataGrid($this); $this->dtgVolunteers->AddColumn(new QDataGridColumn('Month and Year', '<?= $_ITEM->month; ?>', 'Width=270px')); $this->dtgVolunteers->AddColumn(new QDataGridColumn('# of Volunteers', '<?= $_ITEM->count; ?>', 'Width=270px')); // Extract information based off the selections if ($this->lstAfterMonth->SelectedValue && $this->lstAfterYear->SelectedValue && $this->lstBeforeMonth->SelectedValue && $this->lstBeforeYear->SelectedValue) { $this->startDate = new QDateTime($this->lstAfterMonth->SelectedIndex + 1 . '/1/' . $this->lstAfterYear->SelectedValue); $this->endDate = new QDateTime($this->lstBeforeMonth->SelectedIndex + 1 . '/1/' . $this->lstBeforeYear->SelectedValue); // Initialize output values $this->objPersonArray = array(); $this->monthCount = array(); $this->tempDate = new QDateTime($this->lstAfterMonth->SelectedIndex + 1 . '/1/' . $this->lstAfterYear->SelectedValue); while ($this->tempDate->IsEarlierOrEqualTo($this->endDate)) { $this->monthCount[$this->tempDate->__toString('MMM YYYY')] = 0; $this->objPersonArray[$this->tempDate->__toString('MMM YYYY')] = array(); $this->tempDate->AddMonths(1); } // Figure out which groups to search first. /* +----+------------------+----------------------------+ | id | token | name | +----+------------------+----------------------------+ | 1 | bc | Biblical Counseling | | 2 | hr | HR | | 3 | appurch | AP/Purchasing | | 4 | busops | Business Operations | | 5 | finance | Finance | | 6 | officemanagement | Office Management | | 7 | et | ETM | | 8 | evangoutreach | Evangelism and Outreach | | 9 | events | Events | | 10 | family | Family Ministry | | 11 | ibs | IBS | | 12 | music | Music | | 13 | pp | Pastor Paul | | 14 | volunteers | Volunteers | | 15 | worshiparts | Worship Arts | | 16 | facilities | Facilities | | 17 | growth | Growth Groups | | 18 | it | IT | | 19 | mc | Member Care | | 20 | mit | Ministry Involvement | | 21 | prayer | Prayer and Visitation | | 22 | safari | Safari Kids | | 23 | services | Worship Service Ministries | | 24 | videoprod | Video Production | | 25 | website | Website | | 26 | sp | Strategic Partnerships | | 27 | comm | Communications | | 28 | sm | Student Ministries | | 29 | payroll | Payroll | | 30 | mens | Men's Fellowship | | 31 | yam | Young Adult Ministry | | 32 | donations | Donations and Resources | | 33 | womens | Women's Ministry | | 34 | gmt | Global Ministry Team | | 35 | pastors | Pastoral Board | | 36 | recovery | Recovery | | 37 | singles | Singles | | 38 | seniors | Seniors | | 39 | minops | Ministry Operations | | 40 | stewardship | Stewardship | +----+------------------+----------------------------+- */ $objGroupCursor = Group::QueryCursor(QQ::In(QQN::Group()->GroupTypeId, array(GroupType::RegularGroup, GroupType::GrowthGroup))); while ($objGroup = Group::InstantiateCursor($objGroupCursor)) { switch (QApplication::PathInfo(2)) { case 'All': // increment all the appropriate arrays $this->calculateValues($objGroup); break; case 'OutreachEvangelismCare': // Biblical Counseling, Evangelism and Outreach, Global Ministry Team, Prayer and Visitation, Recovery, Strategic Partnerships if ($objGroup->MinistryId == 1 || $objGroup->MinistryId == 8 || $objGroup->MinistryId == 34 || $objGroup->MinistryId == 21 || $objGroup->MinistryId == 36 || $objGroup->MinistryId == 26) { $this->calculateValues($objGroup); } break; case 'AdministrativeOperations': // Communications, IT, Stewardship if ($objGroup->MinistryId == 27 || $objGroup->MinistryId == 18 || $objGroup->MinistryId == 40) { $this->calculateValues($objGroup); } break; case 'Discipleship': // Family Ministry, Growth Groups, IBS, Men's Fellowship if ($objGroup->MinistryId == 10 || $objGroup->MinistryId == 17 || $objGroup->MinistryId == 11 || $objGroup->MinistryId == 30) { $this->calculateValues($objGroup); } break; case 'MinistryOperations': // Member Care, Ministry Involvement, Ministry Operations, Safari Kids, Seniors, Singles, Student Ministries, Women's Ministry, Young Adult Ministry if ($objGroup->MinistryId == 19 || $objGroup->MinistryId == 20 || $objGroup->MinistryId == 39 || $objGroup->MinistryId == 22 || $objGroup->MinistryId == 38 || $objGroup->MinistryId == 37 || $objGroup->MinistryId == 28 || $objGroup->MinistryId == 33 || $objGroup->MinistryId == 31) { $this->calculateValues($objGroup); } break; case 'WorshipArts': // Video Production, Worship Arts if ($objGroup->MinistryId == 24 || $objGroup->MinistryId == 15) { $this->calculateValues($objGroup); } break; case 'WorshipService': // Worship Service Ministries if ($objGroup->MinistryId == 23) { $this->calculateValues($objGroup); } break; default: $objMinistry = Ministry::LoadByToken(QApplication::PathInfo(2)); if ($objMinistry->Token == $objGroup->MinistryId) { // Get all participants in the group $this->calculateValues($objGroup); } break; } } //print "Finished Processing\n"; /* foreach($this->monthCount as $key=>$value) { print "In ".$key.' there were '.$value. " unique volunteers\n"; } */ /* foreach($objPersonArray as $key=>$value) { print "In ".$key.' there were '.count($value). " unique volunteers\n"; } */ $chartArray = array(); foreach ($this->monthCount as $key => $value) { $objItem = new volunteerArray(); $objItem->month = $key; $objItem->count = $value; $chartArray[] = $objItem; } QApplication::ExecuteJavaScript('initializeChart(' . json_encode($chartArray) . ');'); $this->dtgVolunteers->DataSource = $chartArray; } }
// Notice that QuerySingle returned just a single Person object _p($objPerson->FirstName . ' ' . $objPerson->LastName); _p('<br/>', false); ?> <h3>QueryArray Example</h3> <?php $objPersonArray = Person::QueryArray(QQ::In(QQN::Person()->Id, array(5, 6, 8))); // Notice that QueryArray returns an array of Person objects... this will // be true even if the result set only yields 1 row.= foreach ($objPersonArray as $objPerson) { _p($objPerson->FirstName . ' ' . $objPerson->LastName); _p('<br/>', false); } ?> <h3>QueryCount Example</h3> <?php $intCount = Person::QueryCount(QQ::In(QQN::Person()->Id, array(5, 6, 8))); // Notice that QueryCount returns an integer _p($intCount . ' rows.'); ?> <?php require __INCLUDES__ . '/examples/footer.inc.php';
$strPath = '/old_downloads/qform_controls'; break; case 3: $strType = 'Other'; $strPath = '/old_downloads/other'; break; case 4: $strType = 'Langauge Files'; $strPath = '/old_downloads/language_files'; break; } $strName = sprintf('Downloads from Old Qcodo.com Website in "%s"', $strType); $strContent = sprintf('These are user-contributed downloads from the old *Qcodo.com* website in "%s", placed here for historical/archive purposes. ', $strType); $strContent .= 'For new user-submitted contributions, be sure to check out the "User Contributions":http://www.qcodo.com/qpm/ section of the website. "View All Old Downloads":wiki:/old_downloads'; $strContent .= "\r\n\r\n"; $objWikiItemArray = WikiItem::QueryArray(QQ::In(QQN::WikiItem()->Id, array_keys($arrDownloads[$intIndex])), QQ::OrderBy(QQN::WikiItem()->CurrentName)); foreach ($objWikiItemArray as $objWikiItem) { $strContent .= sprintf('file. %s', $objWikiItem->Path); $strContent .= "\r\n\r\n"; } $objWikiItem = WikiItem::CreateNewItem($strPath, WikiItemType::Page); $objWikiPage = new WikiPage(); $objWikiPage->Content = trim($strContent); $objWikiPage->CompileHtml(); $objWikiItem->CreateNewVersion($strName, $objWikiPage, 'Save', array(), Person::Load(1), null); } $objWikiItem = WikiItem::CreateNewItem('/old_downloads', WikiItemType::Page); $strContent = 'These are user-contributed downloads from the old *Qcodo.com* website, placed here for historical/archive purposes. '; $strContent .= 'For new user-submitted contributions, be sure to check out the "User Contributions":http://www.qcodo.com/qpm/ section of the website.'; $strContent .= "\r\n\r\n"; $strContent .= 'h2. "QForm Controls":wiki:/old_downloads/qform_controls';
public function btnAssetModelSearchToolAdd_Click() { $this->ctlAssetModelSearchTool->lblWarning->Text = ""; $intSelectedAssetModelId = $this->ctlAssetModelSearchTool->ctlAssetModelSearch->dtgAssetModel->GetSelected("AssetModelId"); if (count($intSelectedAssetModelId) < 1) { $this->ctlAssetModelSearchTool->lblWarning->Text = "No selected models."; } else { $lblNewWarning = ""; foreach (AssetModel::QueryArray(QQ::In(QQN::AssetModel()->AssetModelId, $intSelectedAssetModelId)) as $objNewAssetModel) { $blnExists = false; foreach ($this->arrAssetModels as $objAssetModel) { if ($objAssetModel->AssetModelId == $objNewAssetModel->AssetModelId) { $blnExists = true; } } if ($blnExists) { $lblNewWarning .= sprintf("<br />%s - already in list", $objNewAssetModel->AssetModelCode); } else { $objAssetModelToAdd = new AssetCustomFieldAssetModel(); $objAssetModelToAdd->AssetModelId = $objNewAssetModel->AssetModelId; $objAssetModelToAdd->CustomFieldId = $this->objCustomField->CustomFieldId; array_push($this->arrAssetModels, $objAssetModelToAdd); } } $this->lstAddAssetModel->Warning = $lblNewWarning; $this->ctlAssetModelSearchTool->dlgAssetModelSearchTool->HideDialogBox(); } // Uncheck all items but SelectAll checkbox $this->UncheckAllItems(); $this->dtgAssetModels->Refresh(); }
public function btnAssetSearchToolAdd_Click() { $this->ctlAssetSearchTool->lblWarning->Text = ""; $intSelectedAssetId = $this->ctlAssetSearchTool->ctlAssetSearch->dtgAsset->GetSelected("AssetId"); if (count($intSelectedAssetId) < 1) { $this->ctlAssetSearchTool->lblWarning->Text = "No selected assets."; } else { $lblNewWarning = ""; foreach (Asset::QueryArray(QQ::In(QQN::Asset()->AssetId, $intSelectedAssetId)) as $objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAddAsset_Click($this, null, null); if ($this->txtNewAssetCode->Warning) { $lblNewWarning .= sprintf("<br />%s - %s", $objAsset->AssetCode, $this->txtNewAssetCode->Warning); $this->txtNewAssetCode->Warning = ""; } } $this->txtNewAssetCode->Warning = $lblNewWarning; $this->ctlAssetSearchTool->dlgAssetSearchTool->HideDialogBox(); } // Uncheck all items but SelectAll checkbox $this->UncheckAllItems(); }
/** * Gets an array of Household objects shared by two people (e.g. all households where both people are participants. * @param Person $objPerson1 * @param Person $objPerson2 */ public static function LoadArrayBySharedHouseholds(Person $objPerson1, Person $objPerson2) { $intSharedHouseholdIdArray = array(); foreach ($objPerson1->GetHouseholdParticipationArray() as $objHouseholdParticipation) { $intSharedHouseholdIdArray[] = $objHouseholdParticipation->HouseholdId; } return Household::QueryArray(QQ::AndCondition(QQ::Equal(QQN::Household()->HouseholdParticipation->PersonId, $objPerson2->Id), QQ::In(QQN::Household()->Id, $intSharedHouseholdIdArray))); }
public function RenderCurrentGroups(Person $objPerson) { $this->objParticipations = GroupParticipation::QueryArray(QQ::AndCondition(QQ::Equal(QQN::GroupParticipation()->PersonId, $objPerson->Id), QQ::IsNull(QQN::GroupParticipation()->DateEnd), QQ::In(QQN::GroupParticipation()->GroupId, $this->intGroupIdArray)), QQ::Clause(QQ::OrderBy(QQN::GroupParticipation()->Group->Name), QQ::Expand(QQN::GroupParticipation()->Group->Name))); $strArray = array(); foreach ($this->objParticipations as $objParticipation) { $strArray[] = $objParticipation->Group->Name; } if (count($strArray)) { return implode(' and ', $strArray); } else { return '<span style="font-size: 10px; color: #999;">No current groups</span>'; } }
protected function btnPrintLabels_Click() { //if ($this->blnPrintLabels) { $this->strBarCodeArray = array(); $this->strTablesBufferArray = array(); $this->intCurrentBarCodeLabel = 0; // Set start value for PDF generation progress bar $_SESSION["intGeneratingStatus"] = 0; set_time_limit(0); $blnError = false; // Array[0] - DataGrid Object name; array[1] - Id; array[2] - used for Bar Code Label Generation $arrDataGridObjectNameId = $this->ctlSearchMenu->GetDataGridObjectNameId(); $this->intObjectIdArray = $this->ctlSearchMenu->{$arrDataGridObjectNameId}[0]->GetSelected($arrDataGridObjectNameId[1]); $objCheckedArray = array(); if (count($this->intObjectIdArray)) { // Switch statement for all four entity types switch ($this->lstLabelTypeControl->SelectedValue) { case 1: // Load an array of Assets by AssetId $objCheckedArray = Asset::QueryArray(QQ::In(QQN::Asset()->AssetId, $this->intObjectIdArray)); break; case 2: // Load an array of Inventories by InventoryModelId $objCheckedArray = InventoryModel::QueryArray(QQ::In(QQN::InventoryModel()->InventoryModelId, $this->intObjectIdArray)); break; case 3: // Load an array of Locations by LocationId $objCheckedArray = Location::QueryArray(QQ::In(QQN::Location()->LocationId, $this->intObjectIdArray)); break; case 4: $objCheckedArray = UserAccount::QueryArray(QQ::In(QQN::UserAccount()->UserAccountId, $this->intObjectIdArray)); break; default: $this->btnPrintLabels->Warning = "Please select Label Type.<br/>"; $this->intObjectIdArray = array(); $blnError = true; break; } $objArrayById = array(); // Create array of objects where the key is Id foreach ($objCheckedArray as $objChecked) { $objArrayById[$objChecked->{$arrDataGridObjectNameId}[1]] = $objChecked; } // Fill the BarCodeArray in the order items sorted in the datagrid foreach ($this->intObjectIdArray as $intObjectId) { $this->strBarCodeArray[] = $objArrayById[$intObjectId]->{$arrDataGridObjectNameId}[2]; } } else { $blnError = true; } if (!$blnError) { $this->btnPrintLabels->Warning = ""; $this->lstLabelStock->SelectedValue = 0; $this->lstLabelOffset->RemoveAllItems(); $this->lstLabelOffset->AddItem(new QListItem('None', 0, 1)); $this->lstLabelStock->Enabled = true; $this->lstLabelOffset->Enabled = true; $this->dlgPrintLabels->ShowDialogBox(); } else { // If we have no checked items $this->btnPrintLabels->Warning .= "You must check at least one item."; } // Enable Print Labels button $this->btnPrintLabels->Enabled = true; //$this->blnPrintLabels = false; /*} else { $this->btnPrintLabels->Warning = "Please wait... loading."; $this->blnPrintLabels = true; QApplication::ExecuteJavaScript("document.getElementById('".$this->btnPrintLabels->ControlId."').click(); document.getElementById('warning_loading').innerHTML = '';"); }*/ QApplication::ExecuteJavaScript("document.getElementById('warning_loading').innerHTML = '';"); }
public function __set($strName, $mixValue) { switch ($strName) { case "TranslationPath": if (file_exists($mixValue)) { $this->strTranslationPath = $mixValue; } else { if (!file_exists(dirname($mixValue))) { throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue))); } if (!is_writable(dirname($mixValue))) { throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue))); } chmod(dirname($mixValue), 0777); if (mkdir($mixValue, 0777, true)) { $this->strTranslationPath = $mixValue; } else { throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue)); } NarroUtils::RecursiveChmod($mixValue); } break; case "TemplatePath": if (file_exists($mixValue)) { $this->strTemplatePath = $mixValue; } else { if (!file_exists(dirname($mixValue))) { throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue))); } if (!is_writable(dirname($mixValue))) { throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue))); } chmod(dirname($mixValue), 0777); if (mkdir($mixValue, 0777, true)) { $this->strTranslationPath = $mixValue; } else { throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue)); } NarroUtils::RecursiveChmod($mixValue); } break; case "User": if ($mixValue instanceof NarroUser) { $this->objUser = $mixValue; } else { throw new Exception(t('User should be set with an instance of NarroUser')); } break; case "Project": if ($mixValue instanceof NarroProject) { $this->objProject = $mixValue; } else { throw new Exception(t('Project should be set with an instance of NarroProject')); } break; case "TargetLanguage": if ($mixValue instanceof NarroLanguage) { $this->objTargetLanguage = $mixValue; } else { throw new Exception(t('TargetLanguage should be set with an instance of NarroLanguage')); } break; case "SourceLanguage": if ($mixValue instanceof NarroLanguage) { $this->objSourceLanguage = $mixValue; } else { throw new Exception(t('SourceLanguage should be set with an instance of NarroLanguage')); } break; case "Approve": try { $this->blnApprove = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "SkipUntranslated": try { $this->blnSkipUntranslated = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "ApproveAlreadyApproved": try { $this->blnApproveAlreadyApproved = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "CheckEqual": try { $this->blnCheckEqual = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "ImportUnchangedFiles": try { $this->blnImportUnchangedFiles = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "ImportSuggestions": try { $this->blnImportSuggestions = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "CopyUnhandledFiles": try { $this->blnCopyUnhandledFiles = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "OnlySuggestions": try { $this->blnOnlySuggestions = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "ExportedSuggestion": try { $this->intExportedSuggestion = QType::Cast($mixValue, QType::Integer); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "ExportAuthorList": try { if (is_array($mixValue)) { $this->arrExportAuthorList = QType::Cast($mixValue, QType::ArrayType); } else { $arrAuthor = explode(',', $mixValue); foreach ($arrAuthor as $intIdx => $strAuthor) { $arrAuthor[$intIdx] = trim($strAuthor); } foreach (NarroUser::QueryArray(QQ::In(QQN::NarroUser()->RealName, $arrAuthor)) as $objUser) { $this->arrExportAuthorList[] = $objUser->UserId; } } break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: return false; } }
<h2>Example 2: Projects that are related to both 'Blueman Industrial Site Architecture' and 'ACME Payment System' projects</h2> <?php $objProjectArray = Project::QueryArray(QQ::AndCondition(QQ::Equal(QQ::Alias(QQN::Project()->ProjectAsRelated, 'related1')->Project->Name, 'Blueman Industrial Site Architecture'), QQ::Equal(QQ::Alias(QQN::Project()->ProjectAsRelated, 'related2')->Project->Name, 'ACME Payment System'))); foreach ($objProjectArray as $objProject) { _p($objProject->Name . " (" . $objProject->Description . ")"); _p('<br/>', false); } ?> <h2>Example 3: Managers having one least a project with a conson milestone, and for each manager, the first voyel milestone and the first conson one</h2> <?php $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(QQN::Person()->ProjectAsManager, null, $emptySelect), 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))); foreach ($objPersonArray as $objManager) { _p($objManager->FirstName . ' ' . $objManager->LastName . " (" . $objManager->GetVirtualAttribute('min_voyel') . ', ' . $objManager->GetVirtualAttribute('min_conson') . ")"); _p('<br/>', false); } ?> <h2>Example 4: Projects with, for each one, the "min" city from the addresses containing 'r' and the "min" city from the addresses NOT containing 'r' </h2> <?php $nWithR = QQ::Alias(QQN::Project()->PersonAsTeamMember->Person->Address, 'with_r'); $nWithoutR = QQ::Alias(QQN::Project()->PersonAsTeamMember->Person->Address, 'without_r'); $objProjectArray = Project::QueryArray(QQ::All(), QQ::Clause(QQ::Expand($nWithR, QQ::Like($nWithR->Street, '%r%')), QQ::Expand($nWithoutR, QQ::NotLike($nWithoutR->Street, '%r%')), QQ::GroupBy(QQN::Project()->Id), QQ::Minimum($nWithR->City, 'min_city_r'), QQ::Minimum($nWithoutR->City, 'min_city_wor'))); foreach ($objProjectArray as $objProject) { _p($objProject->Name . " (" . $objProject->GetVirtualAttribute('min_city_r') . ', ' . $objProject->GetVirtualAttribute('min_city_wor') . ")"); _p('<br/>', false); }
public function dtgGroups_Bind() { $objConditions = QQ::All(); $objClauses = array(); $objConditions = QQ::AndCondition($objConditions, QQ::Equal(QQN::GrowthGroup()->Group->ActiveFlag, true)); if ($this->chkDayOfWeek->Checked) { // Map to Days of Week $dayArray = array(); foreach (GrowthGroupDayType::$NameArray as $key => $value) { if (strpos(strtolower($this->objRegistrant->GroupDay), strtolower($value)) !== false) { $dayArray[] = $key; } } $objConditions = QQ::AndCondition($objConditions, QQ::In(QQN::GrowthGroup()->GrowthGroupDayTypeId, $dayArray)); } $growthGroupArray = GrowthGroup::QueryArray($objConditions); if ($this->chkGroupType->Checked) { $requestedGroupStructureArray = array(); foreach (GrowthGroupStructure::LoadAll() as $objGroupStructure) { if ($this->objRegistrant->IsGrowthGroupStructureAsGroupstructureAssociated($objGroupStructure)) { $requestedGroupStructureArray[] = $objGroupStructure; } } $newGrowthGroupArray = array(); foreach ($growthGroupArray as $objGroup) { foreach ($requestedGroupStructureArray as $objGroupStructure) { if ($objGroup->IsGrowthGroupStructureAssociated($objGroupStructure)) { $newGrowthGroupArray[] = $objGroup; break; } } } $growthGroupArray = $newGrowthGroupArray; } if ($this->chkAvailability->Checked) { $newGrowthGroupArray = array(); $intClosed = 0; foreach (AvailabilityStatus::LoadAll() as $objStatus) { if ($objStatus->Name == 'Closed') { $intClosed = $objStatus->Id; } } foreach ($growthGroupArray as $objGroup) { $intStatus = Group::Load($objGroup->GroupId)->Status; if ($intStatus != $intClosed) { $newGrowthGroupArray[] = $objGroup; } } $growthGroupArray = $newGrowthGroupArray; } if ($this->chkLocation->Checked) { // Map to our existing Growth Group Locations $locationIdArray = array(); $strLocationArray = array($this->objRegistrant->PreferredLocation1, $this->objRegistrant->PreferredLocation2); for ($i = 0; $i < 2; $i++) { if (null != $strLocationArray[$i]) { switch ($strLocationArray[$i]) { case 'Foster City': case 'San Bruno': case 'San Carlos': case 'San Mateo': case 'San Francisco': case 'South San Francisco': $locationIdArray[] = 1; break; case 'East Palo Alto': case 'Mountain View': case 'Menlo Park': case 'Palo Alto': case 'Redwood City': $locationIdArray[] = 2; break; case 'Campbell': case 'Cupertino': case 'Los Altos': case 'Sunnyvale': $locationIdArray[] = 3; break; case 'San Jose': case 'South San Jose': case 'Santa Clara': $locationIdArray[] = 4; break; case 'Fremont': case 'Milpitas': case 'Newark ': case 'Pleasanton': case 'Tracy': $locationIdArray[] = 5; break; case 'Oakland': case 'Clayton': $locationIdArray[] = 6; break; } } } $newGrowthGroupArray = array(); foreach ($growthGroupArray as $objGroup) { if (in_array($objGroup->GrowthGroupLocationId, $locationIdArray)) { $newGrowthGroupArray[] = $objGroup; } } $growthGroupArray = $newGrowthGroupArray; } $this->dtgGroups->DataSource = $growthGroupArray; }
public function btnApply_Click($strFormId, $strControlId, $strParameter) { $this->clearWarnings(); $blnError = false; $objDatabase = QApplication::$Database[1]; // Begin a MySQL Transaction to be either committed or rolled back $objDatabase->TransactionBegin(); // Check "Contact To", "Contact From", "Coutrier" wasn't changed for shipped items if (Shipment::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Shipment()->ShippedFlag, 1), QQ::In(QQN::Shipment()->ShipmentId, $this->arrShipmentToEdit))) > 0 && ($this->chkToCompany->Checked || $this->chkFromCompany->Checked || $this->chkCourier->Checked)) { $this->lblWarning->Text = '"To Company", "From Company", "Courier" shouldn\'t be changed for already Shipped items'; $blnError = true; } if (!$blnError) { // Apply checked main_table fields $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId)); if ($this->chkToCompany->Checked) { if ($this->lstToCompany->SelectedValue) { $set[] = sprintf('`to_company_id`="%s"', $this->lstToCompany->SelectedValue); } else { $this->lstToCompany->Warning = 'Company name must be chosen'; $blnError = true; } if ($this->lstToContact->SelectedValue) { $set[] = sprintf('`to_contact_id`="%s"', $this->lstToContact->SelectedValue); } else { $this->lstToContact->Warning = 'Contact name must be chosen'; $blnError = true; } if ($this->lstToAddress->SelectedValue) { $set[] = sprintf('`to_address_id`="%s"', $this->lstToAddress->SelectedValue); } else { $this->lstToContact->Warning = 'Address name must be chosen'; $blnError = true; } } if ($this->chkFromCompany->Checked) { if ($this->lstFromCompany->SelectedValue) { $set[] = sprintf('`from_company_id`="%s"', $this->lstFromCompany->SelectedValue); } else { $this->lstFromCompany->Warning = 'Company name must be chosen'; $blnError = true; } if ($this->lstFromContact->SelectedValue) { $set[] = sprintf('`from_contact_id`="%s"', $this->lstFromContact->SelectedValue); } else { $this->lstFromContact->Warning = 'Contact name must be chosen'; $blnError = true; } if ($this->lstFromAddress->SelectedValue) { $set[] = sprintf('`from_address_id`="%s"', $this->lstFromAddress->SelectedValue); } else { $this->lstFromAddress->Warning = 'Address name must be chosen'; $blnError = true; } } if ($this->chkCourier->Checked) { $set[] = sprintf('`courier_id`="%s"', $this->lstCourier->SelectedValue); } if ($this->chkShipDate->Checked && $this->calShipDate->DateTime) { $set[] = sprintf('`ship_date`="%s"', $this->calShipDate->DateTime->__toString('YYYY-MM-DD')); } } if (count($this->arrCustomFields) > 0) { $customFieldIdArray = array(); foreach ($this->arrCustomFields as $field) { if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) { if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) { $blnError = true; $field['input']->Warning = "Required."; } else { $this->arrCustomFieldsToEdit[] = $field; $customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId); } } } } // Apdate main table if (!$blnError) { try { // Edit Transactions foreach ($this->arrShipmentToEdit as $intShipmetId) { $objTransaction = Transaction::Load(Shipment::Load($intShipmetId)->Transaction->TransactionId); $objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId; if ($this->chkNote->Checked) { $objTransaction->Note = $this->txtNote->Text; } $objTransaction->Save(); } if (count($this->arrCustomFieldsToEdit) > 0) { // preparing data to edit // Save the values from all of the custom field controls to save the asset foreach ($this->arrShipmentToEdit as $intShipmentId) { $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Shipment, false); $selectedCustomFieldsArray = array(); foreach ($objCustomFieldsArray as $objCustomField) { if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) { $selectedCustomFieldsArray[] = $objCustomField; } } CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intShipmentId, EntityQtype::Shipment); } } $strQuery = sprintf("UPDATE `shipment`\n SET " . implode(",", $set) . "\n WHERE `shipment_id` IN (%s)", implode(",", $this->arrShipmentToEdit)); $objDatabase->NonQuery($strQuery); $objDatabase->TransactionCommit(); $this->ParentControl->HideDialogBox(); QApplication::Redirect(''); } catch (QMySqliDatabaseException $objExc) { $objDatabase->TransactionRollback(); throw new QDatabaseException(); } } else { $objDatabase->TransactionRollback(); $this->arrCustomFieldsToEdit = array(); $this->uncheck(); } }
public function btnGo_Click($strFormId, $strControlId, $strParameter) { //get a list of project ids that have had their status changed $changedIds = $this->colProjectSelected->GetChangedIds(); //load all the changed project objects at once so we can avoid multiple DB hits $temp = Project::QueryArray(QQ::In(QQN::Project()->Id, array_keys($changedIds))); //Put them in an associated list so we can find the needed ones easily later $changedItems = array(); foreach ($temp as $item) { $changedItems[$item->Id] = $item; } foreach ($changedIds as $id => $blnSelected) { //look up the appropriate item using the handily indexed array we built earlier $item = $changedItems[$id]; if ($blnSelected) { //Associate this Project QApplication::DisplayAlert('Associating ' . $item->Name); } else { //Unassociate this Project QApplication::DisplayAlert('Unassociating ' . $item->Name); } } }
/** * Given a search term, this will try and match all similarly matched individuals. * This will utilize soundex and other indexing methodologies. * * @param string $strName * @param QQCondition $objCondition * @param QQClause[] $objClauses * @param QQNodePerson $objPersonNode * @return void */ public static function PrepareQqForSearch($strName, QQCondition &$objCondition, &$objClauses, QQNodePerson $objPersonNode = null) { if (!$objPersonNode) { $objPersonNode = QQN::Person(); } $strNameItemArray = NameItem::GetNormalizedArrayFromNameString($strName, true); // First, get the applicable NameItem $intNameItemIdArrayArray = array(); foreach ($strNameItemArray as $strNameItem) { $intNameItemIdArray = array(); $strQuery = sprintf("SELECT * FROM name_item WHERE (soundex(name) = soundex('%s') OR name LIKE '%s%%')", mysql_escape_string($strNameItem), mysql_escape_string($strNameItem)); $objNameItemArray = NameItem::InstantiateDbResult(NameItem::GetDatabase()->Query($strQuery)); foreach ($objNameItemArray as $objNameItem) { $intNameItemIdArray[] = $objNameItem->Id; } $intNameItemIdArrayArray[] = $intNameItemIdArray; } // Build the search array from Person $intIndex = 0; foreach ($intNameItemIdArrayArray as $intNameItemIdArray) { if (!count($intNameItemIdArray)) { $objCondition = QQ::None(); return; } $intIndex++; $strAlias = 'assn_' . $intIndex; if ($intIndex == 2) { $objClauses[] = QQ::Distinct(); } $objClauses[] = QQ::CustomFrom('person_nameitem_assn', $strAlias); if (count($intNameItemIdArray) == 1) { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQ::CustomNode($strAlias . '.person_id'), $objPersonNode->Id), QQ::Equal(QQ::CustomNode($strAlias . '.name_item_id'), $intNameItemIdArray[0])); } else { $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQ::CustomNode($strAlias . '.person_id'), $objPersonNode->Id), QQ::In(QQ::CustomNode($strAlias . '.name_item_id'), $intNameItemIdArray)); } } }
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'); }
/** * Returns an array of items for the selected rows, loaded using the specified class's Load($id) method * * @param string $strClass The class name of the object type to return * @param bool $blnIndex Whether to spend extra time indexing the array by Id * @return array An array of selected Items * */ public function GetSelectedItems($strClass, $blnIndex = true, $objClauses = null) { $itemIds = $this->GetSelectedIds(); //load these items, using QQ::In so that it's a single DB hit $idQQNode = QQN::$strClass()->{$this->strPrimaryKey}; $conditions = QQ::In($idQQNode, $itemIds); $items = call_user_func(array($strClass, 'QueryArray'), $conditions, $objClauses); //Use the item's Id as the index, if desired. if ($blnIndex) { $newitems = array(); foreach ($items as $item) { $newitems[$item->{$this->strPrimaryKey}] = $item; } return $newitems; } return $items; }
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; }
public function btnAssetSearchToolAdd_Click() { $intSelectedAssetId = $this->ctlAssetSearchTool->ctlAssetSearch->dtgAsset->GetSelected("AssetId"); if (count($intSelectedAssetId) < 1) { $this->ctlAssetSearchTool->lblWarning->Text = "No selected assets."; } else { $lblNewWarning = ""; if (count($intSelectedAssetId) > 100) { $currentLimit = ini_get('max_execution_time'); set_time_limit(0); $this->ctlAssetSearchTool->lblWarning->Text = "This may take several minutes."; } foreach (Asset::QueryArray(QQ::In(QQN::Asset()->AssetId, $intSelectedAssetId)) as $objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAdd_Click($this, null, null); if ($this->txtNewAssetCode->Warning) { $lblNewWarning .= sprintf("<br />%s - %s", $objAsset->AssetCode, $this->txtNewAssetCode->Warning); $this->txtNewAssetCode->Warning = ""; } } if (count($intSelectedAssetId) > 100) { set_time_limit($currentLimit); $this->ctlAssetSearchTool->lblWarning->Text = ""; } $this->txtNewAssetCode->Warning = $lblNewWarning; $this->UncheckAllItems(); $this->ctlAssetSearchTool->dlgAssetSearchTool->HideDialogBox(); } // Uncheck all items but SelectAll checkbox }
public function testConditionalExpansion2() { $clauses = QQ::Clause(QQ::Expand(QQN::Login()->Person->ProjectAsManager, QQ::Equal(QQN::Login()->Person->ProjectAsManager->ProjectStatusTypeId, ProjectStatusType::Open)), QQ::ExpandAsArray(QQN::Login()->Person->ProjectAsManager->Milestone), QQ::ExpandAsArray(QQN::Login()->Person->Address), QQ::OrderBy(QQN::Login()->Person->Id)); $cond = QQ::In(QQN::Login()->PersonId, [1, 3, 7]); $targetLoginArray = Login::QueryArray($cond, $clauses); $targetLogin = reset($targetLoginArray); $this->assertEquals($targetLogin->Person->Id, 1, "Person 1 found."); $this->assertNotNull($targetLogin->Person->_ProjectAsManager, "Person 1 has an open project."); $targetLogin = next($targetLoginArray); $this->assertEquals($targetLogin->Person->Id, 3, "Person 3 found."); $this->assertNull($targetLogin->Person->_ProjectAsManager, "Person 3 does not have an open project."); $targetLogin = next($targetLoginArray); $this->assertEquals($targetLogin->Person->Id, 7, "Person 7 found."); $this->assertNull($targetLogin->Person->_ProjectAsManager, "Person 7 does have an open project."); }
public function btnApply_Click($strFormId, $strControlId, $strParameter) { $this->clearWarnings(); $blnError = false; // Get an instance of the database $objDatabase = QApplication::$Database[1]; // Begin a MySQL Transaction to be either committed or rolled back $objDatabase->TransactionBegin(); if (count($this->arrCustomFields) > 0) { $customFieldIdArray = array(); // preparing data to edit foreach ($this->arrCustomFields as $field) { if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) { if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) { $blnError = true; $field['input']->Warning = "Required."; } else { $this->arrCustomFieldsToEdit[] = $field; $customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId); } } } } // Apply checked main_table fields $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId)); if ($this->chkToCompany->Checked) { if ($this->lstToContact->SelectedValue) { $set[] = sprintf('`to_contact_id`="%s"', $this->lstToContact->SelectedValue); } else { $this->lstToContact->Warning = 'Contact name must be chosen'; $blnError = true; } if ($this->lstToAddress->SelectedValue) { $set[] = sprintf('`to_address_id`="%s"', $this->lstToAddress->SelectedValue); } else { $this->lstToAddress->Warning = 'Address name must be chosen'; $blnError = true; } } if ($this->chkFromCompany->Checked) { if ($this->lstFromCompany->SelectedValue) { $set[] = sprintf('`from_company_id`="%s"', $this->lstFromCompany->SelectedValue); } else { $this->lstFromCompany->Warning = 'Company name must be chosen'; $blnError = true; } if ($this->lstFromContact->SelectedValue) { $set[] = sprintf('`from_contact_id`="%s"', $this->lstFromContact->SelectedValue); } else { $this->lstFromContact->Warning = 'Contact name must be chosen'; $blnError = true; } } if ($this->chkDateReceived->Checked && $this->calDateReceived->DateTime) { // Check all receipts are completed if (Receipt::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Receipt()->ReceivedFlag, 0), QQ::In(QQN::Receipt()->ReceiptId, $this->arrReceiptToEdit))) > 0) { $this->calDateReceived->Warning = 'Can be set only for completed receipts'; $blnError = true; } else { $set[] = sprintf('`receipt_date`="%s"', $this->calDateReceived->DateTime->__toString('YYYY-MM-DD')); } } if ($this->chkDateDue->Checked && $this->calDateDue->DateTime) { $set[] = sprintf('`due_date`="%s"', $this->calDateDue->DateTime->__toString('YYYY-MM-DD')); } if (!$blnError) { try { // Modifying transactions foreach ($this->arrReceiptToEdit as $intReceiptId) { $objTransaction = Transaction::Load(Receipt::Load($intReceiptId)->Transaction->TransactionId); $objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId; if ($this->chkNote->Checked) { $objTransaction->Note = $this->txtNote->Text; } $objTransaction->Save(); } if (count($this->arrCustomFieldsToEdit) > 0) { // Save the values from all of the custom field controls to save the asset foreach ($this->arrReceiptToEdit as $intReceiptId) { $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Receipt, false); $selectedCustomFieldsArray = array(); foreach ($objCustomFieldsArray as $objCustomField) { if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) { $selectedCustomFieldsArray[] = $objCustomField; } } CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intReceiptId, EntityQtype::Receipt); } $this->arrCustomFieldsToEdit = array(); } // Update Transaction // Update main table $strQuery = sprintf("UPDATE `receipt`\n SET " . implode(",", $set) . "\n WHERE `receipt_id` IN (%s)", implode(",", $this->arrReceiptToEdit)); $objDatabase->NonQuery($strQuery); $objDatabase->TransactionCommit(); QApplication::Redirect(''); } catch (QMySqliDatabaseException $objExc) { $objDatabase->TransactionRollback(); throw new QDatabaseException(); } } else { $objDatabase->TransactionRollback(); $this->arrCustomFieldsToEdit = array(); $this->uncheck(); } }
/** * Get the most recent suggestion for a context made by a list of users * * @param integer $intContextId * @param integer $intTextId * @param integer $intUserId * @return NarroSuggestion */ protected function GetUserListSuggestion($intContextId, $intTextId, $intUserId) { return NarroSuggestion::QuerySingle(QQ::AndCondition(QQ::In(QQN::NarroSuggestion()->UserId, $this->arrExportAuthorList), QQ::Equal(QQN::NarroSuggestion()->TextId, $intTextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, $this->objTargetLanguage->LanguageId))); }
public static function _(QQNode $objQueryNode, $strSymbol, $mixValue, $mixValueTwo = null) { try { switch (strtolower(trim($strSymbol))) { case '=': return QQ::Equal($objQueryNode, $mixValue); case '!=': return QQ::NotEqual($objQueryNode, $mixValue); case '>': return QQ::GreaterThan($objQueryNode, $mixValue); case '<': return QQ::LessThan($objQueryNode, $mixValue); case '>=': return QQ::GreaterOrEqual($objQueryNode, $mixValue); case '<=': return QQ::LessOrEqual($objQueryNode, $mixValue); case 'in': return QQ::In($objQueryNode, $mixValue); case 'not in': return QQ::NotIn($objQueryNode, $mixValue); case 'like': return QQ::Like($objQueryNode, $mixValue); case 'not like': return QQ::NotLike($objQueryNode, $mixValue); case 'is null': return QQ::IsNull($objQueryNode, $mixValue); case 'is not null': return QQ::IsNotNull($objQueryNode, $mixValue); case 'between': return QQ::Between($objQueryNode, $mixValue, $mixValueTwo); case 'not between': return QQ::NotBetween($objQueryNode, $mixValue, $mixValueTwo); default: throw new QCallerException('Unknown Query Comparison Operation: ' . $strSymbol, 0); } } 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()); } } }
public function btnAddAsset_Click($strFormId, $strControlId, $strParameter) { if ($this->rblAssetType->SelectedValue == 'new') { $blnError = false; // Do not allow creation of an asset if asset limit will be exceeded $intAssetLimit = is_numeric(QApplication::$TracmorSettings->AssetLimit) ? QApplication::$TracmorSettings->AssetLimit : false; if ($intAssetLimit && Asset::CountActive() >= $intAssetLimit) { $blnError = true; $this->txtNewAssetCode->Warning = "Your asset limit has been reached."; } // Assign an empty string to the asset code for now (NULL won't work to render properly in the datagrid if ($this->chkAutoGenerateAssetCode->Checked == true) { $strAssetCode = ''; } else { $strAssetCode = $this->txtNewAssetCode->Text; if (!$strAssetCode) { $blnError = true; $this->txtNewAssetCode->Warning = 'You must enter an asset tag.'; } } // Generate an error if that asset code already exists if ($objDuplicate = Asset::LoadByAssetCode($strAssetCode)) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset tag already exists. Choose another.'; } elseif (!$this->lstAssetModel->SelectedValue) { $blnError = true; $this->txtNewAssetCode->Warning = 'You must select one model.'; } if (!$blnError) { $objNewAsset = new Asset(); $objNewAsset->AssetModelId = $this->lstAssetModel->SelectedValue; $objNewAsset->LocationId = 5; // To Be Received $objNewAsset->AssetCode = $strAssetCode; // Set the AssetId to 0. This is so that it can be assigned to an AssetTransaction object without being saved to the db // We don't want to save this until btnSave_Click, because we don't want to create new assets that could get orphaned $objNewAsset->AssetId = 0; // This can be combined with the code below it $this->txtNewAssetCode->Text = null; $this->txtNewAssetCode->Enabled = true; $this->chkAutoGenerateAssetCode->Checked = false; $this->lstAssetModel->SelectedValue = null; $objNewAssetTransaction = new AssetTransaction(); // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objNewAsset->LocationId; // $objNewAssetTransaction->AssetId = $objNewAsset->AssetId; $objNewAssetTransaction->Asset = $objNewAsset; $this->objAssetTransactionArray[] = $objNewAssetTransaction; // Set this boolean to true so that the datagrid updates $this->blnModifyAssets = true; } } elseif ($this->rblAssetType->SelectedValue == 'existing') { $strAssetCode = $this->txtNewAssetCode->Text; $blnDuplicate = false; $blnError = false; if ($strAssetCode) { // Begin error checking if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction && $objAssetTransaction->Asset->AssetCode == $strAssetCode) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset has already been added."; } } } if (!$blnError) { $objNewAsset = Asset::LoadByAssetCode($this->txtNewAssetCode->Text); if (!$objNewAsset instanceof Asset) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset tag does not exist."; } elseif ($objNewAsset->LinkedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is locked to a parent asset."; } elseif ($objNewAsset->ArchivedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is archived."; } elseif ($objNewAsset->CheckedOutFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is checked out."; } elseif ($objNewAsset->ReservedFlag) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset is reserved."; } elseif (!($objNewAsset->LocationId == 5 || $objNewAsset->LocationId == 2)) { $blnError = true; $this->txtNewAssetCode->Warning = "That asset has already been received."; } elseif (!QApplication::AuthorizeEntityBoolean($objNewAsset, 2)) { $blnError = true; $this->txtNewAssetCode->Warning = "You do not have authorization to perform a transaction on this asset."; } elseif ($objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objNewAsset->AssetId)) { $strAssetCodeArray = array(); $objCheckedLinkedAssetArray = array(); foreach ($objLinkedAssetArray as $objLinkedAsset) { if (!QApplication::AuthorizeEntityBoolean($objLinkedAsset, 2)) { $blnError = true; $this->txtNewAssetCode->Warning = sprintf("You do not have authorization to perform a transaction on locked asset %s.", $objLinkedAsset->AssetCode); break; } else { $objCheckedLinkedAssetArray[] = $objLinkedAsset; $strAssetCodeArray[] = $objLinkedAsset->AssetCode; } if (!$blnError) { $this->txtNewAssetCode->Warning = sprintf("The following asset(s) have been added to the transaction because they are locked to asset (%s):<br />%s", $objNewAsset->AssetCode, implode('<br />', $strAssetCodeArray)); } } if (!$blnError) { foreach ($objCheckedLinkedAssetArray as $objCheckedLinkedAsset) { $objNewAssetTransaction = new AssetTransaction(); // We can assign the AssetId for existing assets because they have already been saved to the db $objNewAssetTransaction->AssetId = $objCheckedLinkedAsset->AssetId; // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objCheckedLinkedAsset->LocationId; $this->objAssetTransactionArray[] = $objNewAssetTransaction; } } } if (!$blnError) { // Check that the asset isn't already in another pending receipt $arrPendingReceipts = AssetTransaction::QueryArray(QQ::AndCondition(QQ::Equal(QQN::AssetTransaction()->AssetId, $objNewAsset->AssetId), QQ::In(QQN::AssetTransaction()->SourceLocationId, array(5, 2)), QQ::IsNull(QQN::AssetTransaction()->DestinationLocationId), QQ::NotEqual(QQN::AssetTransaction()->TransactionId, $this->objReceipt->TransactionId))); if (!$blnError && count($arrPendingReceipts) != 0) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset is already pending receipt.'; } elseif (!$blnError && ($objPendingShipment = AssetTransaction::PendingShipment($objNewAsset->AssetId))) { $blnError = true; $this->txtNewAssetCode->Warning = 'That asset is in a pending shipment.'; } } // Create a new, but incomplete AssetTransaction if (!$blnError) { $this->txtNewAssetCode->Text = null; $this->txtNewAssetCode->Enabled = true; $this->chkAutoGenerateAssetCode->Checked = false; $this->lstAssetModel->SelectedValue = null; $objNewAssetTransaction = new AssetTransaction(); // We can assign the AssetId for existing assets because they have already been saved to the db $objNewAssetTransaction->AssetId = $objNewAsset->AssetId; // The source location can either be 'Shipped'(2) or 'To Be Received'(5) $objNewAssetTransaction->SourceLocationId = $objNewAsset->LocationId; $this->objAssetTransactionArray[] = $objNewAssetTransaction; // Set this boolean to true so that the datagrid updates $this->blnModifyAssets = true; } } } } $this->dtgAssetTransact->Refresh(); $this->txtNewAssetCode->Focus(); }
/** * Retrieves a list of Groups that can be managed by a given login * @param Login $objLogin * @return Group[] */ public static function LoadArrayByManagedByLogin(Login $objLogin) { if ($objLogin->RoleTypeId == RoleType::ChMSAdministrator) { $intMinistryIdArray = array(); foreach (Ministry::LoadArrayByActiveFlag(true) as $objMinistry) { $intMinistryIdArray[] = $objMinistry->Id; } } else { $intMinistryIdArray = array(); foreach ($objLogin->GetMinistryArray() as $objMinistry) { $intMinistryIdArray[] = $objMinistry->Id; } } return Group::QueryArray(QQ::AndCondition(QQ::Equal(QQN::Group()->GroupTypeId, GroupType::RegularGroup), QQ::In(QQN::Group()->MinistryId, $intMinistryIdArray), QQ::Equal(QQN::Group()->ActiveFlag, true)), QQ::OrderBy(QQN::Group()->Name)); }