<?php
	include_once('config.php');
	 
	 


		if(isset($_POST['deletecomm']))
        {  
			$stmt=$conn->prepare(" delete from pw__comdtdata  where id=:id ");   
			$stmt->bindValue(':id', $_POST['val'] , PDO::PARAM_STR);  
			$stmt->execute();   
			die;
		}
		
		

				if(isset($_POST['deletRaBill']))
				{ 
			 			
					$stmt=$conn->prepare("select RaBillNO,randNo from pw__rabills where id=:id ");   
					$stmt->bindValue(':id', $_POST['id'] , PDO::PARAM_STR);  
					$stmt->execute(); 
					$randNo = $stmt->fetch(PDO::FETCH_OBJ);
					 

					$stmt=$conn->prepare("delete from pw__comp  where randNo=:randNo and RaBillNO1=:RaBillNO1  ");    
					$stmt->bindValue(':randNo', $randNo->randNo , PDO::PARAM_STR);  
					$stmt->bindValue(':RaBillNO1',  $randNo->RaBillNO , PDO::PARAM_STR);  
					$stmt->execute();  


					$stmt=$conn->prepare("delete from pw__rabills   where id=:id "); 
					$stmt->bindValue(':id', $_POST['id'] , PDO::PARAM_STR);  
					$stmt->execute();  					
					die;
				}

	 
	 
	 
	  
	  
			
        if(isset($_POST['DeleImage1']))
        {    
            
                $stmt=$conn->prepare(" select * from UploadPics where id=:id ");   
                $stmt->bindValue(':id', $_POST['val'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $UploadPicsResult = $stmt->fetch(PDO::FETCH_OBJ);
                
                if($UploadPicsResult->type==1)
                    $tp = "SP";
                else  if($UploadPicsResult->type==2)
                    $tp = "WO"; 
                else  if($UploadPicsResult->type==3)
                    $tp = "QC";
                else  if($UploadPicsResult->type==4)
                    $tp = "IN";
                else  if($UploadPicsResult->type==5)
                    $tp = "RY";
                else  if($UploadPicsResult->type==6)
                    $tp = "OT";
                  
                unlink(ABS_PATH.'/uploads/'.$tp.'/'.$_SESSION['custId'].'/'.$UploadPicsResult->nm);    
                
                
                $stmt=$conn->prepare("delete  from UploadPics where id=:id ");   
                $stmt->bindValue(':id', $_POST['val'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                
                die; 
        }
        
        if(isset($_POST['DeleImage2']))
        {    
            
                $stmt=$conn->prepare(" select * from pw__userDoc where id=:id ");   
                $stmt->bindValue(':id', $_POST['val'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $UploadPicsResult = $stmt->fetch(PDO::FETCH_OBJ);   
                unlink(ABS_PATH.'/uploads/DocUpload/'.$_SESSION['custId'].'/'.$UploadPicsResult->docNm);      
                $stmt=$conn->prepare("delete  from pw__userDoc where id=:id ");   
                $stmt->bindValue(':id', $_POST['val'] , PDO::PARAM_STR);  
                $stmt->execute();  
                die; 
        }
?>