<?php
session_start();
if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	include("connect.php");	header("Access-Control-Allow-Origin: *");
		$brmid=$_SESSION['linkarisebranchid'];
		$cmpmid=$_SESSION['linkarisecmpmid'];
			$umid = $_SESSION['linkariseumid'];

	
		$tt="";
		if($_SESSION['linkariseutype']<>'Admin')
		{
			$tt=" and umid=$umid";
		}
	 $eve = "select * from res_party_master where cmpmid=$cmpmid and partytype='Expense' $tt order by partymid desc";

	$re = mysqli_query($conn, $eve);


	$response = array();
	$posts = array();

	$result="0";

	if(mysqli_num_rows($re) > 0)
	{
		$i=1;
		while($rt = mysqli_fetch_assoc($re))
		{
			 	$partymid=$rt['partymid'];
			 	$partyno=$rt['partyno'];
			 	$umid=$rt['umid'];

				
					$uedit="<a href='expenseedit.php?id=".$rt['partymid']."'data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg' >  </a>";
			
				
				$udelete="<a href='expensedelete.php?id=".$rt['partymid']."' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa-lg'>  </a>";
		
				
				$op=$uedit."&nbsp;&nbsp; ".$udelete;
			
			
				$cmpname=$rt['partyname'];
				$paddress=$rt['partyaddress'];
				

			//$imid1="@".$imid;
			$imid1="$i";

				$posts[] = array('partymid'=> $partymid,'partyno'=> $partyno, 'op'=> $op,'cmpname'=> $cmpname,'paddress'=>$paddress);

			$i++;


		}

		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		mysqli_close($conn);
		return;
	}

   else
	{
		$result="0";
		$msg="Invalid Error";

		$posts[] = array('p1'=> $result,'p2'=> $msg);

		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
	}

	mysqli_close($conn);
?>
