<?php

ob_start();
require_once('../../../../wp-config.php');

$id = $_POST["fa"];
$order_id = $_POST["order_id"];
$table_prefix = "0_";
$conn = db();

$sql = "DELETE FROM ".$table_prefix."refs WHERE id = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."sales_orders WHERE order_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."sales_order_details WHERE order_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."debtor_trans WHERE trans_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."debtor_trans_details WHERE debtor_trans_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."trans_tax_details WHERE trans_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."gl_trans WHERE type_no = $id";
$conn->query($sql);

$sql = "DELETE FROM ".$table_prefix."stock_moves WHERE trans_no = $id";
$conn->query($sql);

$conn->close();

delete_post_meta( $order_id, '_fa');

//echo "respone";
?>
