当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomField::AssignNewEntityDefaultValues方法代码示例

本文整理汇总了PHP中CustomField::AssignNewEntityDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::AssignNewEntityDefaultValues方法的具体用法?PHP CustomField::AssignNewEntityDefaultValues怎么用?PHP CustomField::AssignNewEntityDefaultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomField的用法示例。


在下文中一共展示了CustomField::AssignNewEntityDefaultValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: btnSave_Click

 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     if ($this->objAssetTransactionArray && $this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::AssetInventory;
     } elseif ($this->objAssetTransactionArray) {
         $intEntityQtypeId = EntityQtype::Asset;
     } elseif ($this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::Inventory;
     } else {
         $blnError = true;
         $this->btnCancel->Warning = 'There are no assets or inventory in this shipment.';
     }
     if (QApplication::$TracmorSettings->CustomShipmentNumbers) {
         if ($objShipment = Shipment::LoadByShipmentNumber($this->txtShipmentNumber->Text)) {
             if ($objShipment->ShipmentId != $this->objShipment->ShipmentId) {
                 $blnError = true;
                 $this->txtShipmentNumber->Warning = 'That is a duplicate shipment number.';
             }
         }
     }
     if (!$blnError) {
         if (!$this->blnEditMode) {
             try {
                 // Get an instance of the database
                 $objDatabase = QApplication::$Database[1];
                 // Begin a MySQL Transaction to be either committed or rolled back
                 $objDatabase->TransactionBegin();
                 // Create the new transaction object and save it
                 $this->objTransaction = new Transaction();
                 $this->objTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->objTransaction->TransactionTypeId = 6;
                 $this->objTransaction->Note = $this->txtNote->Text;
                 $this->objTransaction->Save();
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                         if ($objAssetTransaction->Asset instanceof Asset) {
                             // Save the asset just to update the modified_date field so it can trigger an Optimistic Locking Exception when appropriate
                             $objAssetTransaction->Asset->Save();
                             // Assign the TransactionId
                             $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId;
                             // Create the new asset if it was scheduled for receipt
                             if ($objAssetTransaction->ScheduleReceiptFlag && $objAssetTransaction->NewAsset && $objAssetTransaction->NewAsset instanceof Asset) {
                                 $objReceiptAsset = new Asset();
                                 $objReceiptAsset->AssetModelId = $objAssetTransaction->NewAsset->AssetModelId;
                                 $objReceiptAsset->LocationId = $objAssetTransaction->NewAsset->LocationId;
                                 //if ($objReceiptAsset->AssetCode == '') {
                                 if ($objAssetTransaction->NewAsset->AssetCode == '') {
                                     $objReceiptAsset->AssetCode = Asset::GenerateAssetCode();
                                 } else {
                                     $objReceiptAsset->AssetCode = $objAssetTransaction->NewAsset->AssetCode;
                                 }
                                 $objReceiptAsset->Save();
                                 // Assign any default custom field values
                                 CustomField::AssignNewEntityDefaultValues(1, $objReceiptAsset->AssetId);
                                 // Associate the new Asset with the AssetTransaction
                                 $objAssetTransaction->NewAsset = $objReceiptAsset;
                             }
                             // $objAssetTransaction->DestinationLocationId = $DestinationLocationId;
                             $objAssetTransaction->Save();
                             /*$objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId);
                             		if ($objLinkedAssetArray) {
                             		  foreach ($objLinkedAssetArray as $objLinkedAsset) {
                             		    $objLinkedAssetTransaction = new AssetTransaction();
                                						$objLinkedAssetTransaction->AssetId = $objLinkedAsset->AssetId;
                                						$objLinkedAssetTransaction->SourceLocationId = $objLinkedAsset->LocationId;
                                						$objLinkedAssetTransaction->TransactionId = $objAssetTransaction->TransactionId;
                                						$objLinkedAssetTransaction->Save();
                             		  }
                             		}*/
                         }
                     }
                 }
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) {
                         // Save the inventory location just to update the modified_date field so it can triggern an Optimistic Locking Exception when appropriate
                         $objInventoryTransaction->InventoryLocation->Save();
                         // Assign the TransactionId
                         $objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId;
                         // $objInventoryTransaction->DestinationLocationId = $DestinationLocationId;
                         $objInventoryTransaction->Save();
                     }
                 }
                 $this->UpdateShipmentFields();
                 $this->objShipment->ShippedFlag = false;
                 $this->objShipment->Save();
                 if ($this->arrCustomFields) {
                     // Save the values from all of the custom field controls to save the shipment
                     CustomField::SaveControls($this->objShipment->objCustomFieldArray, $this->blnEditMode, $this->arrCustomFields, $this->objShipment->ShipmentId, 10);
                 }
                 $objDatabase->TransactionCommit();
                 QApplication::Redirect('shipment_list.php');
             } catch (QExtendedOptimisticLockingException $objExc) {
                 // Rollback the database
                 $objDatabase->TransactionRollback();
                 if ($objExc->Class == 'Asset') {
                     // $this->btnRemoveAssetTransaction_Click($this->FormId, 'btnRemoveAsset' . $objExc->EntityId, $objExc->EntityId);
                     $this->btnRemoveAssetTransaction_Click($this->FormId, null, $objExc->EntityId);
//.........这里部分代码省略.........
开发者ID:proxymoron,项目名称:tracmor,代码行数:101,代码来源:shipment_edit.php

示例2: btnSave_Click

 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     if ($this->objAssetTransactionArray && $this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::AssetInventory;
     } elseif ($this->objAssetTransactionArray) {
         $intEntityQtypeId = EntityQtype::Asset;
     } elseif ($this->objInventoryTransactionArray) {
         $intEntityQtypeId = EntityQtype::Inventory;
     } else {
         $blnError = true;
         $this->btnCancel->Warning = 'There are no assets nor inventory in this receipt.';
     }
     if (QApplication::$TracmorSettings->CustomReceiptNumbers) {
         if (trim($this->txtReceiptNumber->Text) == '') {
             $blnError = true;
             $this->txtReceiptNumber->Warning = 'Receipt number is a required field.';
         } else {
             if ($objReceipt = Receipt::LoadByReceiptNumber($this->txtReceiptNumber->Text)) {
                 if ($objReceipt->ReceiptId != $this->objReceipt->ReceiptId) {
                     $blnError = true;
                     $this->txtReceiptNumber->Warning = 'That is a duplicate receipt number.';
                 }
             }
         }
     }
     if (!$this->lstFromCompany->SelectedValue) {
         $blnError = true;
         $this->lstFromCompany->Warning = 'You must select a From Company';
     }
     if (!$this->lstFromContact->SelectedValue) {
         $blnError = true;
         $this->lstFromContact->Warning = 'You must select a From Contact';
     }
     if (!$this->lstToContact->SelectedValue) {
         $blnError = true;
         $this->lstToContact->Warning = 'You must select a To Contact';
     }
     if (!$this->lstToAddress->SelectedValue) {
         $blnError = true;
         $this->lstToAddress->Warning = 'You must select a To Address';
     }
     if (!$blnError) {
         if (!$this->blnEditMode) {
             try {
                 // Get an instance of the database
                 $objDatabase = QApplication::$Database[1];
                 // Begin a MySQL Transaction to be either committed or rolled back
                 $objDatabase->TransactionBegin();
                 // Create the new transaction object and save it
                 $this->objTransaction = new Transaction();
                 $this->objTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->objTransaction->TransactionTypeId = 7;
                 // Receive
                 $this->objTransaction->Note = $this->txtNote->Text;
                 $this->objTransaction->Save();
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                         // Save the asset just to update the modified_date field so it can trigger an Optimistic Locking Exception when appropriate
                         if ($objAssetTransaction->Asset instanceof Asset) {
                             // Save the asset to update the modified_date field so it can trigger an Optimistic Locking Exception when appropriate
                             // Also set the location to 5 (TBR). This is in case the current LocationId is 2 (Shipped), because they can be received.
                             $objAssetTransaction->Asset->LocationId = 5;
                             // If the AssetId==0, then it is a newly created asset that hasn't been saved to the db yet
                             // We have to create a new asset object and assign it to the AssetTransaction
                             // Just resetting the values for the existing asset object won't work for some reason (not sure why).
                             if ($objAssetTransaction->Asset->AssetId == 0) {
                                 $objNewAsset = new Asset();
                                 $objNewAsset->AssetModelId = $objAssetTransaction->Asset->AssetModelId;
                                 $objNewAsset->TempId = $objAssetTransaction->Asset->TempId;
                                 $objNewAsset->LocationId = $objAssetTransaction->Asset->LocationId;
                                 // If the asset was selected for autogeneration, it will be blank, so create the asset code here (right before save)
                                 if ($objAssetTransaction->Asset->AssetCode == '') {
                                     $objAssetTransaction->Asset->AssetCode = Asset::GenerateAssetCode();
                                 }
                                 $objNewAsset->AssetCode = $objAssetTransaction->Asset->AssetCode;
                                 // Save the new asset
                                 $objNewAsset->Save();
                                 // Assign any default custom field values
                                 CustomField::AssignNewEntityDefaultValues(1, $objNewAsset->AssetId);
                                 // Assign the new asset to the AssetTransaction
                                 $objAssetTransaction->Asset = $objNewAsset;
                                 $objAssetTransaction->NewAssetFlag = true;
                             } else {
                                 $objAssetTransaction->NewAssetFlag = false;
                                 $objAssetTransaction->Asset->Save();
                             }
                             // Create the new assettransaction object and save it
                             $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId;
                             $objAssetTransaction->Save();
                         }
                     }
                 }
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objInventoryTransactionArray as &$objInventoryTransaction) {
                         // Finish the InventoryTransaction and save it
                         $objInventoryTransaction->InventoryLocation->Quantity += $objInventoryTransaction->Quantity;
                         $objInventoryTransaction->InventoryLocation->Save();
//.........这里部分代码省略.........
开发者ID:proxymoron,项目名称:tracmor,代码行数:101,代码来源:receipt_edit.php

示例3: btnSave_Click


//.........这里部分代码省略.........
         if (!$this->blnEditMode) {
             try {
                 // Get an instance of the database
                 $objDatabase = QApplication::$Database[1];
                 // Begin a MySQL Transaction to be either committed or rolled back
                 $objDatabase->TransactionBegin();
                 // Create the new transaction object and save it
                 $this->objTransaction = new Transaction();
                 $this->objTransaction->EntityQtypeId = $intEntityQtypeId;
                 $this->objTransaction->TransactionTypeId = 6;
                 $this->objTransaction->Note = $this->txtNote->Text;
                 $this->objTransaction->Save();
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Asset) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objAssetTransactionArray as $objAssetTransaction) {
                         if ($objAssetTransaction->Asset instanceof Asset) {
                             // Save the asset just to update the modified_date field so it can trigger an Optimistic Locking Exception when appropriate
                             $objAssetTransaction->Asset->Save();
                             // Assign the TransactionId
                             $objAssetTransaction->TransactionId = $this->objTransaction->TransactionId;
                             // Create the new asset if it was scheduled for receipt
                             if ($objAssetTransaction->ScheduleReceiptFlag && $objAssetTransaction->NewAsset && $objAssetTransaction->NewAsset instanceof Asset) {
                                 $objReceiptAsset = new Asset();
                                 $objReceiptAsset->AssetModelId = $objAssetTransaction->NewAsset->AssetModelId;
                                 $objReceiptAsset->LocationId = $objAssetTransaction->NewAsset->LocationId;
                                 //if ($objReceiptAsset->AssetCode == '') {
                                 if ($objAssetTransaction->NewAsset->AssetCode == '') {
                                     $objReceiptAsset->AssetCode = Asset::GenerateAssetCode();
                                 } else {
                                     $objReceiptAsset->AssetCode = $objAssetTransaction->NewAsset->AssetCode;
                                 }
                                 $objReceiptAsset->Save();
                                 // Assign any default custom field values
                                 CustomField::AssignNewEntityDefaultValues(1, $objReceiptAsset->AssetId);
                                 // Associate the new Asset with the AssetTransaction
                                 $objAssetTransaction->NewAsset = $objReceiptAsset;
                             }
                             // $objAssetTransaction->DestinationLocationId = $DestinationLocationId;
                             $objAssetTransaction->Save();
                             /*$objLinkedAssetArray = Asset::LoadChildLinkedArrayByParentAssetId($objAssetTransaction->Asset->AssetId);
                             		if ($objLinkedAssetArray) {
                             		  foreach ($objLinkedAssetArray as $objLinkedAsset) {
                             		    $objLinkedAssetTransaction = new AssetTransaction();
                                						$objLinkedAssetTransaction->AssetId = $objLinkedAsset->AssetId;
                                						$objLinkedAssetTransaction->SourceLocationId = $objLinkedAsset->LocationId;
                                						$objLinkedAssetTransaction->TransactionId = $objAssetTransaction->TransactionId;
                                						$objLinkedAssetTransaction->Save();
                             		  }
                             		}*/
                         }
                     }
                 }
                 if ($intEntityQtypeId == EntityQtype::AssetInventory || $intEntityQtypeId == EntityQtype::Inventory) {
                     // Assign different source and destinations depending on transaction type
                     foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) {
                         // Save the inventory location just to update the modified_date field so it can triggern an Optimistic Locking Exception when appropriate
                         $objInventoryTransaction->InventoryLocation->Save();
                         // Assign the TransactionId
                         $objInventoryTransaction->TransactionId = $this->objTransaction->TransactionId;
                         // $objInventoryTransaction->DestinationLocationId = $DestinationLocationId;
                         $objInventoryTransaction->Save();
                     }
                 }
                 $this->UpdateShipmentFields();
                 $this->objShipment->ShippedFlag = false;
                 $this->objShipment->Save();
开发者ID:brustj,项目名称:tracmor,代码行数:67,代码来源:shipment_edit.php


注:本文中的CustomField::AssignNewEntityDefaultValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。