<?php

ob_start();
include('../db_con.php');
//var_dump($_REQUEST);

	$appid = intval($_REQUEST['app']);
$type = intval($_REQUEST['type']);
	$file = $_REQUEST['file'];

		
				
		$sql = "delete from app_docu_table where `app_id`='$appid' AND `file`='$file' AND `doc_type`='$type'";

		 //var_dump($sql) or die();
		 $result = @mysqli_query($con,$sql);
		 if ($result){
			
		 	if($type==1) unlink("uploads/documents/".$file);
		 	if($type==2) unlink("uploads/reports/".$file);

		 	//header("Location:viewdocuments.php?appid=$appid");
			//echo json_encode(array('success'=>true));
			header('Location: ' . $_SERVER['HTTP_REFERER']);
			exit;
			
		} else {
			echo "Some errors occured.";
		}
?>