/** * Refresh this MetaControl with Data from the local Receipt object. * @param boolean $blnReload reload Receipt from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objReceipt->Reload(); } if ($this->lblReceiptId) { if ($this->blnEditMode) { $this->lblReceiptId->Text = $this->objReceipt->ReceiptId; } } if ($this->lstTransaction) { $this->lstTransaction->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstTransaction->AddItem(QApplication::Translate('- Select One -'), null); } $objTransactionArray = Transaction::LoadAll(); if ($objTransactionArray) { foreach ($objTransactionArray as $objTransaction) { $objListItem = new QListItem($objTransaction->__toString(), $objTransaction->TransactionId); if ($this->objReceipt->Transaction && $this->objReceipt->Transaction->TransactionId == $objTransaction->TransactionId) { $objListItem->Selected = true; } $this->lstTransaction->AddItem($objListItem); } } } if ($this->lblTransactionId) { $this->lblTransactionId->Text = $this->objReceipt->Transaction ? $this->objReceipt->Transaction->__toString() : null; } if ($this->lstFromCompany) { $this->lstFromCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objFromCompanyArray = Company::LoadAll(); if ($objFromCompanyArray) { foreach ($objFromCompanyArray as $objFromCompany) { $objListItem = new QListItem($objFromCompany->__toString(), $objFromCompany->CompanyId); if ($this->objReceipt->FromCompany && $this->objReceipt->FromCompany->CompanyId == $objFromCompany->CompanyId) { $objListItem->Selected = true; } $this->lstFromCompany->AddItem($objListItem); } } } if ($this->lblFromCompanyId) { $this->lblFromCompanyId->Text = $this->objReceipt->FromCompany ? $this->objReceipt->FromCompany->__toString() : null; } if ($this->lstFromContact) { $this->lstFromContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromContact->AddItem(QApplication::Translate('- Select One -'), null); } $objFromContactArray = Contact::LoadAll(); if ($objFromContactArray) { foreach ($objFromContactArray as $objFromContact) { $objListItem = new QListItem($objFromContact->__toString(), $objFromContact->ContactId); if ($this->objReceipt->FromContact && $this->objReceipt->FromContact->ContactId == $objFromContact->ContactId) { $objListItem->Selected = true; } $this->lstFromContact->AddItem($objListItem); } } } if ($this->lblFromContactId) { $this->lblFromContactId->Text = $this->objReceipt->FromContact ? $this->objReceipt->FromContact->__toString() : null; } if ($this->lstToContact) { $this->lstToContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToContact->AddItem(QApplication::Translate('- Select One -'), null); } $objToContactArray = Contact::LoadAll(); if ($objToContactArray) { foreach ($objToContactArray as $objToContact) { $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId); if ($this->objReceipt->ToContact && $this->objReceipt->ToContact->ContactId == $objToContact->ContactId) { $objListItem->Selected = true; } $this->lstToContact->AddItem($objListItem); } } } if ($this->lblToContactId) { $this->lblToContactId->Text = $this->objReceipt->ToContact ? $this->objReceipt->ToContact->__toString() : null; } if ($this->lstToAddress) { $this->lstToAddress->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToAddress->AddItem(QApplication::Translate('- Select One -'), null); } $objToAddressArray = Address::LoadAll(); if ($objToAddressArray) { foreach ($objToAddressArray as $objToAddress) { $objListItem = new QListItem($objToAddress->__toString(), $objToAddress->AddressId); if ($this->objReceipt->ToAddress && $this->objReceipt->ToAddress->AddressId == $objToAddress->AddressId) { $objListItem->Selected = true; } $this->lstToAddress->AddItem($objListItem); } } } if ($this->lblToAddressId) { $this->lblToAddressId->Text = $this->objReceipt->ToAddress ? $this->objReceipt->ToAddress->__toString() : null; } if ($this->txtReceiptNumber) { $this->txtReceiptNumber->Text = $this->objReceipt->ReceiptNumber; } if ($this->lblReceiptNumber) { $this->lblReceiptNumber->Text = $this->objReceipt->ReceiptNumber; } if ($this->calDueDate) { $this->calDueDate->DateTime = $this->objReceipt->DueDate; } if ($this->lblDueDate) { $this->lblDueDate->Text = sprintf($this->objReceipt->DueDate) ? $this->objReceipt->__toString($this->strDueDateDateTimeFormat) : null; } if ($this->calReceiptDate) { $this->calReceiptDate->DateTime = $this->objReceipt->ReceiptDate; } if ($this->lblReceiptDate) { $this->lblReceiptDate->Text = sprintf($this->objReceipt->ReceiptDate) ? $this->objReceipt->__toString($this->strReceiptDateDateTimeFormat) : null; } if ($this->chkReceivedFlag) { $this->chkReceivedFlag->Checked = $this->objReceipt->ReceivedFlag; } if ($this->lblReceivedFlag) { $this->lblReceivedFlag->Text = $this->objReceipt->ReceivedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } 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->objReceipt->CreatedByObject && $this->objReceipt->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objReceipt->CreatedByObject ? $this->objReceipt->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objReceipt->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objReceipt->CreationDate) ? $this->objReceipt->__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->objReceipt->ModifiedByObject && $this->objReceipt->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objReceipt->ModifiedByObject ? $this->objReceipt->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objReceipt->ModifiedDate; } } if ($this->lstReceiptCustomFieldHelper) { $this->lstReceiptCustomFieldHelper->RemoveAllItems(); $this->lstReceiptCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objReceiptCustomFieldHelperArray = ReceiptCustomFieldHelper::LoadAll(); if ($objReceiptCustomFieldHelperArray) { foreach ($objReceiptCustomFieldHelperArray as $objReceiptCustomFieldHelper) { $objListItem = new QListItem($objReceiptCustomFieldHelper->__toString(), $objReceiptCustomFieldHelper->ReceiptId); if ($objReceiptCustomFieldHelper->ReceiptId == $this->objReceipt->ReceiptId) { $objListItem->Selected = true; } $this->lstReceiptCustomFieldHelper->AddItem($objListItem); } } // Because ReceiptCustomFieldHelper's ReceiptCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstReceiptCustomFieldHelper->SelectedValue) { $this->lstReceiptCustomFieldHelper->Enabled = false; } else { $this->lstReceiptCustomFieldHelper->Enabled = true; } } if ($this->lblReceiptCustomFieldHelper) { $this->lblReceiptCustomFieldHelper->Text = $this->objReceipt->ReceiptCustomFieldHelper ? $this->objReceipt->ReceiptCustomFieldHelper->__toString() : null; } }
protected function lstReceiptCustomFieldHelper_Create() { $this->lstReceiptCustomFieldHelper = new QListBox($this); $this->lstReceiptCustomFieldHelper->Name = QApplication::Translate('Receipt Custom Field Helper'); $this->lstReceiptCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objReceiptCustomFieldHelperArray = ReceiptCustomFieldHelper::LoadAll(); if ($objReceiptCustomFieldHelperArray) { foreach ($objReceiptCustomFieldHelperArray as $objReceiptCustomFieldHelper) { $objListItem = new QListItem($objReceiptCustomFieldHelper->__toString(), $objReceiptCustomFieldHelper->ReceiptId); if ($objReceiptCustomFieldHelper->ReceiptId == $this->objReceipt->ReceiptId) { $objListItem->Selected = true; } $this->lstReceiptCustomFieldHelper->AddItem($objListItem); } } // Because ReceiptCustomFieldHelper's ReceiptCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstReceiptCustomFieldHelper->SelectedValue) { $this->lstReceiptCustomFieldHelper->Enabled = false; } }