protected function btnDelete_Click($strFormId, $strControlId, $strParameter) { try { $objCustomFieldArray = $this->objCompany->objCustomFieldArray; $this->objCompany->Delete(); // Custom Field Values for text fields must be manually deleted because MySQL ON DELETE will not cascade to them // The values should not get deleted for select values CustomField::DeleteTextValues($objCustomFieldArray); $this->RedirectToListPage(); } catch (QDatabaseExceptionBase $objExc) { if ($objExc->ErrorNumber == 1451) { $this->btnDelete->Warning = 'This company cannot be deleted because it is associated with one or more shipments or receipts.'; } else { throw new QDatabaseExceptionBase(); } } }
protected function btnDelete_Click($strFormId, $strControlId, $strParameter) { $objCustomFieldArray = $this->objReceipt->objCustomFieldArray; $blnError = false; if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction->blnReturnReceivedStatus()) { $blnError = true; $this->btnDelete->Warning = 'All Assets and Inventory must be Pending to delete this receipt.'; } } } if ($this->objInventoryTransactionArray) { foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { if ($objInventoryTransaction->blnReturnReceivedStatus()) { $blnError = true; $this->btnDelete->Warning = 'All Assets and Inventory must be Pending to delete this receipt.'; } } } if (!$blnError) { // Take out the inventory from the TBR InventoryLocation if ($this->objInventoryTransactionArray) { foreach ($this->objInventoryTransactionArray as $objInventoryTransaction) { $objInventoryTransaction->InventoryLocation->Quantity -= $objInventoryTransaction->Quantity; $objInventoryTransaction->InventoryLocation->Save(); } } // Delete any assets that were created while scheduling this receipt if ($this->objAssetTransactionArray) { foreach ($this->objAssetTransactionArray as $objAssetTransaction) { if ($objAssetTransaction->NewAssetFlag) { $objAssetTransaction->Asset->Delete(); } } } // Load the Transaction $this->objTransaction = Transaction::Load($this->objReceipt->TransactionId); // Delete the Transaction Object and let it MySQL CASCADE down to asset_transaction, inventory_transaction, and receipt $this->objTransaction->Delete(); CustomField::DeleteTextValues($objCustomFieldArray); $this->RedirectToListPage(); } }
public function btnDelete_Click($strFormId, $strControlId, $strParameter) { try { $objCustomFieldArray = $this->objInventoryModel->objCustomFieldArray; $this->objInventoryModel->Delete(); // Custom Field Values for text fields must be manually deleted because MySQL ON DELETE will not cascade to them // The values do not get deleted for select values CustomField::DeleteTextValues($objCustomFieldArray); QApplication::Redirect('inventory_model_list.php'); } catch (QDatabaseExceptionBase $objExc) { if ($objExc->ErrorNumber == 1451) { $this->btnDelete->Warning = 'This inventory model cannot be deleted because it is associated with one or more transactions.'; } else { throw new QDatabaseExceptionBase(); } } }
protected function btnDelete_Click($strFormId, $strControlId, $strParameter) { $objCustomFieldArray = $this->objShipment->objCustomFieldArray; // Just delete the transaction and MySQL CASCADE down to shipment, asset_transaction, and inventory_transaction $this->objTransaction = Transaction::Load($this->objShipment->TransactionId); $this->objTransaction->Delete(); CustomField::DeleteTextValues($objCustomFieldArray); QApplication::Redirect('../shipping/shipment_list.php'); }