本文整理汇总了PHP中AssetModel::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetModel::Load方法的具体用法?PHP AssetModel::Load怎么用?PHP AssetModel::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetModel
的用法示例。
在下文中一共展示了AssetModel::Load方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetupAssetModel
protected function SetupAssetModel()
{
// Lookup Object PK information from Query String (if applicable)
// Set mode to Edit or New depending on what's found
$intAssetModelId = QApplication::QueryString('intAssetModelId');
if ($intAssetModelId) {
$this->objAssetModel = AssetModel::Load($intAssetModelId);
if (!$this->objAssetModel) {
throw new Exception('Could not find a AssetModel object with PK arguments: ' . $intAssetModelId);
}
$this->strTitleVerb = QApplication::Translate('Edit');
$this->blnEditMode = true;
} else {
$this->objAssetModel = new AssetModel();
$this->strTitleVerb = QApplication::Translate('Create');
$this->blnEditMode = false;
}
}
示例2: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'AssetCustomFieldAssetModelId':
// Gets the value for intAssetCustomFieldAssetModelId (Read-Only PK)
// @return integer
return $this->intAssetCustomFieldAssetModelId;
case 'AssetModelId':
// Gets the value for intAssetModelId (Not Null)
// @return integer
return $this->intAssetModelId;
case 'CustomFieldId':
// Gets the value for intCustomFieldId (Not Null)
// @return integer
return $this->intCustomFieldId;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'AssetModel':
// Gets the value for the AssetModel object referenced by intAssetModelId (Not Null)
// @return AssetModel
try {
if (!$this->objAssetModel && !is_null($this->intAssetModelId)) {
$this->objAssetModel = AssetModel::Load($this->intAssetModelId);
}
return $this->objAssetModel;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'CustomField':
// Gets the value for the CustomField object referenced by intCustomFieldId (Not Null)
// @return CustomField
try {
if (!$this->objCustomField && !is_null($this->intCustomFieldId)) {
$this->objCustomField = CustomField::Load($this->intCustomFieldId);
}
return $this->objCustomField;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
case '__Restored':
return $this->__blnRestored;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例3: btnSave_Click
public function btnSave_Click($strFormId, $strControlId, $strParameter)
{
$this->EnableSelectedControls();
$this->ClearWarnings();
$blnError = false;
// Make sure at least one checkbox is checked
if (!$this->chkCategory->Checked && !$this->chkManufacturer->Checked && !$this->chkLongDescription->Checked) {
$blnChecked = false;
foreach ($this->arrCheckboxes as $objCheckBox) {
if ($objCheckBox->Checked) {
$blnChecked = true;
break;
}
}
if (!$blnChecked) {
$blnError = true;
$this->btnCancel->Warning = 'You must select at least one field to edit.';
return;
}
}
// 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();
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);
}
}
}
}
$set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId));
// Force modified_date timestamp update
$set[] = '`modified_date` = NOW()';
if ($this->chkLongDescription->Checked) {
$set[] = sprintf('`long_description`="%s"', $this->txtLongDescription->Text);
}
if ($this->chkManufacturer->Checked) {
if ($this->lstManufacturer->SelectedValue !== null) {
$set[] = sprintf('`manufacturer_id`=%s', $this->lstManufacturer->SelectedValue);
} else {
$blnError = true;
$this->lstManufacturer->Warning = 'Manufacturer is required.';
}
}
if ($this->chkCategory->Checked) {
if ($this->lstCategory->SelectedValue !== null) {
$set[] = sprintf('`category_id`= %s', $this->lstCategory->SelectedValue);
} else {
$blnError = true;
$this->lstCategory->Warning = 'Category is required.';
}
}
// First check that the user is authorized to edit these models
foreach ($this->arrModelsToEdit as $intModelId) {
$objAssetModel = AssetModel::Load($intModelId);
if (!QApplication::AuthorizeEntityBoolean($objAssetModel, 2)) {
$blnError = true;
$this->btnCancel->Warning = 'You are not authorized to edit one or more of the selected models.';
break;
}
}
if (!$blnError) {
try {
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->arrModelsToEdit as $intModelId) {
$objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::AssetModel, false);
$selectedCustomFieldsArray = array();
foreach ($objCustomFieldsArray as $objCustomField) {
if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) {
$selectedCustomFieldsArray[] = $objCustomField;
}
}
CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intModelId, EntityQtype::AssetModel);
}
}
$strQuery = sprintf("UPDATE `asset_model`\n\t\t\t\t\t\t\t\t\t SET " . implode(",", $set) . "\n\t\t\t\t\t\t\t\t\t WHERE `asset_model_id` IN (%s)", implode(",", $this->arrModelsToEdit));
// print $strQuery; exit;
$objDatabase->NonQuery($strQuery);
$objDatabase->TransactionCommit();
QApplication::Redirect('');
} catch (QMySqliDatabaseException $objExc) {
$objDatabase->TransactionRollback();
throw new QDatabaseException();
}
} else {
$objDatabase->TransactionRollback();
$this->arrCustomFieldsToEdit = array();
}
}
示例4: lstAssetModel_Select
public function lstAssetModel_Select($strFormId, $strControlId, $strParameter)
{
if ($this->lstAssetModel->SelectedValue != null) {
$objAssetModel = AssetModel::Load($this->lstAssetModel->SelectedValue);
if ($objAssetModel) {
if ($objAssetModel->AssetModelCode) {
$this->lblAssetModelCode->Text = $objAssetModel->AssetModelCode;
} else {
$this->lblAssetModelCode->Text = 'None';
}
if ($objAssetModel->Manufacturer) {
$this->lblManufacturer->Text = $objAssetModel->Manufacturer->ShortDescription;
} else {
$this->lblManufactuerer->Text = 'None';
}
if ($objAssetModel->Category) {
$this->lblCategory->Text = $objAssetModel->Category->ShortDescription;
}
}
}
}
示例5: btnMassDeleteConfirm_Click
protected function btnMassDeleteConfirm_Click()
{
$this->dlgMassDelete->HideDialogBox();
$items = $this->dtgAssetModel->getSelected('AssetModelId');
$this->lblWarning->Text = "";
$arrToSkip = array();
foreach ($items as $item) {
// First check that the user is authorized to edit this model
$objAssetModel = AssetModel::Load($item);
if (!QApplication::AuthorizeEntityBoolean($objAssetModel, 3)) {
$this->lblWarning->Text = 'You are not authorized to delete one or more of the selected models.';
$this->dlgMassDelete->HideDialogBox();
return;
}
}
// Separating items able to be deleted
foreach ($items as $item) {
$arrAssetAssigned = Asset::LoadArrayByAssetModelId($item);
if (!$arrAssetAssigned || count($arrAssetAssigned) <= 0) {
$this->arrToDelete[] = $item;
} else {
$arrToSkip[] = $item;
}
}
if (count($arrToSkip) > 0) {
if (count($arrToSkip) == 1) {
$toBe = 'is';
$ending = '';
$skipping = 'this';
} else {
$toBe = 'are';
$ending = 's';
$skipping = 'these';
}
if (count($arrToSkip) == count($items)) {
$this->lblWarning->Text = 'Models with assigned assets cannot be deleted.';
$this->dlgMassDelete->HideDialogBox();
return;
}
$intToDelete = count($items) - count($arrToSkip);
$this->dlgMassDelete->Text = sprintf('<div class="title"> Model Mass Delete - %s records</div><hr/>', $intToDelete);
$this->dlgMassDelete->Text .= sprintf("%s of the selected Models %s assigned to an asset and cannot be deleted.\n\t\t\t\t\t\t\t\t Would you like to continue the deletion process,\n\t\t\t\t\t\t\t\t skipping %s Model%s?<br /><br />", count($arrToSkip), $toBe, count($arrToSkip) > 1 ? $skipping . ' ' . count($arrToSkip) : $skipping, $ending);
$this->btnMassDeleteConfirm->Display = false;
$this->btnMassDeleteConfirmSkip->Display = true;
$this->dlgMassDelete->ShowDialogBox();
} else {
if (count($this->arrToDelete) > 0) {
AssetModel::DeleteSelected($this->arrToDelete);
$this->arrToDelete = array();
QApplication::Redirect('');
}
}
}
示例6: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'AssetId':
/**
* Gets the value for intAssetId (Read-Only PK)
* @return integer
*/
return $this->intAssetId;
case 'AssetModelId':
/**
* Gets the value for intAssetModelId (Not Null)
* @return integer
*/
return $this->intAssetModelId;
case 'LocationId':
/**
* Gets the value for intLocationId
* @return integer
*/
return $this->intLocationId;
case 'AssetCode':
/**
* Gets the value for strAssetCode (Unique)
* @return string
*/
return $this->strAssetCode;
case 'ImagePath':
/**
* Gets the value for strImagePath
* @return string
*/
return $this->strImagePath;
case 'CheckedOutFlag':
/**
* Gets the value for blnCheckedOutFlag
* @return boolean
*/
return $this->blnCheckedOutFlag;
case 'ReservedFlag':
/**
* Gets the value for blnReservedFlag
* @return boolean
*/
return $this->blnReservedFlag;
case 'CreatedBy':
/**
* Gets the value for intCreatedBy
* @return integer
*/
return $this->intCreatedBy;
case 'CreationDate':
/**
* Gets the value for dttCreationDate
* @return QDateTime
*/
return $this->dttCreationDate;
case 'ModifiedBy':
/**
* Gets the value for intModifiedBy
* @return integer
*/
return $this->intModifiedBy;
case 'ModifiedDate':
/**
* Gets the value for strModifiedDate (Read-Only Timestamp)
* @return string
*/
return $this->strModifiedDate;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'AssetModel':
/**
* Gets the value for the AssetModel object referenced by intAssetModelId (Not Null)
* @return AssetModel
*/
try {
if (!$this->objAssetModel && !is_null($this->intAssetModelId)) {
$this->objAssetModel = AssetModel::Load($this->intAssetModelId);
}
return $this->objAssetModel;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'Location':
//.........这里部分代码省略.........
示例7: btnNext_Click
//.........这里部分代码省略.........
$this->lstMapDefaultValueArray[] = $lstDefaultValue;
$dtpDate = new QDateTimePicker($this);
$dtpDate->DateTimePickerType = QDateTimePickerType::Date;
$dtpDate->DateTimePickerFormat = QDateTimePickerFormat::MonthDayYear;
$dtpDate->Display = false;
$this->dtpDateArray[] = $dtpDate;
if (array_key_exists($i, $this->lstMapHeaderArray)) {
$this->lstTramorField_Change(null, $this->lstMapHeaderArray[$i]->ControlId, null);
}
}
$this->arrMapFields[$i]['row1'] = $strFirstRowArray[$i];
}
$this->btnNext->Text = "Import Now";
fclose($file_skipped);
// Create Add Field button
$btnAddField = new QButton($this);
$btnAddField->Text = "Add Field";
$btnAddField->AddAction(new QClickEvent(), new QServerAction('btnAddField_Click'));
$btnAddField->AddAction(new QEnterKeyEvent(), new QServerAction('btnAddField_Click'));
$btnAddField->AddAction(new QEnterKeyEvent(), new QTerminateAction());
$this->lstMapHeaderArray[] = $btnAddField;
}
}
}
} elseif ($this->intStep == 2) {
// Step 2 complete
$blnRequiredAllAssetCustomFields = true;
$blnError = false;
$blnAssetCode = false;
$blnAssetModelShortDescription = false;
$blnLocation = false;
$blnAssetId = false;
// $array Required Custom Fields for All Asset Models
$arrAssetCustomFieldOptions = EntityQtypeCustomField::LoadArrayByEntityQtypeId(QApplication::Translate(EntityQtype::Asset));
// generate error flag and field names which are required for export;
$arrRequiredAllAssetCustomFields = array();
foreach ($arrAssetCustomFieldOptions as $arrAssetCustomFieldOption) {
if ($arrAssetCustomFieldOption->CustomField->RequiredFlag && $arrAssetCustomFieldOption->CustomField->ActiveFlag && $arrAssetCustomFieldOption->CustomField->AllAssetModelsFlag) {
$arrRequiredAllAssetCustomFields[] = $arrAssetCustomFieldOption->CustomField->ShortDescription;
if (!in_array($arrAssetCustomFieldOption->CustomField->ShortDescription, $this->getLstKeys())) {
$blnRequiredAllAssetCustomFields = false;
}
}
}
// Checking errors (Model Short Description, Model Code, Category and Manufacturer must be selected)
for ($i = 0; $i < count($this->lstMapHeaderArray) - 1; $i++) {
$lstMapHeader = $this->lstMapHeaderArray[$i];
$strSelectedValue = strtolower($lstMapHeader->SelectedValue);
if ($strSelectedValue == "model") {
$blnAssetModelShortDescription = true;
} elseif ($strSelectedValue == "asset tag") {
$blnAssetCode = true;
} elseif ($strSelectedValue == "location") {
$blnLocation = true;
} elseif ($strSelectedValue == "id") {
$blnAssetId = true;
}
}
if ($this->lstMapDefaultValueArray) {
// Checking errors for required Default Value text fields
foreach ($this->lstMapDefaultValueArray as $lstDefault) {
if ($lstDefault->Display && $lstDefault->Required && !$lstDefault->SelectedValue) {
$lstDefault->Warning = "You must select one default value.";
$blnError = true;
break;
} else {
示例8: lblBookValue_Update
protected function lblBookValue_Update()
{
if ($objAssetModel = AssetModel::Load($this->lstAssetModel->SelectedValue)) {
$intDepreciationClassId = $objAssetModel->DepreciationClassId;
if (!empty($intDepreciationClassId) && DepreciationClass::Load($intDepreciationClassId)) {
$life = DepreciationClass::Load($intDepreciationClassId)->Life;
}
}
if (is_numeric($this->txtPurchaseCost->Text) && isset($life) && $this->calPurchaseDate->DateTime instanceof DateTime && QDateTime::Now() > $this->calPurchaseDate->DateTime) {
$interval = QDateTime::Now()->diff($this->calPurchaseDate->DateTime);
$interval = $interval->y * 12 + $interval->m;
$fltBookValue = $this->txtPurchaseCost->Text - $this->txtPurchaseCost->Text * ($interval / $life);
// prevent negative results
$fltBookValue = $fltBookValue < 0 ? 0 : $fltBookValue;
$this->lblBookValue->Text = money_format('%i', $fltBookValue);
} else {
$this->lblBookValue->Text = '...';
}
}
示例9: btnEdit_Click
public function btnEdit_Click($strFormId, $strControlId, $strParameter)
{
$strParameterArray = explode(',', $strParameter);
$objAssetModel = AssetModel::Load($strParameterArray[0]);
$objEditPanel = new AssetModelEditPanel($this, $this->strCloseEditPanelMethod, $objAssetModel);
$strMethodName = $this->strSetEditPanelMethod;
$this->objForm->{$strMethodName}($objEditPanel);
}
示例10: Reload
/**
* Reload this AssetModel from the database.
* @return void
*/
public function Reload()
{
// Make sure we are actually Restored from the database
if (!$this->__blnRestored) {
throw new QCallerException('Cannot call Reload() on a new, unsaved AssetModel object.');
}
// Reload the Object
$objReloaded = AssetModel::Load($this->intAssetModelId);
// Update $this's local variables to match
$this->CategoryId = $objReloaded->CategoryId;
$this->ManufacturerId = $objReloaded->ManufacturerId;
$this->strAssetModelCode = $objReloaded->strAssetModelCode;
$this->strShortDescription = $objReloaded->strShortDescription;
$this->strLongDescription = $objReloaded->strLongDescription;
$this->strImagePath = $objReloaded->strImagePath;
$this->CreatedBy = $objReloaded->CreatedBy;
$this->dttCreationDate = $objReloaded->dttCreationDate;
$this->ModifiedBy = $objReloaded->ModifiedBy;
$this->strModifiedDate = $objReloaded->strModifiedDate;
$this->DepreciationClassId = $objReloaded->DepreciationClassId;
}
示例11: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'AssetId':
// Gets the value for intAssetId (Read-Only PK)
// @return integer
return $this->intAssetId;
case 'ParentAssetId':
// Gets the value for intParentAssetId
// @return integer
return $this->intParentAssetId;
case 'AssetModelId':
// Gets the value for intAssetModelId (Not Null)
// @return integer
return $this->intAssetModelId;
case 'LocationId':
// Gets the value for intLocationId
// @return integer
return $this->intLocationId;
case 'AssetCode':
// Gets the value for strAssetCode (Unique)
// @return string
return $this->strAssetCode;
case 'ImagePath':
// Gets the value for strImagePath
// @return string
return $this->strImagePath;
case 'CheckedOutFlag':
// Gets the value for blnCheckedOutFlag
// @return boolean
return $this->blnCheckedOutFlag;
case 'ReservedFlag':
// Gets the value for blnReservedFlag
// @return boolean
return $this->blnReservedFlag;
case 'LinkedFlag':
// Gets the value for blnLinkedFlag
// @return boolean
return $this->blnLinkedFlag;
case 'ArchivedFlag':
// Gets the value for blnArchivedFlag
// @return boolean
return $this->blnArchivedFlag;
case 'CreatedBy':
// Gets the value for intCreatedBy
// @return integer
return $this->intCreatedBy;
case 'CreationDate':
// Gets the value for dttCreationDate
// @return QDateTime
return $this->dttCreationDate;
case 'ModifiedBy':
// Gets the value for intModifiedBy
// @return integer
return $this->intModifiedBy;
case 'ModifiedDate':
// Gets the value for strModifiedDate (Read-Only Timestamp)
// @return string
return $this->strModifiedDate;
case 'DepreciationFlag':
// Gets the value for blnDepreciationFlag
// @return boolean
return $this->blnDepreciationFlag;
case 'PurchaseDate':
// Gets the value for dttPurchaseDate
// @return QDateTime
return $this->dttPurchaseDate;
case 'PurchaseCost':
// Gets the value for fltPurchaseCost
// @return double
return $this->fltPurchaseCost;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'ParentAsset':
// Gets the value for the Asset object referenced by intParentAssetId
// @return Asset
try {
if (!$this->objParentAsset && !is_null($this->intParentAssetId)) {
$this->objParentAsset = Asset::Load($this->intParentAssetId);
}
return $this->objParentAsset;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'AssetModel':
//.........这里部分代码省略.........
示例12: Create
/**
* Static Helper Method to Create using PK arguments
* You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
* If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
* static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
* edit, or if we are also allowed to create a new one, etc.
*
* @param mixed $objParentObject QForm or QPanel which will be using this AssetModelMetaControl
* @param integer $intAssetModelId primary key value
* @param QMetaControlCreateType $intCreateType rules governing AssetModel object creation - defaults to CreateOrEdit
* @return AssetModelMetaControl
*/
public static function Create($objParentObject, $intAssetModelId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
{
// Attempt to Load from PK Arguments
if (strlen($intAssetModelId)) {
$objAssetModel = AssetModel::Load($intAssetModelId);
// AssetModel was found -- return it!
if ($objAssetModel) {
return new AssetModelMetaControl($objParentObject, $objAssetModel);
} else {
if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
throw new QCallerException('Could not find a AssetModel object with PK arguments: ' . $intAssetModelId);
}
}
// If EditOnly is specified, throw an exception
} else {
if ($intCreateType == QMetaControlCreateType::EditOnly) {
throw new QCallerException('No PK arguments specified');
}
}
// If we are here, then we need to create a new record
return new AssetModelMetaControl($objParentObject, new AssetModel());
}