<?php
session_start();
	  $nm = (isset($_GET['nm']) && $_GET['nm']!=""?$_GET['nm']:"");
    if(!empty($nm))  
    {  
			//echo $id;
     		$_SESSION[$_GET["nm"]]=$_GET["img"];
			echo $_SESSION[$_GET["nm"]].$_GET["nm"];
    } 

    $id = (isset($_GET['id']) && $_GET['id']!=""?$_GET['id']:"");
    if(!empty($id))  
    {  
echo $id;
        if(unlink('ScanedImagesTemp/'.$id))  
        {  
            echo 'Image Deleted';  
	    }  
    } 


    $orgId = (isset($_GET['orgId'])&& $_GET['orgId']!=""?$_GET['orgId']:"");
    if(!empty($orgId))  
    {  
        if(unlink($orgId))  
        {  
	//include_once('db.php');
        include "connect.php";
        $del='delete from customer_menu WHERE customer_id='.$_REQUEST["cust_id"].' and menu_id="'.$_REQUEST["menu_id"].'"';
		mysqli_query($con,$del);
        $documents = $_GET['documents'];
            if($_GET['documents']=="All-Done"){
                if($_GET['status']=='Insp'){
                    $upd='UPDATE customer SET documents="Half-Done",status="Upload" WHERE customer_id='.$_REQUEST["cust_id"];
                    mysqli_query($con,$upd);
                } else {
                    $upd='UPDATE customer SET documents="Half-Done" WHERE customer_id='.$_REQUEST["cust_id"];
                    mysqli_query($con,$upd);
                }
            }
        
        }  
    }  
    if(isset($_GET['location'])){
        $file_path = $_GET['location'];
        $name = $_GET['name'];
        if (file_exists($file_path)) {
            unlink($file_path);
            include "connect.php";
            if($name=='crtm'){
                $q='UPDATE customer SET crtm = null where customer_id ='.$_GET['id'];
            }elseif($name=='taxReceipt'){
                $q='UPDATE customer SET taxReceipt = null where customer_id ='.$_GET['id'];
            }elseif($name=='SMCtaxReceipt'){
                $q='UPDATE customer SET SMCtaxReceipt = null where customer_id ='.$_GET['id'];
            }elseif($name=='permit'){
                $q='UPDATE customer SET permit = null where customer_id ='.$_GET['id'];
            }elseif($name=='fitness'){
                $q='UPDATE customer SET fitness = null where customer_id ='.$_GET['id'];
            }
            mysqli_query($con,$q);

            echo 'File deleted successfully.';
        } else {
            echo 'File does not exist.';
        }
    }    
?>  