<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['manager_id']) && isset($_POST['title'])&& isset($_POST['message']))
{
	$manager_id = $_POST['manager_id'];
	$message=$_POST['message'];
	$title=$_POST['title'];
	
	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	$ctime=date('h:i:sa');

	$res_device_id = mysqli_query($con,"SELECT device_id FROM `tbl_manager` where tbl_manager.manager_id='$manager_id'");
	if(mysqli_num_rows($res_device_id)>0)
	{	
		while( $fetch_detail=mysqli_fetch_assoc($res_device_id))
		{
			$key=$fetch_detail['device_id'];
			include("send_notification.php");
			$query = mysqli_query($con,"INSERT INTO `tbl_notification_history`(`manager_id`, `agent_id`, `title`, `message`, `date`, `time`) VALUES ('$manager_id','','$title','$message','$cdate','$ctime')");
		}
	}

	$response['success']='1';
	$response['details']="Send Successful";			
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);
?>