/** * Exit action for the field product * Fill some form fields (sale_price, amount) */ public static function onExitProduct($param) { $product_id = $param['product_id']; // get the product code try { TTransaction::open('permission'); //$product = new Product($product_id); // reads the product $result = new SystemStock(); $result->getDataItem($product_id); $obj = new StdClass(); $obj->product_description = $result->product; $obj->sale_price = number_format($result->price, 2, '.', ','); $obj->amount = 1; TTransaction::close(); TForm::sendData('form_pos', $obj); } catch (Exception $e) { // does nothing } }
/** * method Delete() * Delete a record */ function Delete($param) { try { // get the parameter $key $key = $param['key']; // open a transaction with database 'permission' TTransaction::open('permission'); // instantiates object System_group $object = new SystemStock($key); // deletes the object from the database $object->delete(); // close the transaction TTransaction::close(); // reload the listing $this->onReload($param); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted')); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }