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

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

	$result="0";
	
	  $eve = "select * from res_invoice_master where cmpmid=$cmpmid and paymentreminder='Yes' ORDER BY paymentreminderdate ASC";
	$re = mysqli_query($conn, $eve);

	if(mysqli_num_rows($re) > 0)
	{
		$i=0;
		while($rt = mysqli_fetch_assoc($re))
		{
				$i++;
			 	//$inqfdid=$rt['fdid'];
			 	//$imid=$rt['imid'];
			 	$partymid=$rt['customermid'];
			 	$invoicemid=$rt['invoicemid'];
			 
			 	$idate=date("d-m-Y",strtotime($rt['invoicedate']));
			 	$inqfdate=date("d-m-y",strtotime($rt['paymentreminderdate']));
			 
			 	$inqfollowremarks=$rt['paymentreminderremarks'];
			
				$eve1 = "select * from res_party_master where cmpmid=$cmpmid and partymid='$partymid'";
	$re1 = mysqli_query($conn, $eve1);
	$partyno="";
					$cmpname="";
					$cname=""; 
				
					$cmobile=""; 
	while($rt1 = mysqli_fetch_assoc($re1))
		{
					$partyno=$rt1['partyno'];
					$cmpname=$rt1['partyname'];
					$cname=$rt1['partycpname']; 
					
					$cmobile=$rt1['partymobile']; 
		}
				
				
			
			 	
				
				$inqaddfollowup= "<a href='inquiryfollowupaddnext.php?id=$partymid'><i class='fa fa-pencil' title=' Add New Inquiry Follow-Up'></i></a>";
				
				$inqfstatus="aa";
				$fdelete="";
				if($inqfstatus=="Pending"){
				$fdelete="<a href='inquiryfollowupdelete.php?id=".$inqfdid."' data-toggle='tooltip' data-placement='top' title='Delete' class='fa fa-trash-o fa-lg' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' >  </a>";
			}
			else{
				$fdelete;
			}
			$stageedit="<a href='#' data-bs-toggle='modal' data-id='".$invoicemid."' data-bs-target='#kt_modal_reminder' class='btn btn-sm btn-primary align-self-center' id='getUser2'>$inqfdate<i class='fa fa-pencil'></i></a>";
				 $op1="<span class='label label-sm label-danger'>$inqfdate</span>";
				 $cmpnamecontact=$cname."&nbsp;&nbsp;<br>".$cmobile;
					$op=$stageedit;
		

				$posts[] = array('i'=> $i,'imid'=> $invoicemid, 'op'=> $op,'inqfstatus'=> $inqfstatus,'cmpname'=>$cmpname,'cmpnamecontact'=>$cmpnamecontact,'fdelete'=>$fdelete,'idate'=>$idate,'inqfollowremarks'=>$inqfollowremarks);

			//$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);
	
	
?>
