예제 #1
0
 public static function delete_invoice($invoice_id)
 {
     $invoice_id = (int) $invoice_id;
     if ((int) $invoice_id > 0 && self::can_i('delete', 'Invoices')) {
         hook_handle_callback('invoice_deleted', $invoice_id);
         $invoice_data = self::get_invoice($invoice_id);
         $sql = "DELETE FROM " . _DB_PREFIX . "invoice WHERE invoice_id = '" . $invoice_id . "' LIMIT 1";
         $res = query($sql);
         $sql = "DELETE FROM " . _DB_PREFIX . "invoice_item WHERE invoice_id = '" . $invoice_id . "'";
         $res = query($sql);
         $sql = "DELETE FROM " . _DB_PREFIX . "invoice_tax WHERE invoice_id = '" . $invoice_id . "'";
         $res = query($sql);
         $sql = "DELETE FROM " . _DB_PREFIX . "invoice_payment WHERE invoice_id = '" . $invoice_id . "'";
         $res = query($sql);
         $sql = "UPDATE " . _DB_PREFIX . "invoice SET renew_invoice_id = 0 WHERE renew_invoice_id = '" . $invoice_id . "'";
         $res = query($sql);
         if (class_exists('module_note', false) && module_note::is_plugin_enabled()) {
             module_note::note_delete("invoice", $invoice_id);
         }
         if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
             module_extra::delete_extras('invoice', 'invoice_id', $invoice_id);
         }
         module_cache::clear('invoice');
         module_cache::clear('job');
         if ($invoice_data && $invoice_data['customer_id']) {
             module_customer::update_customer_status($invoice_data['customer_id']);
         }
     }
 }