<?php
	include("../config.php");
	$response = array();
	if ($_POST['delete']) {
		$id = $_POST['delete'];
		$type              = 'trip_delete';
	    $user_id           = $_SESSION['user_detail']['id'];
	    $data              = serialize($_POST);
	    $created_datetime  = date('Y-m-d H:i:s');
	    $created_id        = $_SESSION['user_detail']['id'];
	    $updated_datetime  = date('Y-m-d H:i:s');
	    $updated_id        = $_SESSION['user_detail']['id'];

 		$trip     = mysqli_query($conn, "SELECT * FROM `trip` WHERE `id` = '".$id."'");
	    $trip_row = mysqli_fetch_assoc($trip);
	    $trip_no = $trip_row['trip_no'];
	    $gl_delete 		   = mysqli_query($conn, "DELETE FROM `trip` WHERE `id` = '".$id."'");
		$detail_delete     = mysqli_query($conn, "DELETE FROM `trip_detail` WHERE `master_id` = '".$id."'");

 		$gl_delete_legder = mysqli_query($conn, "DELETE FROM `general_ledger` WHERE `trip_code` = '".$trip_no."' "); 

 		$gl_delete_bank = mysqli_query($conn, "DELETE FROM `bank_master` WHERE `trip_code` = '".$trip_no."' ");
 		$gl_delete_bank_details = mysqli_query($conn, "DELETE FROM `bank_details` WHERE `trip_code` = '".$trip_no."' ");   

 		$gl_delete_cash = mysqli_query($conn, "DELETE FROM `cash_master` WHERE `trip_code` = '".$trip_no."' ");   


 		$gl_delete_cash_details = mysqli_query($conn, "DELETE FROM `cash_details` WHERE `trip_code` = '".$trip_no."' ");   


		$activity = mysqli_query($conn, "INSERT INTO `activities`(`type`, `user_id`, `data`, `created_id`, `created_datetime`, `updated_id`, `updated_datetime`) VALUES ('".$type."','".$user_id."','".$data."','".$created_id."','".$created_datetime."','".$updated_id."','".$updated_datetime."')");
		echo json_encode($response);
	}
?>