protected function GetControlHtml() { $strOutput = $this->lblMessage->Render(false) . '<br /><table style="border: 1px solid #DDDDDD" cellpadding="4" cellspacing="0" width="100%">'; foreach (NarroProject::$AvailablePreferences as $strName => $arrPref) { if ($arrPref['project_type'] && $arrPref['project_type'] != $this->objProject->ProjectType) { continue; } $this->lblMessage->Text = t('Here you can set your project preferences.'); switch ($arrPref['type']) { case 'number': $txtNumber = new QIntegerTextBox($this); $txtNumber->Name = $strName; $txtNumber->Minimum = 5; $txtNumber->Maximum = 100; $txtNumber->MaxLength = 3; $txtNumber->Width = 50; if ($arrPref['global']) { $txtNumber->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId); } $txtNumber->Text = $this->objProject->GetPreferenceValueByName($strName); $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtNumber->RenderWithError(false), $arrPref['description'] ? t($arrPref['description']) : ''); $this->arrControls[$strName] = $txtNumber; break; case 'text': $txtTextPref = new QTextBox($this); $txtTextPref->Name = $strName; if ($arrPref['global']) { $txtTextPref->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId); } $txtTextPref->Text = $this->objProject->GetPreferenceValueByName($strName); $txtTextPref->Columns = strlen($txtTextPref->Text); $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtTextPref->RenderWithError(false), $arrPref['description'] ? t($arrPref['description']) : ''); $this->arrControls[$strName] = $txtTextPref; break; case 'option': $lstOption = new QListBox($this); $lstOption->Name = $strName; if ($arrPref['global']) { $lstOption->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId); } foreach ($arrPref['values'] as $strValue) { $lstOption->AddItem(t($strValue), $strValue, $strValue == $this->objProject->GetPreferenceValueByName($strName)); } $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $lstOption->RenderWithError(false), $arrPref['description'] ? t($arrPref['description']) : ''); $this->arrControls[$strName] = $lstOption; break; } } $strOutput .= '</table><br />'; $this->strText = $strOutput; return parent::GetControlHtml(); }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strAssetGroup = "Asset"; $strAssetModelGroup = "Model"; $lstMapHeader->AddItem("- Not Mapped -", null); $lstMapHeader->AddItem("Asset Tag", "Asset Code", $strName == 'asset code' ? true : false, $strAssetGroup, 'CssClass="redtext"'); foreach ($this->arrAssetCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "asset_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetGroup); } $lstMapHeader->AddItem("Location", "Location", $strName == 'location' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Created By", "Created By", $strName == 'created by' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Created Date", "Created Date", $strName == 'created date' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified By", "Modified By", $strName == 'modified by' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified Date", "Modified Date", $strName == 'modified date' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Model Number", "Asset Model Code", $strName == 'asset model code' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Model Short Description", "Asset Model Short Description", $strName == 'asset model short description' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Model Long Description", "Asset Model Long Description", $strName == 'asset model long description' ? true : false, $strAssetModelGroup); foreach ($this->arrAssetModelCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "model_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetModelGroup); } $lstMapHeader->AddItem("Category", "Category", $strName == 'category' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Manufacturer", "Manufacturer", $strName == 'manufacturer' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; if ($strName && $lstMapHeader->SelectedValue) { //$this->arrTracmorField[$intId] = strtolower($lstMapHeader->SelectedValue); } return true; }
public function RenderFund(RecurringDonationItems $objItem = null) { if (!$objItem) { return '<strong>TOTAL SUBMISSION</strong>'; } $lstFunds = $this->GetControl('lstFunds' . $this->dtgDonationItems->CurrentRowIndex); $txtFund = $this->GetControl('txtFund' . $this->dtgDonationItems->CurrentRowIndex); if (!$lstFunds) { $lstFunds = new QListBox($this->dtgDonationItems, 'lstFunds' . $this->dtgDonationItems->CurrentRowIndex); $lstFunds->ActionParameter = $this->dtgDonationItems->CurrentRowIndex; $lstFunds->AddAction(new QChangeEvent(), new QAjaxAction('lstFunds_Change')); $txtFund = new QTextBox($this->dtgDonationItems, 'txtFund' . $this->dtgDonationItems->CurrentRowIndex); $txtFund->Visible = false; if (!$objItem->StewardshipFundId) { $lstFunds->AddItem('- Select One -', null); } foreach (StewardshipFund::LoadArrayByExternalFlag(true, QQ::OrderBy(QQN::StewardshipFund()->ExternalName)) as $objFund) { $lstFunds->AddItem($objFund->ExternalName, $objFund->Id, $objFund->Id == $objItem->StewardshipFundId); } $lstFunds->AddItem('- Other... -', false); } return $lstFunds->RenderWithError(false) . ' ' . $txtFund->RenderWithError(false); }
protected function arrControls_Create() { if ($this->objModuleArray) { foreach ($this->objModuleArray as $objModule) { // Create Access List Controls $objAccessControl = new QListBox($this); $objAccessControl->ActionParameter = $objModule->ModuleId; $objAccessControl->Width = 100; $objAccessControl->CssClass = "greentext"; $objEnabledItem = new QListItem('Enabled', 1, false, null, 'CssClass="greentext"'); $objDisabledItem = new QListItem('Disabled', 0, false, null, 'CssClass="redtext"'); if ($this->blnEditMode) { $objRoleModule = RoleModule::LoadByRoleIdModuleId($this->objRole->RoleId, $objModule->ModuleId); if ($objRoleModule) { if ($objRoleModule->AccessFlag) { $objEnabledItem->Selected = true; $objDisabledItem->Selected = false; $objAccessControl->CssClass = "greentext"; } else { $objEnabledItem->Selected = false; $objDisabledItem->Selected = true; $objAccessControl->CssClass = "redtext"; } } } // Add Items to Access Control $objAccessControl->AddItem($objEnabledItem); $objAccessControl->AddItem($objDisabledItem); $objAccessControl->AddAction(new QChangeEvent(), new QAjaxAction('lstAccessControl_Select')); // Set the List Item objects to null because QCodo will maintain them in the formstate otherwise $objEnabledItem = null; $objDisabledItem = null; $this->arrControls[$objModule->ShortDescription]['access'] = $objAccessControl; $objAccessControl = null; if ($this->objAuthorizationArray) { foreach ($this->objAuthorizationArray as $objAuthorization) { // Create Authorization Controls foreach authorization type (view/edit/delete) // We could loop through AuthorizationLevels here, but no need to right now $objControl = new QListBox($this); $objControl->Width = 100; $objControl->ActionParameter = $objModule->ModuleId; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); if ($this->blnEditMode && $objRoleModule) { $objControl->Enabled = $objRoleModule->AccessFlag ? true : false; $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, $objAuthorization->AuthorizationId); if ($objRoleModuleAuthorization) { // Select the Proper Authorization Level if ($objRoleModuleAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleModuleAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleModuleAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } // Add the RoleModuleAuthorization to an array so that it can be checked for Optimistic Locking Constraints when saving $this->objRoleModuleAuthorizationArray[$objRoleModule->RoleModuleId . '-' . $objAuthorization->AuthorizationId] = $objRoleModuleAuthorization; $objRoleModuleAuthorization = null; } else { $objAllItem->Selected = true; } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); // Do not include the 'None' List Item for View // If an administrator does not want to allow for viewing, they should disable access. This eliminates the problem of setting View: None, but Edit: All // The problem with View: Owner and Edit: All still exists if ($objAuthorization->AuthorizationId != 1) { $objControl->AddItem($objNoneItem); } $objAllItem = null; $objOwnerItem = null; $objNoneItem = null; // Assign the Controls array if ($objAuthorization->ShortDescription == 'edit') { $objControl->AddAction(new QChangeEvent(), new QAjaxAction('lstEdit_Change')); $arrEditControlIdModuleId[] = $objControl->ControlId . "-" . $objModule->ModuleId; //$this->lstEdit_Change($this->FormId, $objControl->ControlId, $objModule->ModuleId); } $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription] = $objControl; $objControl = null; } } $objRoleModule = null; } } foreach ($arrEditControlIdModuleId as $strControlIdModuleId) { $arrExplode = explode("-", $strControlIdModuleId); $this->lstEdit_Change($this->FormId, $arrExplode[0], $arrExplode[1]); } // Create control for Move $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 1; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 1); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['move'] = $objControl; // Create control for Check In/Out $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 2; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 2); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['check_in_out'] = $objControl; // Create control for Reserve/Unreserve $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 3; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 8); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['reserve_unreserve'] = $objControl; // Create control for Take Out $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 4; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 5); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['take_out'] = $objControl; // Create control for Restock $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 5; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 4); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['restock'] = $objControl; // Create control for Check In/Out $objControl = new QListBox($this); $objControl->Width = 100; $objAllItem = new QListItem('All', 1); $objOwnerItem = new QListItem('Owner', 2); $objNoneItem = new QListItem('None', 3); $objControl->ActionParameter = 6; if ($this->blnEditMode) { $objRoleTransactionTypeAuthorization = RoleTransactionTypeAuthorization::LoadByRoleIdTransactionTypeId($this->objRole->RoleId, 10); if ($objRoleTransactionTypeAuthorization) { // Select the Proper Authorization Level if ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 1) { $objAllItem->Selected = true; $objOwnerItem->Selected = false; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 2) { $objAllItem->Selected = false; $objOwnerItem->Selected = true; $objNoneItem->Selected = false; } elseif ($objRoleTransactionTypeAuthorization->AuthorizationLevelId == 3) { $objAllItem->Selected = false; $objOwnerItem->Selected = false; $objNoneItem->Selected = true; } } } $objControl->AddItem($objAllItem); $objControl->AddItem($objOwnerItem); $objControl->AddItem($objNoneItem); $this->arrControls['archive_unarchive'] = $objControl; }
public function AdvancedColumn_Render(AssetTransaction $objAssetTransaction) { if (!$objAssetTransaction->Asset->TempId) { $objAssetTransaction->Asset->TempId = $this->intNewTempId++; } $strControlId = 'lstAdvanced' . $objAssetTransaction->Asset->TempId; $lstAdvanced = $this->GetControl($strControlId); if (!$lstAdvanced) { // Create the advanced label for this row in the datagrid // Use ActionParameter to specify the Temp ID of the asset $lstAdvanced = new QListBox($this->dtgAssetTransact, $strControlId); $lstAdvanced->ActionParameter = $objAssetTransaction->Asset->TempId; $lstAdvanced->CausesValidation = false; $lstAdvanced->AddItem('None', 0); $lstAdvanced->AddItem('Schedule for Return', 1); $lstAdvanced->AddItem('Schedule for Exchange', 2); $lstAdvanced->AddAction(new QChangeEvent(), new QAjaxAction('lstAdvancedColumn_Change')); $lstAdvanced->Width = 200; if ($objAssetTransaction->Asset->LinkedFlag) { $lstAdvanced->Enabled = false; } } if ($objAssetTransaction->ScheduleReceiptFlag) { if ($objAssetTransaction->NewAssetFlag) { $lstAdvanced->SelectedValue = 2; } else { $lstAdvanced->SelectedValue = 1; } } else { $lstAdvanced->SelectedValue = 0; } return $lstAdvanced->Render(false); }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strCategoryGroup = "Category"; $lstMapHeader->AddItem("- Not Mapped -", null); // Add ID for update imports only if ($this->lstImportAction->SelectedValue == 2) { $lstMapHeader->AddItem("ID", "ID", $strName == 'id' ? true : false, $strCategoryGroup, 'CssClass="redtext"'); } $lstMapHeader->AddItem("Category Name", "Category Name", $strName == 'category' ? true : false, $strCategoryGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Category Description", "Category Description", $strName == 'description' ? true : false, $strCategoryGroup); $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; foreach ($this->arrItemCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "category_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strCategoryGroup); } return true; }
protected function GetControlHtml() { $strOutput = $this->lblMessage->Render(false) . '<br /><table style="border: 1px solid #DDDDDD" cellpadding="4" cellspacing="0" width="100%">'; foreach (NarroUser::$AvailablePreferences as $strName => $arrPref) { switch ($arrPref['type']) { case 'number': $txtNumber = new QIntegerTextBox($this); $txtNumber->Name = $strName; $txtNumber->Minimum = 5; $txtNumber->Maximum = 100; $txtNumber->MaxLength = 3; $txtNumber->Width = 50; $txtNumber->Text = $this->objUser->GetPreferenceValueByName($strName); $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtNumber->RenderWithError(false), t($arrPref['description'])); $this->arrControls[$strName] = $txtNumber; break; case 'text': $txtTextPref = new QTextBox($this); $txtTextPref->Name = $strName; $txtTextPref->Text = $this->objUser->GetPreferenceValueByName($strName); if ($strName == 'Special characters') { $strSelect = sprintf('<select onchange="document.getElementById(\'%s\').value+=this.options[this.selectedIndex].value;">', $txtTextPref->ControlId); foreach (NarroDiacriticsPanel::$arrEntities as $strEntityName => $strEntityChar) { $strSelect .= sprintf('<option value=" %s">%s (%s)', $strEntityName, $strEntityChar, $strEntityName); } $strSelect .= '</select>'; $arrPref['description'] = t($arrPref['description']) . $strSelect; $txtTextPref->Width = 400; } elseif ($strName == 'Other languages') { $strSelect = sprintf('<select onchange="document.getElementById(\'%s\').value+= \' \' + this.options[this.selectedIndex].value;">', $txtTextPref->ControlId); foreach (NarroLanguage::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objLanguage) { $strSelect .= sprintf('<option value="%s">%s (%s)', $objLanguage->LanguageCode, t($objLanguage->LanguageName), $objLanguage->LanguageCode); } $strSelect .= '</select>'; $arrPref['description'] = t($arrPref['description']) . $strSelect; $txtTextPref->Width = 400; } $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtTextPref->RenderWithError(false), $arrPref['description']); $this->arrControls[$strName] = $txtTextPref; break; case 'option': $lstOption = new QListBox($this); $lstOption->Name = $strName; if ($strName == 'Language') { $arrLanguages = NarroLanguage::LoadAllActive(QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))); foreach ($arrLanguages as $objLanguage) { $lstOption->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageCode, $objLanguage->LanguageCode == $this->objUser->GetPreferenceValueByName($strName)); } } elseif ($strName == 'Application language') { $arrLanguages = NarroLanguage::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))); foreach ($arrLanguages as $objLanguage) { $lstOption->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageCode, $objLanguage->LanguageCode == $this->objUser->GetPreferenceValueByName($strName)); } } else { foreach ($arrPref['values'] as $strValue) { $lstOption->AddItem(t($strValue), $strValue, $strValue == $this->objUser->GetPreferenceValueByName($strName)); } } $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $lstOption->RenderWithError(false), t($arrPref['description'])); $this->arrControls[$strName] = $lstOption; break; } } $strOutput .= '</table><br />'; $strOutput .= $this->btnCancel->Render(false) . ' ' . $this->btnSave->Render(false); if ($this->txtPreviousUrl) { $strOutput .= ' ' . sprintf(t('Click <a href="%s">here</a> to return to the page you were.'), $this->txtPreviousUrl); } $this->strText = $strOutput; return parent::GetControlHtml(); }
public function RenderQuantity($objItem) { // Required and Optional Products if ($objItem instanceof FormProduct) { if ($objItem->FormProductTypeId == FormProductType::Required) { return '1'; } else { if ($objItem->FormProductTypeId == FormProductType::Optional) { if ($objItem->FormPaymentTypeId == FormPaymentType::Donation) { return '1'; } else { $lstQuantity = $this->GetControl('lstQuantity' . $objItem->Id); if (!$lstQuantity) { $lstQuantity = new QListBox($this->dtgProducts, 'lstQuantity' . $objItem->Id); $lstQuantity->ActionParameter = $objItem->Id; $lstQuantity->AddItem(0, 0); for ($intQuantity = $objItem->MinimumQuantity; $intQuantity <= $objItem->MaximumQuantity; $intQuantity++) { $lstQuantity->AddItem($intQuantity, $intQuantity); } $lstQuantity->SelectedIndex = 0; $lstQuantity->AddAction(new QChangeEvent(), new QAjaxAction('lstQuantity_Change')); } } return $lstQuantity->Render(false); } } // Payment Entries } else { if ($objItem instanceof SignupPayment) { return null; // "Required with Choice" Products } else { if ($objItem == -1) { if ($this->lstRequiredWithChoice->SelectedValue) { return '1'; } else { return null; } } } } }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strAssetGroup = "Asset"; $strAssetGroup = "Asset"; $lstMapHeader->AddItem("- Not Mapped -", null); // Add ID for update imports only if ($this->lstImportAction->SelectedValue == 2) { $lstMapHeader->AddItem("ID", "ID", $strName == 'id' ? true : false, $strAssetGroup, 'CssClass="redtext"'); } $lstMapHeader->AddItem("Asset Tag", "Asset Tag", $strName == 'asset tag' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Model", "Model", $strName == 'model' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Location", "Location", $strName == 'location' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Parent Asset", "Parent Asset", $strName == 'parent asset' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Locked To Parent", "Locked To Parent", $strName == 'locked to parent' ? true : false, $strAssetGroup); // Add Depreciation fields if enabled if (QApplication::$TracmorSettings->DepreciationFlag == '1') { $lstMapHeader->AddItem("Depreciate Asset", "Depreciate Asset", $strName == "depreciate asset" ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Purchase Date", "Purchase Date", $strName == "purchase date" ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Purchase Cost", "Purchase Cost", $strName == "purchase cost" ? true : false, $strAssetGroup); } foreach ($this->arrAssetCustomField as $objCustomField) { // Add style to Required Fields for All Asset Models if ($objCustomField->RequiredFlag && $objCustomField->AllAssetModelsFlag) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "asset_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetGroup, 'CssClass="redtext"'); } else { $lstMapHeader->AddItem($objCustomField->ShortDescription, "asset_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetGroup); } } /*$lstMapHeader->AddItem("Created By", "Created By", ($strName == 'created by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Created Date", "Created Date", ($strName == 'created date') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified By", "Modified By", ($strName == 'modified by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified Date", "Modified Date", ($strName == 'modified date') ? true : false, $strAssetGroup);*/ $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; /*if ($strName && $lstMapHeader->SelectedValue) { //$this->arrTracmorField[$intId] = strtolower($lstMapHeader->SelectedValue); }*/ return true; }
/** * Creates the actual control that will edit the value. * * @param QControl $objParent * @return QIntegerTextBox|QListBox|QRadioButtonList|QTextBox */ protected function CreateControl(QControl $objParent) { switch ($this->controlType) { case QType::Boolean: $ctl = new QRadioButtonList($objParent); $ctl->AddItem('True', true); $ctl->AddItem('False', false); $ctl->AddItem('None', null); $ctl->RepeatColumns = 3; break; case QType::String: $ctl = new QTextBox($objParent); break; case QType::Integer: $ctl = new QIntegerTextBox($objParent); break; case QType::ArrayType: // an array the user will specify in a comma separated list $ctl = new QTextBox($objParent); break; case QModelConnectorParam::SelectionList: // a specific set of choices to present to the user $ctl = new QListBox($objParent); foreach ($this->options as $key => $val) { $ctl->AddItem($val, $key === '' ? null : $key); // allow null item keys } break; default: // i.e. QJsClosure, or other random items. Probably codegened, and not used much. $ctl = new QTextBox($objParent); break; } $ctl->Name = $this->strName; $ctl->ToolTip = $this->strDescription; return $ctl; }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strAssetGroup = "Asset"; $strAssetGroup = "Asset"; $lstMapHeader->AddItem("- Not Mapped -", null); // Add ID for update imports only if ($this->lstImportAction->SelectedValue == 2) { $lstMapHeader->AddItem("ID", "ID", $strName == 'id' ? true : false, $strAssetGroup, 'CssClass="redtext"'); } $lstMapHeader->AddItem("Asset Code", "Asset Code", $strName == 'asset code' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Asset Model", "Asset Model", $strName == 'asset model' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Location", "Location", $strName == 'location' ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Parent Asset", "Parent Asset", $strName == 'parent asset' ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Locked To Parent", "Locked To Parent", $strName == 'locked to parent' ? true : false, $strAssetGroup); foreach ($this->arrAssetCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "asset_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetGroup); } /*$lstMapHeader->AddItem("Created By", "Created By", ($strName == 'created by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Created Date", "Created Date", ($strName == 'created date') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified By", "Modified By", ($strName == 'modified by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified Date", "Modified Date", ($strName == 'modified date') ? true : false, $strAssetGroup);*/ $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; /*if ($strName && $lstMapHeader->SelectedValue) { //$this->arrTracmorField[$intId] = strtolower($lstMapHeader->SelectedValue); }*/ return true; }
/** * Creates all the controls for each "question" in the form. * Note: For any fields that are looked up from the user's profile (e.g. address, phone, etc.) -- a drop down is available for quick access. * However, if they select "other", we save the data and do NOT link it to any records! * (e.g. if an "other" phone is used, that data is not stored anywhere else) */ protected function CreateFormItemControls() { /** * @var Person */ $objPerson = $this->objSignupEntry->Person; if ($objPerson != null) { // First, set up for the Person Name label $lblPersonName = new QLabel($this, 'lblPersonName'); $lblPersonName->Name = 'Name'; $lblPersonName->Required = true; $lblPersonName->Text = $objPerson->Name; $lblPersonName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lblPersonName; } else { // else if not logged in, prompt for First and Last Name. Always. $txtFirstName = new QTextBox($this); $txtFirstName->Name = 'First Name'; $txtFirstName->Required = true; $txtFirstName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtFirstName; $txtLastName = new QTextBox($this); $txtLastName->Name = 'Last Name'; $txtLastName->Required = true; $txtLastName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtLastName; } // Go through all the other fields foreach ($this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) { // Only display if this is NOT "InternalFlag" if ($objFormQuestion->InternalFlag) { continue; } $strControlId = 'fq' . $objFormQuestion->Id; $objFormAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($this->objSignupEntry->Id, $objFormQuestion->Id); switch ($objFormQuestion->FormQuestionTypeId) { case FormQuestionType::SpouseName: if ($objPerson != null) { if (($objMarriage = $objPerson->GetMostRecentMarriage()) && $objMarriage->MarriedToPerson) { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->ActionParameter = $strControlId . 'nm'; if (!$objFormQuestion->RequiredFlag) { $lstSpouse->AddItem('- Select One -', null); } $lstSpouse->AddItem($objMarriage->MarriedToPerson->Name, $objMarriage->MarriedToPerson->Id, true); $lstSpouse->AddItem('- Other... -', false); $lstSpouse->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstSpouse->Name = $objFormQuestion->Question; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = false; $txtName->Required = false; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { if ($lstSpouse->SelectedName != $objFormAnswer->TextValue) { $lstSpouse->SelectedIndex = count($lstSpouse->GetAllItems()) - 1; $txtName->Text = $objFormAnswer->TextValue; $this->lst_ToggleOther(null, $lstSpouse->ControlId, $lstSpouse->ActionParameter); } } } else { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->Visible = false; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } } else { $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } break; case FormQuestionType::Address: if ($objPerson != null) { $objHouseholdArray = Household::LoadArrayBySharedHouseholds($objPerson, $this->objSignupEntry->SignupByPerson); if (count($objHouseholdArray) > 1) { // TODO: Implement! throw new Exception('TODO: Not Implemented'); } else { if (count($objHouseholdArray) == 1) { $objAddress = $objHouseholdArray[0]->GetCurrentAddress(); $rblAddress = new QRadioButtonList($this, $strControlId . 'switch'); $rblAddress->Name = $objFormQuestion->Question; $rblAddress->RenderMethod = 'RenderWithName'; $rblAddress->AddItem('Use Home Address Below', $objAddress->Id, true); $rblAddress->AddItem('Edit Home Address', false, false); $rblAddress->RepeatColumns = 2; $rblAddress->AddAction(new QClickEvent(), new QAjaxAction('rblAddress_Change')); $this->objFormQuestionControlArray[] = $rblAddress; } else { $objAddress = new Address(); $rblAddress = null; } } } $txtAddress1 = new QTextBox($this, $strControlId . 'address1'); $txtAddress1->Name = 'Address 1'; $txtAddress1->RenderMethod = 'RenderWithName'; $txtAddress1->Text = $objPerson != null ? $objAddress->Address1 : ''; $txtAddress2 = new QTextBox($this, $strControlId . 'address2'); $txtAddress2->Name = 'Address 2'; $txtAddress2->RenderMethod = 'RenderWithName'; $txtAddress2->Text = $objPerson != null ? $objAddress->Address2 : ''; $txtCity = new QTextBox($this, $strControlId . 'city'); $txtCity->Name = 'City, State and Zip'; $txtCity->RenderMethod = 'RenderWithName'; $txtCity->Text = $objPerson != null ? $objAddress->City : ''; $lstState = new QListBox($this, $strControlId . 'state'); $lstState->ActionParameter = '_' . $strControlId . 'city'; $lstState->Name = QApplication::Translate('State'); $lstState->RenderMethod = 'RenderWithError'; $lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { if ($objPerson != null) { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation); } else { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, false); } } $txtZipCode = new QTextBox($this, $strControlId . 'zipcode'); $txtZipCode->ActionParameter = '_' . $strControlId . 'city'; $txtZipCode->Name = 'Zip Code'; $txtZipCode->RenderMethod = 'RenderWithError'; $txtZipCode->Text = $objPerson != null ? $objAddress->ZipCode : ''; $txtZipCode->Width = '80px'; if ($objFormQuestion->RequiredFlag) { $txtAddress1->Required = true; $txtCity->Required = true; $lstState->Required = true; $txtZipCode->Required = true; } $this->objFormQuestionControlArray[] = $txtAddress1; $this->objFormQuestionControlArray[] = $txtAddress2; $this->objFormQuestionControlArray[] = $txtCity; $this->objFormQuestionControlArray[] = $lstState; $this->objFormQuestionControlArray[] = $txtZipCode; // Final configuration based on whether or not we've got a household record for this person // (in which case we have defined a rblAddress) if ($objPerson != null) { if ($rblAddress) { // Check to see if the question has been answered before if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { // If it $objAddress = Address::DeduceAddressFromFullLine($objFormAnswer->TextValue); if ($objFormAnswer->AddressId == $rblAddress->SelectedValue || !$objAddress) { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } else { $txtAddress1->Text = $objAddress->Address1; $txtAddress2->Text = $objAddress->Address2; $txtCity->Text = $objAddress->City; $txtZipCode->Text = $objAddress->ZipCode; $lstState->SelectedValue = $objAddress->State; $rblAddress->SelectedIndex = 1; } // It has not -- let's default to having the address be presumed correct } else { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } // No rblAddress - so let's update the address1 label to match the form question's question text } else { $txtAddress1->Name = $objFormQuestion->Question; } } break; case FormQuestionType::Age: $txtAge = new QIntegerTextBox($this, $strControlId . 'age'); $txtAge->Name = $objFormQuestion->Question; $txtAge->Minimum = 0; $txtAge->Maximum = 130; $txtAge->MaxLength = 3; if ($objFormAnswer && !is_null($objFormAnswer->IntegerValue)) { $txtAge->Text = $objFormAnswer->IntegerValue; } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && $objPerson->Age) { $txtAge->Text = $objPerson->Age; } } } if ($objFormQuestion->RequiredFlag) { $txtAge->Required = true; } $txtAge->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAge; $txtAge->Width = '50px'; break; case FormQuestionType::DateofBirth: $dtxDateOfBirth = new QDateTimeTextBox($this, $strControlId . 'dob'); $dtxDateOfBirth->LabelForInvalid = 'For example, "Mar 20 1977"'; $dtxDateOfBirth->Name = $objFormQuestion->Question; if ($objFormAnswer && !is_null($objFormAnswer->DateValue)) { $dtxDateOfBirth->Text = $objFormAnswer->DateValue->ToString('MMM D YYYY'); } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && !$objPerson->DobGuessedFlag && $objPerson->DateOfBirth) { $dtxDateOfBirth->Text = $objPerson->DateOfBirth->ToString('MMM D YYYY'); } } } if ($objFormQuestion->RequiredFlag) { $dtxDateOfBirth->Required = true; } $dtxDateOfBirth->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $dtxDateOfBirth; $dtxDateOfBirth->Width = '150px'; break; case FormQuestionType::Gender: $lstGender = new QListBox($this, $strControlId . 'gender'); $lstGender->Name = $objFormQuestion->Question; $lstGender->AddItem('- Select One -', null); if ($objFormAnswer && $objFormAnswer->TextValue) { $lstGender->AddItem('Male', true, $objFormAnswer->BooleanValue); $lstGender->AddItem('Female', false, !$objFormAnswer->BooleanValue); } else { if ($objPerson != null) { $lstGender->AddItem('Male', true, $objPerson->Gender == 'M'); $lstGender->AddItem('Female', false, $objPerson->Gender == 'F'); } else { $lstGender->AddItem('Male', true, true); // just default to something $lstGender->AddItem('Female', false, false); } } if ($objFormQuestion->RequiredFlag) { $lstGender->Required = true; } $lstGender->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstGender; break; case FormQuestionType::Phone: $objPhoneArray = array(); if ($objPerson != null) { // Add Household Numbers (if applicable) foreach ($objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetCurrentAddress()->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } } // Add Personal Numbers foreach ($objPerson->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } if (count($objPhoneArray)) { $lstPhone = new QListBox($this, $strControlId . 'id'); $lstPhone->ActionParameter = $strControlId . 'phone'; $lstPhone->Name = $objFormQuestion->Question; $lstPhone->AddItem('- Select One -', null); rsort($objPhoneArray); foreach ($objPhoneArray as $objPhone) { $lstPhone->AddItem($objPhone->Number, $objPhone->Id, $objFormAnswer && $objFormAnswer->PhoneId == $objPhone->Id); } $lstPhone->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstPhone->Required = true; } $lstPhone->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstPhone; $lstPhone->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtPhone = new PhoneTextBox($this, $strControlId . 'phone'); $this->objFormQuestionControlArray[] = $txtPhone; $txtPhone->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued phone number from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstPhone || !$lstPhone->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objPhoneArray)) { if ($blnExplicitlyTextValueOnly) { $lstPhone->SelectedIndex = count($lstPhone->GetAllItems()) - 1; $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Text = $objFormAnswer->TextValue; } else { $txtPhone->Visible = false; $txtPhone->Required = false; } } else { $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtPhone->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::Email: $objEmailArray = array(); if ($objPerson != null) { // Add Personal Emails foreach ($objPerson->GetEmailArray() as $objEmail) { $objEmailArray[] = $objEmail; } if (count($objEmailArray)) { $lstEmail = new QListBox($this, $strControlId . 'id'); $lstEmail->ActionParameter = $strControlId . 'email'; $lstEmail->Name = $objFormQuestion->Question; $lstEmail->AddItem('- Select One -', null); rsort($objEmailArray); foreach ($objEmailArray as $objEmail) { $lstEmail->AddItem($objEmail->Address, $objEmail->Id, $objFormAnswer && $objFormAnswer->EmailId == $objEmail->Id); } $lstEmail->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstEmail->Required = true; } $lstEmail->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstEmail; $lstEmail->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtEmail = new QEmailTextBox($this, $strControlId . 'email'); $this->strEmailCtrlId = $strControlId . 'email'; $this->objFormQuestionControlArray[] = $txtEmail; $txtEmail->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued email address from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstEmail || !$lstEmail->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objEmailArray)) { if ($blnExplicitlyTextValueOnly) { $lstEmail->SelectedIndex = count($lstEmail->GetAllItems()) - 1; $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Text = $objFormAnswer->TextValue; } else { $txtEmail->Visible = false; $txtEmail->Required = false; } } else { $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtEmail->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::ShortText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::LongText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->TextMode = QTextMode::MultiLine; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::Number: $txtAnswer = new QIntegerTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; $txtAnswer->Width = '50px'; $txtAnswer->MaxLength = 6; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->IntegerValue; } break; case FormQuestionType::YesNo: $chkAnswer = new QCheckBox($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->Text = trim($objFormQuestion->Options); $chkAnswer->Required = $objFormQuestion->RequiredFlag; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; if ($objFormAnswer) { $chkAnswer->Checked = $objFormAnswer->BooleanValue; } break; case FormQuestionType::SingleSelect: $lstAnswer = new QListBox($this, $strControlId); $lstAnswer->Name = $objFormQuestion->Question; $lstAnswer->Required = $objFormQuestion->RequiredFlag; $lstAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstAnswer; $lstAnswer->AddItem('- Select One -', null); foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $lstAnswer->AddItem($strItem, $strItem, $objFormAnswer && $objFormAnswer->TextValue == $strItem); } } if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->ActionParameter = $strControlId . 'other'; $lstAnswer->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstAnswer->AddItem('- Other... -', false); $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->Required = false; $txtAnswer->Visible = false; $this->objFormQuestionControlArray[] = $txtAnswer; } if ($objFormAnswer && strlen($objFormAnswer->TextValue) && !$lstAnswer->SelectedValue) { if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->SelectedIndex = count($lstAnswer->GetAllItems()) - 1; $txtAnswer->Text = $objFormAnswer->TextValue; $txtAnswer->Visible = true; } else { $lstAnswer->AddItem($objFormAnswer->TextValue, $objFormAnswer->TextValue, true); } } break; case FormQuestionType::MultipleSelect: $strAnswerArray = array(); if ($objFormAnswer) { foreach (explode("\n", trim($objFormAnswer->TextValue)) as $strAnswer) { if (strlen($strAnswer = trim($strAnswer))) { $strAnswerArray[$strAnswer] = $strAnswer; } } } // GJS - Change to check boxes instead of multi select $chkAnswer = new QCheckBoxList($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $chkAnswer->AddItem($strItem, $strItem, array_key_exists($strItem, $strAnswerArray)); $strAnswerArray[$strItem] = null; unset($strAnswerArray[$strItem]); } } foreach ($strAnswerArray as $strAnswer) { $chkAnswer->AddItem($strAnswer, $strAnswer, true); } if ($objFormQuestion->AllowOtherFlag) { $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->HtmlBefore = 'Add another option and hit <strong>Enter</strong>:<br/>'; $txtAnswer->Visible = true; $txtAnswer->ActionParameter = $strControlId; $txtAnswer->AddAction(new QEnterKeyEvent(), new QAjaxAction('txtMultipleSelectOther_Enter')); $this->objFormQuestionControlArray[] = $txtAnswer; } break; case FormQuestionType::Instructions: $lblAnswer = new QLabel($this, $strControlId); $lblAnswer->HtmlEntities = false; $lblAnswer->Text = nl2br(QApplication::HtmlEntities(trim($objFormQuestion->Options)), true); if (strlen($strLabel = trim($objFormQuestion->Question))) { $lblAnswer->Name = $strLabel; $lblAnswer->RenderMethod = 'RenderWithName'; } else { $lblAnswer->RenderMethod = 'Render'; } $this->objFormQuestionControlArray[] = $lblAnswer; break; default: throw new Exception('Invalid FormQuestionTypeId: ' . $objFormQuestion->FormQuestionTypeId); } } }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strAssetModelGroup = "Asset Model"; $lstMapHeader->AddItem("- Not Mapped -", null); /*$lstMapHeader->AddItem("Asset Tag", "Asset Code", ($strName == 'asset code') ? true : false, $strAssetGroup, 'CssClass="redtext"'); foreach ($this->arrAssetCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "asset_".$objCustomField->CustomFieldId, ($strName == strtolower($objCustomField->ShortDescription)) ? true : false, $strAssetGroup); } $lstMapHeader->AddItem("Location", "Location", ($strName == 'location') ? true : false, $strAssetGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Created By", "Created By", ($strName == 'created by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Created Date", "Created Date", ($strName == 'created date') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified By", "Modified By", ($strName == 'modified by') ? true : false, $strAssetGroup); $lstMapHeader->AddItem("Modified Date", "Modified Date", ($strName == 'modified date') ? true : false, $strAssetGroup);*/ // Add ID for update imports only if ($this->lstImportAction->SelectedValue == 2) { $lstMapHeader->AddItem("ID", "ID", $strName == 'id' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); } $lstMapHeader->AddItem("Model Number", "Model Number", $strName == 'model number' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Short Description", "Short Description", $strName == 'short description' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Long Description", "Long Description", $strName == 'long description' ? true : false, $strAssetModelGroup); $lstMapHeader->AddItem("Category", "Category", $strName == 'category' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Manufacturer", "Manufacturer", $strName == 'manufacturer' ? true : false, $strAssetModelGroup, 'CssClass="redtext"'); if (QApplication::$TracmorSettings->DepreciationFlag == '1') { $lstMapHeader->AddItem("Depreciation Class", "Depreciation Class", $strName == 'depreciation class' ? true : false, $strAssetModelGroup); } foreach ($this->arrModelCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "model_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strAssetModelGroup); } $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; /*if ($strName && $lstMapHeader->SelectedValue) { //$this->arrTracmorField[$intId] = strtolower($lstMapHeader->SelectedValue); }*/ return true; }
protected function GetCustomControlForAttributeNode(QPanel $pnlValue, $strControlId, $strCurrentValue) { // Get the Attribute object we are trying to query against $objAttribute = Attribute::Load($this->NodeDetail); $ctlValue = new QListBox($pnlValue, $strControlId); foreach ($objAttribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) { $ctlValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $strCurrentValue); } return $ctlValue; }
/** * This function creates a listbox suitable for the filter bar * @param string $strControlId id based on the column that the control is contained * @param string $strControlName The name to give the textbox * @param string[] $arrListValues A name=>value array of items to add to the list * @param string $strSelectedValue The value to start selected * @return QListBox the resulting listbox **/ protected function filterListBox_Create($strControlId, $strControlName, $arrListValues, $strSelectedValue) { $ctlFilterListbox = new QListBox($this, $strControlId); $ctlFilterListbox->Name = $strControlName; $ctlFilterListbox->AddItem('-' . QApplication::Translate('Any') . '-'); $ctlFilterListbox->FontSize = $this->RowStyle->FontSize; $ctlFilterListbox->Width = 'auto'; //Now fill up the advanced list foreach (array_keys($arrListValues) as $strFilterName) { $ctlFilterListbox->AddItem($strFilterName, $strFilterName); } $ctlFilterListbox->SelectedName = $strSelectedValue; return $ctlFilterListbox; }
protected function lstMapHeader_Create($objParentObject, $intId, $strName = null) { if ($this->chkHeaderRow->Checked && !$strName) { $strName = 'abcdefg'; } $strName = strtolower($strName); $lstMapHeader = new QListBox($objParentObject); $lstMapHeader->Name = "lst" . $intId; $strContactGroup = "Contact"; $lstMapHeader->AddItem("- Not Mapped -", null); // Add ID for update imports only if ($this->lstImportAction->SelectedValue == 2) { $lstMapHeader->AddItem("ID", "ID", $strName == 'id' ? true : false, $strContactGroup, 'CssClass="redtext"'); } $lstMapHeader->AddItem("Company", "Company", $strName == 'company' ? true : false, $strContactGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("First Name", "First Name", $strName == 'first name' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Last Name", "Last Name", $strName == 'last name' ? true : false, $strContactGroup, 'CssClass="redtext"'); $lstMapHeader->AddItem("Title", "Title", $strName == 'title' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Email", "Email", $strName == 'email' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Description", "Description", $strName == 'description' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Office Phone", "Office Phone", $strName == 'office phone' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Home Phone", "Home Phone", $strName == 'home phone' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Mobile Phone", "Mobile Phone", $strName == 'mobile phone' ? true : false, $strContactGroup); $lstMapHeader->AddItem("Fax", "Fax", $strName == 'fax' ? true : false, $strContactGroup); $lstMapHeader->AddAction(new QChangeEvent(), new QAjaxAction('lstTramorField_Change')); $this->lstMapHeaderArray[] = $lstMapHeader; foreach ($this->arrItemCustomField as $objCustomField) { $lstMapHeader->AddItem($objCustomField->ShortDescription, "contact_" . $objCustomField->CustomFieldId, $strName == strtolower($objCustomField->ShortDescription) ? true : false, $strContactGroup); } return true; }
protected function lstField_Setup(IssueField $objIssueField) { $lstField = new QListBox($this); $lstField->Name = $objIssueField->Name; $lstField->ActionParameter = $objIssueField->Id; if (!($lstField->Required = $objIssueField->RequiredFlag)) { $lstField->AddItem('- Select One -'); } $objSelectedIssueFieldOption = $this->mctIssue->Issue->GetFieldOptionForIssueField($objIssueField); foreach ($objIssueField->GetOptionArray() as $objIssueFieldOption) { $lstField->AddItem($objIssueFieldOption->Name, $objIssueFieldOption->Id, $objSelectedIssueFieldOption && $objSelectedIssueFieldOption->Id == $objIssueFieldOption->Id); } if ($objIssueField->MutableFlag) { $lstField->AddItem('- Other... -', -1); $txtMutableField = new QTextBox($this, 'txtMutableField' . $objIssueField->Id); $txtMutableField->Visible = false; $txtMutableField->SetCustomStyle('margin-top', '2px'); $this->txtMutableFields[$objIssueField->Id] = $txtMutableField; $lstField->AddAction(new QChangeEvent(), new QAjaxAction('lstField_Change')); } if ($objIssueField->RequiredFlag) { $this->lstRequiredFields[] = $lstField; } else { $this->lstOptionalFields[] = $lstField; } }
public function lstLocationInventoryReceived_Render(InventoryTransaction $objInventoryTransaction) { if (!$objInventoryTransaction->blnReturnReceivedStatus()) { $strControlId = 'lstLocationInventoryReceived' . $objInventoryTransaction->InventoryTransactionId; $lstLocationInventoryReceived = $this->GetControl($strControlId); if (!$lstLocationInventoryReceived) { // Create the drop down list for this row in the datagrid // Use ActionParameter to specify the Id of the AssetTransaction $lstLocationInventoryReceived = new QListBox($this->dtgInventoryTransact, $strControlId); $lstLocationInventoryReceived->Name = 'Location To Receive'; $lstLocationInventoryReceived->ActionParameter = $objInventoryTransaction->InventoryTransactionId; $lstLocationInventoryReceived->AddItem('- Select One -', null); $objLocationArray = Location::LoadAllLocations(false, false, 'short_description', null, null, false, false, false, true); if ($objLocationArray) { foreach ($objLocationArray as $objLocation) { $lstLocationInventoryReceived->AddItem($objLocation->__toString(), $objLocation->LocationId); } } $lstLocationInventoryReceived->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnReceiveInventoryTransaction')); $lstLocationInventoryReceived->AddAction(new QEnterKeyEvent(), new QTerminateAction()); } QApplication::AuthorizeControl($this->objReceipt, $lstLocationInventoryReceived, 2); return $lstLocationInventoryReceived->Render(false); } }
public function pnlValue_Refresh($intIndex) { $lstNode = $this->objForm->GetControl('lstNode' . $intIndex); $lstOperation = $this->objForm->GetControl('lstOperation' . $intIndex); $pnlValue = $this->objForm->GetControl('pnlValue' . $intIndex); $strControlId = 'ctlValue' . $intIndex; $objQueryCondition = $this->objQueryConditionArray[$intIndex]; if (!$lstNode->SelectedValue) { $pnlValue->RemoveChildControls(true); $pnlValue->ActionParameter = null; return; } if ($pnlValue->ActionParameter != $lstNode->SelectedValue) { $pnlValue->RemoveChildControls(true); $pnlValue->ActionParameter = $lstNode->SelectedValue; $objQueryNode = $this->objNodeArray[$lstNode->SelectedValue]; switch ($objQueryNode->QueryDataTypeId) { case QueryDataType::StringValue: $ctlValue = new QTextBox($pnlValue, $strControlId); if ($objQueryCondition->QueryNodeId == $objQueryNode->Id) { $ctlValue->Text = $objQueryCondition->Value; } break; case QueryDataType::DateValue: $ctlValue = new QDateTimePicker($pnlValue, $strControlId); if ($objQueryCondition->QueryNodeId == $objQueryNode->Id) { $ctlValue->DateTime = new QDateTime($objQueryCondition->Value); } break; case QueryDataType::IntegerValue: $ctlValue = new QIntegerTextBox($pnlValue, $strControlId); if ($objQueryCondition->QueryNodeId == $objQueryNode->Id) { $ctlValue->Text = $objQueryCondition->Value; } break; case QueryDataType::BooleanValue: $ctlValue = new QListBox($pnlValue, $strControlId); $ctlValue->AddItem('True', true, $objQueryCondition->QueryNodeId == $objQueryNode->Id && $objQueryCondition->Value); $ctlValue->AddItem('False', false, $objQueryCondition->QueryNodeId == $objQueryNode->Id && !$objQueryCondition->Value); break; case QueryDataType::TypeValue: $ctlValue = new QListBox($pnlValue, $strControlId); $strTypeName = $objQueryNode->NodeDetail; $ctlValue->AddItem('- Select One -'); foreach ($strTypeName::$NameArray as $intKey => $strValue) { $ctlValue->AddItem($strValue, $intKey, $objQueryCondition->QueryNodeId == $objQueryNode->Id && $intKey == $objQueryCondition->Value); } break; case QueryDataType::ObjectValue: $ctlValue = new QListBox($pnlValue, $strControlId); $strTokens = explode(' ', $objQueryNode->NodeDetail); $strClassName = $strTokens[0]; $strMethodName = $strTokens[1]; $strParameter = $strTokens[2]; switch ($strParameter) { case '%L%': $strParameter = QApplication::$Login; break; } $strProperty = $strTokens[3]; if (array_key_exists(4, $strTokens)) { $strIdProperty = $strTokens[4]; } else { $strIdProperty = 'Id'; } if (strlen($strParameter)) { $objArray = $strClassName::$strMethodName($strParameter, QQ::OrderBy(QQN::$strClassName()->__get($strProperty))); } else { $objArray = $strClassName::$strMethodName(QQ::OrderBy(QQN::$strClassName()->__get($strProperty))); } $ctlValue->AddItem('- Select One -'); foreach ($objArray as $objItem) { $ctlValue->AddItem($objItem->{$strProperty}, $objItem->{$strIdProperty}, $objQueryCondition->QueryNodeId == $objQueryNode->Id && $objItem->{$strIdProperty} == $objQueryCondition->Value); } break; case QueryDataType::CustomValue: $strCurrentValue = $objQueryCondition->QueryNodeId == $objQueryNode->Id ? $objQueryCondition->Value : null; $ctlValue = $objQueryNode->GetCustomControl($pnlValue, $strControlId, $strCurrentValue); break; case QueryDataType::CustomValueOnly: $strCurrentValue = $objQueryCondition->QueryNodeId == $objQueryNode->Id ? $objQueryCondition->Value : null; $ctlValue = $objQueryNode->GetCustomControl($pnlValue, $strControlId, $strCurrentValue); break; default: throw new Exception('Invalid QueryDataType: ' . $objQueryNode->QueryDataTypeId); } } else { $ctlValue = $this->objForm->GetControl($strControlId); } if (!$lstOperation->SelectedValue) { $ctlValue->Visible = false; $ctlValue->Required = false; } else { $objQueryOperation = $this->objOperationArray[$lstOperation->SelectedValue]; $ctlValue->Visible = $objQueryOperation->ArgumentFlag; $ctlValue->Required = $objQueryOperation->ArgumentFlag; } }