<?php
session_start();
if (!isset($_SESSION['tulsilogin'])) {
    header('Location: index.php');
    return;
}
include("connect.php");
header("Access-Control-Allow-Origin: *");
$staffId = $_GET['staffid'];

$eve = "select * from res_prospect_management where staffid=$staffId";

if (isset($_GET['status']) && $_GET['status'] != "all") {
    $status = $_GET['status'];
    $eve = "select * from res_prospect_management where status='$status' AND staffid=$staffId";
}

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

$response = array();
$data = array();

$result = "0";

if (mysqli_num_rows($re) > 0) {
    $i = 1;
    while ($rt = mysqli_fetch_assoc($re)) {
       // $edit = "<a href='staff_prospect_management_edit.php?id=" . $rt['id'] . "'data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg' >  </a>";
        $details = "<a href='staff_prospect_management_details.php?id=" . $rt['id'] . "'   data-toggle='tooltip' data-placement='top' title='Details' class='far fa-eye fa-lg'> </a>";

        $data[] = array(
            'srno' => $i++,
            'operation' => $details,
            'name' => $rt['name'],
            'mobile' => $rt['mobile'],
            'email' => $rt['email'],
            'source' => $rt['source'],
            'city' => $rt['city'],
            'country' => $rt['country'],
            'status' => ucfirst($rt['status']),
        );
    }
    $response['data'] = $data;
    echo stripslashes(json_encode(array('data' => $data)));
    mysqli_close($conn);
    return;
} else {
    $result = "0";
    $msg = "Invalid Error";

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

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