$record = $_REQUEST['record']; $sugarbean->retrieve($record); if (!$sugarbean->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $GLOBALS['log']->info("deleting Item: {$record}"); // Antes de borrar, obtenemos el ID de la factura $sql = " select invoice_id from invoice_items where deleted=0 and id = '{$record}' "; $result = $sugarbean->db->query($sql); $row = $sugarbean->db->fetchByAssoc($result); $invoice_id = $row['invoice_id']; // Borramos el Item $sugarbean->mark_deleted($record); // Actualizamos la factura asociada. if ($invoice_id) { $invoice = new reg_invoices(); $invoice->retrieve($invoice_id); $invoice->calcularTotal(); $invoice->save(); } } // handle the return location variables if (!empty($_REQUEST['return_url'])) { $_REQUEST['return_url'] = urldecode($_REQUEST['return_url']); } $GLOBALS['log']->debug("deleted Item: bean: {$bean_name}, "); if (empty($_REQUEST['refresh_page'])) { handleRedirect(); } exit;