/**
 * Delete InvoiceDBO from database
 *
 * @param InvoiceDBO &$dbo InvoiceDBO to delete
 */
function delete_InvoiceDBO(&$dbo)
{
    $DB = DBConnection::getDBConnection();
    // Delete line-items
    foreach ($dbo->getItems() as $item_dbo) {
        delete_InvoiceItemDBO($item_dbo);
    }
    // Delete Payments
    foreach ($dbo->getPayments() as $payment_dbo) {
        delete_PaymentDBO($payment_dbo);
    }
    // Build SQL
    $sql = $DB->build_delete_sql("invoice", "id = " . intval($dbo->getID()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
}
 /**
  * Delete Line Item
  *
  * Remove a line item from the invoice
  */
 function delete_line_item()
 {
     // Delete Invoice Items
     foreach ($this->post['items'] as $dbo) {
         delete_InvoiceItemDBO($dbo);
     }
     // Success
     $this->setMessage(array("type" => "[INVOICE_ITEM_DELETED]"));
     $this->reload();
 }