本文整理汇总了PHP中Asset::CountActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset::CountActive方法的具体用法?PHP Asset::CountActive怎么用?PHP Asset::CountActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::CountActive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: btnAddAsset_Click
public function btnAddAsset_Click($strFormId, $strControlId, $strParameter)
{
if ($this->rblAssetType->SelectedValue == 'new') {
$blnError = false;
// Do not allow creation of an asset if asset limit will be exceeded
$intAssetLimit = is_numeric(QApplication::$TracmorSettings->AssetLimit) ? QApplication::$TracmorSettings->AssetLimit : false;
if ($intAssetLimit && Asset::CountActive() >= $intAssetLimit) {
$blnError = true;
$this->txtNewAssetCode->Warning = "Your asset limit has been reached.";
}
// Assign an empty string to the asset code for now (NULL won't work to render properly in the datagrid
if ($this->chkAutoGenerateAssetCode->Checked == true) {
$strAssetCode = '';
} else {
$strAssetCode = $this->txtNewAssetCode->Text;
if (!$strAssetCode) {
$blnError = true;
$this->txtNewAssetCode->Warning = 'You must enter an asset tag.';
}
}
// Generate an error if that asset code already exists
if ($objDuplicate = Asset::LoadByAssetCode($strAssetCode)) {
$blnError = true;
$this->txtNewAssetCode->Warning = 'That asset tag already exists. Choose another.';
} elseif (!$this->lstAssetModel->SelectedValue) {
$blnError = true;
$this->txtNewAssetCode->Warning = 'You must select one model.';
}
if (!$blnError) {
$objNewAsset = new Asset();
$objNewAsset->AssetModelId = $this->lstAssetModel->SelectedValue;
$objNewAsset->LocationId = 5;
// To Be Received
$objNewAsset->AssetCode = $strAssetCode;
// Set the AssetId to 0. This is so that it can be assigned to an AssetTransaction object without being saved to the db
// We don't want to save this until btnSave_Click, because we don't want to create new assets that could get orphaned
$objNewAsset->AssetId = 0;
// This can be combined with the code below it
$this->txtNewAssetCode->Text = null;
$this->txtNewAssetCode->Enabled = true;
$this->chkAutoGenerateAssetCode->Checked = false;
$this->lstAssetModel->SelectedValue = null;
$objNewAssetTransaction = new AssetTransaction();
// The source location can either be 'Shipped'(2) or 'To Be Received'(5)
$objNewAssetTransaction->SourceLocationId = $objNewAsset->LocationId;
// $objNewAssetTransaction->AssetId = $objNewAsset->AssetId;
$objNewAssetTransaction->Asset = $objNewAsset;
$this->objAssetTransactionArray[] = $objNewAssetTransaction;
// Set this boolean to true so that the datagrid updates
$this->blnModifyAssets = true;
}
} elseif ($this->rblAssetType->SelectedValue == 'existing') {
$strAssetCode = $this->txtNewAssetCode->Text;
$blnDuplicate = false;
$blnError = false;
if ($strAssetCode) {
// Begin error checking
if ($this->objAssetTransactionArray) {
foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
if ($objAssetTransaction && $objAssetTransaction->Asset->AssetCode == $strAssetCode) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset has already been added.";
}
}
}
if (!$blnError) {
$objNewAsset = Asset::LoadByAssetCode($this->txtNewAssetCode->Text);
if (!$objNewAsset instanceof Asset) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset tag does not exist.";
} elseif ($objNewAsset->LinkedFlag) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset is locked to a parent asset.";
} elseif ($objNewAsset->ArchivedFlag) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset is archived.";
} elseif ($objNewAsset->CheckedOutFlag) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset is checked out.";
} elseif ($objNewAsset->ReservedFlag) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset is reserved.";
} elseif (!($objNewAsset->LocationId == 5 || $objNewAsset->LocationId == 2)) {
$blnError = true;
$this->txtNewAssetCode->Warning = "That asset has already been received.";
} elseif (!QApplication::AuthorizeEntityBoolean($objNewAsset, 2)) {
$blnError = true;
$this->txtNewAssetCode->Warning = "You do not have authorization to perform a transaction on this asset.";
} elseif ($objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objNewAsset->AssetId)) {
$strAssetCodeArray = array();
$objCheckedLinkedAssetArray = array();
foreach ($objLinkedAssetArray as $objLinkedAsset) {
if (!QApplication::AuthorizeEntityBoolean($objLinkedAsset, 2)) {
$blnError = true;
$this->txtNewAssetCode->Warning = sprintf("You do not have authorization to perform a transaction on locked asset %s.", $objLinkedAsset->AssetCode);
break;
} else {
$objCheckedLinkedAssetArray[] = $objLinkedAsset;
$strAssetCodeArray[] = $objLinkedAsset->AssetCode;
}
//.........这里部分代码省略.........
示例2: Form_Create
protected function Form_Create()
{
if (QApplication::QueryString('intDownloadCsv')) {
$this->RenderBegin(false);
session_cache_limiter('must-revalidate');
// force a "no cache" effect
header("Pragma: hack");
// IE chokes on "no cache", so set to something, anything, else.
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT";
header($ExpStr);
header('Content-Type: text/csv');
header('Content-Disposition: csv; filename=skipped_records.csv');
$file = fopen(sprintf("%s/%s_skipped.csv", __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "r");
ob_end_clean();
while ($row = fgets($file, 1000)) {
print $row;
@ob_flush();
flush();
}
QApplication::$JavaScriptArray = array();
QApplication::$JavaScriptArrayHighPriority = array();
$this->RenderEnd(false);
exit;
}
// Create the Header Menu
$this->ctlHeaderMenu_Create();
$intRoleId = QApplication::$objUserAccount->RoleId;
$this->blnError = true;
$objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, EntityQtype::Asset, 2);
$this->intAssetLimit = QApplication::$TracmorSettings->AssetLimit;
$this->intAssetCount = Asset::CountActive();
// Check the user have edit permissions
if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) {
$this->blnError = false;
}
if (!$this->blnError) {
$this->pnlMain_Create();
$this->pnlStepOne_Create();
$this->Buttons_Create();
$this->intStep = 1;
$this->intSkippedRecordCount = 0;
$this->blnImportEnd = true;
$this->btnRemoveArray = array();
$this->Labels_Create();
$this->objDatabase = Asset::GetDatabase();
$this->intItemIdKey = null;
$this->objUpdatedItemArray = array();
$this->arrAssetCustomField = array();
$intCustomFieldIdArray = array();
// Load Asset Model Custom Field
foreach (CustomField::LoadArrayByActiveFlagEntity(1, EntityQtype::Asset) as $objCustomField) {
$this->arrAssetCustomField[$objCustomField->CustomFieldId] = $objCustomField;
$intCustomFieldIdArray[] = $objCustomField->CustomFieldId;
}
if (count($intCustomFieldIdArray)) {
//QApplication::$Database[1]->EnableProfiling();
// Load restrict permisions for Asset Cutom Fields
$objConditions = QQ::AndCondition(QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->RoleId, (string) $intRoleId), QQ::In(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->CustomFieldId, $intCustomFieldIdArray), QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->AuthorizedFlag, false));
$objClauses = array();
array_push($objClauses, QQ::Expand(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->EntityQtypeCustomFieldId));
array_push($objClauses, QQ::OrderBy(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomFieldId));
$arrRoleEntityQtypeCustomFieldAuthorization = RoleEntityQtypeCustomFieldAuthorization::QueryArray($objConditions, $objClauses);
if ($arrRoleEntityQtypeCustomFieldAuthorization) {
foreach ($arrRoleEntityQtypeCustomFieldAuthorization as $objRoleAuth) {
if (array_key_exists($objRoleAuth->EntityQtypeCustomField->CustomFieldId, $this->arrAssetCustomField)) {
unset($this->arrAssetCustomField[$objRoleAuth->EntityQtypeCustomField->CustomFieldId]);
}
}
}
//QApplication::$Database[1]->OutputProfiling();
}
$this->intUserArray = array();
// Load Users
/*foreach (UserAccount::LoadAll() as $objUser) {
$this->intUserArray[strtolower($objUser->Username)] = $objUser->UserAccountId;
}*/
$this->strAcceptibleMimeArray = array('text/plain' => 'txt', 'text/comma-separated-values' => 'csv', 'text/csv' => 'csv', 'text/x-comma-separated-values' => 'csv', 'application/vnd.ms-excel' => 'csv', 'application/csv' => 'csv', 'text/x-csv' => 'csv');
}
}
示例3: btnSave_Click
public function btnSave_Click($strFormId, $strControlId, $strParameter)
{
try {
// Get an instance of the database
$objDatabase = QApplication::$Database[1];
// Begin a MySQL Transaction to be either committed or rolled back
$objDatabase->TransactionBegin();
// Generate a new AssetCode based on the MinAssetCode value
// This happens whether or not they are creating a new one or editing an existing one
if ($this->chkAutoGenerateAssetCode->Checked) {
$this->txtAssetCode->Text = Asset::GenerateAssetCode();
}
$this->objAsset->AssetCode = $this->txtAssetCode->Text;
$this->objAsset->AssetModelId = $this->lstAssetModel->SelectedValue;
$blnError = false;
// If a new asset is being created
if (!$this->blnEditMode) {
// Do not allow creation of an asset if asset limit will be exceeded
$intAssetLimit = is_numeric(QApplication::$TracmorSettings->AssetLimit) ? QApplication::$TracmorSettings->AssetLimit : false;
if (!$this->blnEditMode) {
if ($intAssetLimit && Asset::CountActive() >= $intAssetLimit) {
$blnError = true;
$this->txtAssetCode->Warning = "Your asset limit has been reached.";
}
}
// Check to see if the asset code already exists
$AssetDuplicate = Asset::LoadByAssetCode($this->txtAssetCode->Text);
if ($AssetDuplicate) {
$blnError = true;
$this->txtAssetCode->Warning = "That asset code is already in use. Please try another.";
}
if (!$blnError && $this->txtParentAssetCode->Text) {
if ($this->txtParentAssetCode->Text != $this->objAsset->AssetCode) {
$objParentAsset = Asset::LoadByAssetCode($this->txtParentAssetCode->Text);
if (!$objParentAsset) {
$blnError = true;
$this->txtParentAssetCode->Warning = "That asset code does not exist. Please try another.";
} else {
if ($this->chkLockToParent->Checked && $objParentAsset->LocationId != $this->lstLocation->SelectedValue) {
// If locking child to parent, make sure assets are at the same location
$blnError = true;
$this->chkLockToParent->Warning = 'Cannot lock to parent asset at another location.';
} else {
if ($this->chkLockToParent->Checked && ($objParentAsset->CheckedOutFlag || $objParentAsset->ReservedFlag || $objParentAsset->ArchivedFlag || $objParentAsset->LocationId == 2 || $objParentAsset->LocationId == 5 || AssetTransaction::PendingTransaction($objParentAsset->AssetId))) {
$blnError = true;
$this->chkLockToParent->Warning = "Parent asset code (" . $objParentAsset->AssetCode . ") must not be currently Archived, Checked Out, Pending Shipment, Shipped/TBR, or Reserved.";
} else {
$this->objAsset->ParentAssetId = $objParentAsset->AssetId;
if ($this->chkLockToParent->Checked) {
$this->objAsset->LinkedFlag = 1;
}
}
}
}
} else {
$blnError = true;
$this->txtParentAssetCode->Warning = "Parent asset code must not be the same as asset code. Please try another.";
}
} else {
// If txtParentAssetCode is empty
$this->objAsset->LinkedFlag = false;
$this->objAsset->ParentAssetId = null;
}
if (!$blnError) {
// Location can only be decided when creating an asset. Otherwise they must conduct a transaction.
if (!$this->blnEditMode) {
$this->objAsset->LocationId = $this->lstLocation->SelectedValue;
}
// Save child assets
$this->SaveChildAssets();
// Object should be saved only if it is new, to obtain the proper AssetId to add to the custom field tables
$this->objAsset->Save();
$this->objParentObject->RefreshChildAssets();
}
}
// Assign input values to custom fields
if ($this->arrCustomFields && !$blnError) {
// Save the values from all of the custom field controls to save the asset
CustomField::SaveControls($this->objAsset->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objAsset->AssetId, 1);
}
if ($this->blnEditMode) {
// Check to see if the asset code already exists (and is not the asset code of the asset that the user is currently editing
$AssetDuplicate = Asset::LoadByAssetCode($this->txtAssetCode->Text);
if ($AssetDuplicate && $AssetDuplicate->AssetId != $this->objAsset->AssetId) {
$blnError = true;
$this->txtAssetCode->Warning = "That asset code is already in use. Please try another.";
}
if (!$blnError && $this->txtParentAssetCode->Text) {
// Check if the parent asset code is already a child asset of this asset
$arrChildAsset = Asset::LoadArrayByParentAssetId($this->objAsset->AssetId);
foreach ($arrChildAsset as $objChildAsset) {
if ($objChildAsset->AssetCode == $this->txtParentAssetCode->Text) {
$blnError = true;
$this->txtParentAssetCode->Warning = "Parent asset code is already a child of this asset. Please try another.";
break;
}
}
if (!$blnError) {
if ($this->txtParentAssetCode->Text != $this->objAsset->AssetCode) {
$objParentAsset = Asset::LoadByAssetCode($this->txtParentAssetCode->Text);
//.........这里部分代码省略.........
示例4: btnSave_Click
public function btnSave_Click($strFormId, $strControlId, $strParameter)
{
try {
// Get an instance of the database
$objDatabase = QApplication::$Database[1];
// Begin a MySQL Transaction to be either committed or rolled back
$objDatabase->TransactionBegin();
// Generate a new AssetCode based on the MinAssetCode value
// This happens whether or not they are creating a new one or editing an existing one
if ($this->chkAutoGenerateAssetCode->Checked) {
$this->txtAssetCode->Text = Asset::GenerateAssetCode();
}
$this->objAsset->AssetCode = $this->txtAssetCode->Text;
$this->objAsset->AssetModelId = $this->lstAssetModel->SelectedValue;
$blnError = false;
// If a new asset is being created
if (!$this->blnEditMode) {
// Do not allow creation of an asset if asset limit will be exceeded
$intAssetLimit = is_numeric(QApplication::$TracmorSettings->AssetLimit) ? QApplication::$TracmorSettings->AssetLimit : false;
if (!$this->blnEditMode) {
if ($intAssetLimit && Asset::CountActive() >= $intAssetLimit) {
$blnError = true;
$this->txtAssetCode->Warning = "Your asset limit has been reached.";
}
}
// Check Depreciation fields
if (QApplication::$TracmorSettings->DepreciationFlag == '1') {
if ($this->chkAssetDepreciation->Checked) {
if (!preg_match("/\\b\\d{1,3}(?:,?\\d{3})*(?:\\.\\d{2})?\\b/", $this->txtPurchaseCost->Text) || $this->txtPurchaseCost->Text <= 0) {
$blnError = true;
$this->txtPurchaseCost->Warning = "Purchase Cost value isn't valid";
} elseif (AssetModel::Load($this->lstAssetModel->SelectedValue)->DepreciationClassId != null) {
//print $this->calPurchaseDate->DateTime ."||". $this->txtPurchaseCost->Text."|";exit;
$this->objAsset->DepreciationFlag = true;
$this->objAsset->PurchaseDate = $this->calPurchaseDate->DateTime;
$this->objAsset->PurchaseCost = str_replace(',', '', $this->txtPurchaseCost->Text);
} else {
$blnError = true;
$this->chkAssetDepreciation->Warning = "Chosen Model isn't assigned to any Depreciation Class";
}
}
}
// Check to see if the asset tag already exists
$AssetDuplicate = Asset::LoadByAssetCode($this->txtAssetCode->Text);
if ($AssetDuplicate) {
$blnError = true;
$this->txtAssetCode->Warning = "That asset tag is already in use. Please try another.";
}
if (!$blnError && $this->txtParentAssetCode->Text) {
if ($this->txtParentAssetCode->Text != $this->objAsset->AssetCode) {
$objParentAsset = Asset::LoadByAssetCode($this->txtParentAssetCode->Text);
if (!$objParentAsset) {
$blnError = true;
$this->txtParentAssetCode->Warning = "That asset tag does not exist. Please try another.";
} else {
if ($this->chkLockToParent->Checked && $objParentAsset->LocationId != $this->lstLocation->SelectedValue) {
// If locking child to parent, make sure assets are at the same location
$blnError = true;
$this->chkLockToParent->Warning = 'Cannot lock to parent asset at another location.';
} else {
if ($this->chkLockToParent->Checked && ($objParentAsset->CheckedOutFlag || $objParentAsset->ReservedFlag || $objParentAsset->ArchivedFlag || $objParentAsset->LocationId == 2 || $objParentAsset->LocationId == 5 || AssetTransaction::PendingTransaction($objParentAsset->AssetId))) {
$blnError = true;
$this->chkLockToParent->Warning = "Parent asset tag (" . $objParentAsset->AssetCode . ") must not be currently Archived, Checked Out, Pending Shipment, Shipped/TBR, or Reserved.";
} else {
$this->objAsset->ParentAssetId = $objParentAsset->AssetId;
if ($this->chkLockToParent->Checked) {
$this->objAsset->LinkedFlag = 1;
}
}
}
}
} else {
$blnError = true;
$this->txtParentAssetCode->Warning = "Parent asset tag must not be the same as asset tag. Please try another.";
}
} else {
// If txtParentAssetCode is empty
$this->objAsset->LinkedFlag = false;
$this->objAsset->ParentAssetId = null;
}
if (!$blnError) {
// Location can only be decided when creating an asset. Otherwise they must conduct a transaction.
if (!$this->blnEditMode) {
$this->objAsset->LocationId = $this->lstLocation->SelectedValue;
}
// Save child assets
$this->SaveChildAssets();
// Object should be saved only if it is new, to obtain the proper AssetId to add to the custom field tables
$this->objAsset->Save();
$this->objParentObject->RefreshChildAssets();
}
}
// Assign input values to custom fields
if (is_array($this->arrCustomFields) && count($this->arrCustomFields) > 0 && !$blnError) {
// Save the values from all of the custom field controls to save the asset
CustomField::SaveControls($this->objAsset->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objAsset->AssetId, 1);
}
if ($this->blnEditMode) {
// Check to see if the asset tag already exists (and is not the asset tag of the asset that the user is currently editing
$AssetDuplicate = Asset::LoadByAssetCode($this->txtAssetCode->Text);
//.........这里部分代码省略.........