Exemplo n.º 1
0
 protected function lstAssetCustomFieldHelper_Create()
 {
     $this->lstAssetCustomFieldHelper = new QListBox($this);
     $this->lstAssetCustomFieldHelper->Name = QApplication::Translate('Asset Custom Field Helper');
     $this->lstAssetCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
     $objAssetCustomFieldHelperArray = AssetCustomFieldHelper::LoadAll();
     if ($objAssetCustomFieldHelperArray) {
         foreach ($objAssetCustomFieldHelperArray as $objAssetCustomFieldHelper) {
             $objListItem = new QListItem($objAssetCustomFieldHelper->__toString(), $objAssetCustomFieldHelper->AssetId);
             if ($objAssetCustomFieldHelper->AssetId == $this->objAsset->AssetId) {
                 $objListItem->Selected = true;
             }
             $this->lstAssetCustomFieldHelper->AddItem($objListItem);
         }
     }
     // Because AssetCustomFieldHelper's AssetCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
     if ($this->lstAssetCustomFieldHelper->SelectedValue) {
         $this->lstAssetCustomFieldHelper->Enabled = false;
     }
 }
 /**
  * Refresh this MetaControl with Data from the local Asset object.
  * @param boolean $blnReload reload Asset from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objAsset->Reload();
     }
     if ($this->lblAssetId) {
         if ($this->blnEditMode) {
             $this->lblAssetId->Text = $this->objAsset->AssetId;
         }
     }
     if ($this->lstParentAsset) {
         $this->lstParentAsset->RemoveAllItems();
         $this->lstParentAsset->AddItem(QApplication::Translate('- Select One -'), null);
         $objParentAssetArray = Asset::LoadAll();
         if ($objParentAssetArray) {
             foreach ($objParentAssetArray as $objParentAsset) {
                 $objListItem = new QListItem($objParentAsset->__toString(), $objParentAsset->AssetId);
                 if ($this->objAsset->ParentAsset && $this->objAsset->ParentAsset->AssetId == $objParentAsset->AssetId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstParentAsset->AddItem($objListItem);
             }
         }
     }
     if ($this->lblParentAssetId) {
         $this->lblParentAssetId->Text = $this->objAsset->ParentAsset ? $this->objAsset->ParentAsset->__toString() : null;
     }
     if ($this->lstAssetModel) {
         $this->lstAssetModel->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstAssetModel->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objAssetModelArray = AssetModel::LoadAll();
         if ($objAssetModelArray) {
             foreach ($objAssetModelArray as $objAssetModel) {
                 $objListItem = new QListItem($objAssetModel->__toString(), $objAssetModel->AssetModelId);
                 if ($this->objAsset->AssetModel && $this->objAsset->AssetModel->AssetModelId == $objAssetModel->AssetModelId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAssetModel->AddItem($objListItem);
             }
         }
     }
     if ($this->lblAssetModelId) {
         $this->lblAssetModelId->Text = $this->objAsset->AssetModel ? $this->objAsset->AssetModel->__toString() : null;
     }
     if ($this->lstLocation) {
         $this->lstLocation->RemoveAllItems();
         $this->lstLocation->AddItem(QApplication::Translate('- Select One -'), null);
         $objLocationArray = Location::LoadAll();
         if ($objLocationArray) {
             foreach ($objLocationArray as $objLocation) {
                 $objListItem = new QListItem($objLocation->__toString(), $objLocation->LocationId);
                 if ($this->objAsset->Location && $this->objAsset->Location->LocationId == $objLocation->LocationId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLocation->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLocationId) {
         $this->lblLocationId->Text = $this->objAsset->Location ? $this->objAsset->Location->__toString() : null;
     }
     if ($this->txtAssetCode) {
         $this->txtAssetCode->Text = $this->objAsset->AssetCode;
     }
     if ($this->lblAssetCode) {
         $this->lblAssetCode->Text = $this->objAsset->AssetCode;
     }
     if ($this->txtImagePath) {
         $this->txtImagePath->Text = $this->objAsset->ImagePath;
     }
     if ($this->lblImagePath) {
         $this->lblImagePath->Text = $this->objAsset->ImagePath;
     }
     if ($this->chkCheckedOutFlag) {
         $this->chkCheckedOutFlag->Checked = $this->objAsset->CheckedOutFlag;
     }
     if ($this->lblCheckedOutFlag) {
         $this->lblCheckedOutFlag->Text = $this->objAsset->CheckedOutFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkReservedFlag) {
         $this->chkReservedFlag->Checked = $this->objAsset->ReservedFlag;
     }
     if ($this->lblReservedFlag) {
         $this->lblReservedFlag->Text = $this->objAsset->ReservedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkLinkedFlag) {
         $this->chkLinkedFlag->Checked = $this->objAsset->LinkedFlag;
     }
     if ($this->lblLinkedFlag) {
         $this->lblLinkedFlag->Text = $this->objAsset->LinkedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkArchivedFlag) {
         $this->chkArchivedFlag->Checked = $this->objAsset->ArchivedFlag;
     }
     if ($this->lblArchivedFlag) {
         $this->lblArchivedFlag->Text = $this->objAsset->ArchivedFlag ? 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->objAsset->CreatedByObject && $this->objAsset->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCreatedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCreatedBy) {
         $this->lblCreatedBy->Text = $this->objAsset->CreatedByObject ? $this->objAsset->CreatedByObject->__toString() : null;
     }
     if ($this->calCreationDate) {
         $this->calCreationDate->DateTime = $this->objAsset->CreationDate;
     }
     if ($this->lblCreationDate) {
         $this->lblCreationDate->Text = sprintf($this->objAsset->CreationDate) ? $this->objAsset->__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->objAsset->ModifiedByObject && $this->objAsset->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstModifiedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblModifiedBy) {
         $this->lblModifiedBy->Text = $this->objAsset->ModifiedByObject ? $this->objAsset->ModifiedByObject->__toString() : null;
     }
     if ($this->lblModifiedDate) {
         if ($this->blnEditMode) {
             $this->lblModifiedDate->Text = $this->objAsset->ModifiedDate;
         }
     }
     if ($this->chkDepreciationFlag) {
         $this->chkDepreciationFlag->Checked = $this->objAsset->DepreciationFlag;
     }
     if ($this->lblDepreciationFlag) {
         $this->lblDepreciationFlag->Text = $this->objAsset->DepreciationFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->calPurchaseDate) {
         $this->calPurchaseDate->DateTime = $this->objAsset->PurchaseDate;
     }
     if ($this->lblPurchaseDate) {
         $this->lblPurchaseDate->Text = sprintf($this->objAsset->PurchaseDate) ? $this->objAsset->__toString($this->strPurchaseDateDateTimeFormat) : null;
     }
     if ($this->txtPurchaseCost) {
         $this->txtPurchaseCost->Text = $this->objAsset->PurchaseCost;
     }
     if ($this->lblPurchaseCost) {
         $this->lblPurchaseCost->Text = $this->objAsset->PurchaseCost;
     }
     if ($this->lstAssetCustomFieldHelper) {
         $this->lstAssetCustomFieldHelper->RemoveAllItems();
         $this->lstAssetCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
         $objAssetCustomFieldHelperArray = AssetCustomFieldHelper::LoadAll();
         if ($objAssetCustomFieldHelperArray) {
             foreach ($objAssetCustomFieldHelperArray as $objAssetCustomFieldHelper) {
                 $objListItem = new QListItem($objAssetCustomFieldHelper->__toString(), $objAssetCustomFieldHelper->AssetId);
                 if ($objAssetCustomFieldHelper->AssetId == $this->objAsset->AssetId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAssetCustomFieldHelper->AddItem($objListItem);
             }
         }
         // Because AssetCustomFieldHelper's AssetCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
         if ($this->lstAssetCustomFieldHelper->SelectedValue) {
             $this->lstAssetCustomFieldHelper->Enabled = false;
         } else {
             $this->lstAssetCustomFieldHelper->Enabled = true;
         }
     }
     if ($this->lblAssetCustomFieldHelper) {
         $this->lblAssetCustomFieldHelper->Text = $this->objAsset->AssetCustomFieldHelper ? $this->objAsset->AssetCustomFieldHelper->__toString() : null;
     }
 }