if($ill->get($_REQUEST['link_id']) === FALSE){ $error_msg .= "Could not get invoice line!"; debug_message($ill->getLastError()); }else{ $line->quantity -= $ill->getQuantity(); $line->addTax(); if($line->update() === FALSE){ $error_msg .= "Could not update quantity on line item!"; debug_message($line->getLastError()); }else{ $ct = new SI_CompanyTransaction(); if($ct->get($invoice->trans_id) === FALSE){ $error_msg .= "Error getting transaction for invoice!"; debug_message($ct->getLastError()); }else{ $ct->amount -= $ill->getPrice(); if($ct->update() === FALSE){ $error_msg .= "Error updating company transaction with new price"; debug_message($ct->getLastError()); }else{ if($ill->delete() === FALSE){ $error_msg .= "Error deleting line link"; debug_message($ill->getLastError()); }else{ header('Location: '.getCurrentURL(null, false).'?mode=edit&id='.$line->id."\r\n"); die(); } } } } }