<?php
session_start();

	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}

	include("connect.php");
	
	date_default_timezone_set("Asia/Kolkata");
	$mdate1= date('Y-m-d H:i:s');
	
	
	
		$par1 = $_SESSION['linkariseumobile'];
				$ipaddress = "";

				if (getenv('HTTP_CLIENT_IP'))
					$ipaddress = getenv('HTTP_CLIENT_IP');
				else if(getenv('HTTP_X_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
				else if(getenv('HTTP_X_FORWARDED'))
					$ipaddress = getenv('HTTP_X_FORWARDED');
				else if(getenv('HTTP_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_FORWARDED_FOR');
				else if(getenv('HTTP_FORWARDED'))
					$ipaddress = getenv('HTTP_FORWARDED');
				else if(getenv('REMOTE_ADDR'))
					$ipaddress = getenv('REMOTE_ADDR');
				else
					$ipaddress = 'UNKNOWN';

				$userserver=$_SERVER['HTTP_USER_AGENT'];
				$eve1 = "insert into res_user_log (lid,mobile,lastupdatedtime,pagename,taskname,ipaddress,useragentdetail) values(NULL,'$par1','$mdate1','Purchase Order','delete Purchase Order','$ipaddress','$userserver')";
				$re1 = mysqli_query($conn, $eve1);



	if(isset($_POST['pomid'])){
$pomid=(int)mysqli_real_escape_string($conn,$_POST['pomid']);}
	else{
		$pomid=(int)mysqli_real_escape_string($conn,$_GET['id']);
	}

	
	$query="delete from res_po_master where pomid=$pomid";
	$result= mysqli_query($conn, $query) or die("Error");
		
	$_SESSION['msg'] = "Record deleted successfully";
	
	header('Location: purchaseorder.php');
	
	
?>
