/** * Refresh this MetaControl with Data from the local Contact object. * @param boolean $blnReload reload Contact from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objContact->Reload(); } if ($this->lblContactId) { if ($this->blnEditMode) { $this->lblContactId->Text = $this->objContact->ContactId; } } if ($this->lstCompany) { $this->lstCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objCompanyArray = Company::LoadAll(); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($this->objContact->Company && $this->objContact->Company->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } } if ($this->lblCompanyId) { $this->lblCompanyId->Text = $this->objContact->Company ? $this->objContact->Company->__toString() : null; } if ($this->lstAddress) { $this->lstAddress->RemoveAllItems(); $this->lstAddress->AddItem(QApplication::Translate('- Select One -'), null); $objAddressArray = Address::LoadAll(); if ($objAddressArray) { foreach ($objAddressArray as $objAddress) { $objListItem = new QListItem($objAddress->__toString(), $objAddress->AddressId); if ($this->objContact->Address && $this->objContact->Address->AddressId == $objAddress->AddressId) { $objListItem->Selected = true; } $this->lstAddress->AddItem($objListItem); } } } if ($this->lblAddressId) { $this->lblAddressId->Text = $this->objContact->Address ? $this->objContact->Address->__toString() : null; } if ($this->txtFirstName) { $this->txtFirstName->Text = $this->objContact->FirstName; } if ($this->lblFirstName) { $this->lblFirstName->Text = $this->objContact->FirstName; } if ($this->txtLastName) { $this->txtLastName->Text = $this->objContact->LastName; } if ($this->lblLastName) { $this->lblLastName->Text = $this->objContact->LastName; } if ($this->txtTitle) { $this->txtTitle->Text = $this->objContact->Title; } if ($this->lblTitle) { $this->lblTitle->Text = $this->objContact->Title; } if ($this->txtEmail) { $this->txtEmail->Text = $this->objContact->Email; } if ($this->lblEmail) { $this->lblEmail->Text = $this->objContact->Email; } if ($this->txtPhoneOffice) { $this->txtPhoneOffice->Text = $this->objContact->PhoneOffice; } if ($this->lblPhoneOffice) { $this->lblPhoneOffice->Text = $this->objContact->PhoneOffice; } if ($this->txtPhoneHome) { $this->txtPhoneHome->Text = $this->objContact->PhoneHome; } if ($this->lblPhoneHome) { $this->lblPhoneHome->Text = $this->objContact->PhoneHome; } if ($this->txtPhoneMobile) { $this->txtPhoneMobile->Text = $this->objContact->PhoneMobile; } if ($this->lblPhoneMobile) { $this->lblPhoneMobile->Text = $this->objContact->PhoneMobile; } if ($this->txtFax) { $this->txtFax->Text = $this->objContact->Fax; } if ($this->lblFax) { $this->lblFax->Text = $this->objContact->Fax; } if ($this->txtDescription) { $this->txtDescription->Text = $this->objContact->Description; } if ($this->lblDescription) { $this->lblDescription->Text = $this->objContact->Description; } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objContact->CreatedByObject && $this->objContact->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objContact->CreatedByObject ? $this->objContact->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objContact->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objContact->CreationDate) ? $this->objContact->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objContact->ModifiedByObject && $this->objContact->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objContact->ModifiedByObject ? $this->objContact->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objContact->ModifiedDate; } } if ($this->lstContactCustomFieldHelper) { $this->lstContactCustomFieldHelper->RemoveAllItems(); $this->lstContactCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objContactCustomFieldHelperArray = ContactCustomFieldHelper::LoadAll(); if ($objContactCustomFieldHelperArray) { foreach ($objContactCustomFieldHelperArray as $objContactCustomFieldHelper) { $objListItem = new QListItem($objContactCustomFieldHelper->__toString(), $objContactCustomFieldHelper->ContactId); if ($objContactCustomFieldHelper->ContactId == $this->objContact->ContactId) { $objListItem->Selected = true; } $this->lstContactCustomFieldHelper->AddItem($objListItem); } } // Because ContactCustomFieldHelper's ContactCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstContactCustomFieldHelper->SelectedValue) { $this->lstContactCustomFieldHelper->Enabled = false; } else { $this->lstContactCustomFieldHelper->Enabled = true; } } if ($this->lblContactCustomFieldHelper) { $this->lblContactCustomFieldHelper->Text = $this->objContact->ContactCustomFieldHelper ? $this->objContact->ContactCustomFieldHelper->__toString() : null; } }
protected function lstContactCustomFieldHelper_Create() { $this->lstContactCustomFieldHelper = new QListBox($this); $this->lstContactCustomFieldHelper->Name = QApplication::Translate('Contact Custom Field Helper'); $this->lstContactCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objContactCustomFieldHelperArray = ContactCustomFieldHelper::LoadAll(); if ($objContactCustomFieldHelperArray) { foreach ($objContactCustomFieldHelperArray as $objContactCustomFieldHelper) { $objListItem = new QListItem($objContactCustomFieldHelper->__toString(), $objContactCustomFieldHelper->ContactId); if ($objContactCustomFieldHelper->ContactId == $this->objContact->ContactId) { $objListItem->Selected = true; } $this->lstContactCustomFieldHelper->AddItem($objListItem); } } // Because ContactCustomFieldHelper's ContactCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstContactCustomFieldHelper->SelectedValue) { $this->lstContactCustomFieldHelper->Enabled = false; } }