<?php

session_start();



if (!isset($_SESSION['tulsilogin'])) {

    header('Location: index.php');

    return;

}



include("connect.php");



if (isset($_POST['bulk_allocation_checkbox']) && is_array($_POST['bulk_allocation_checkbox']) && count($_POST['bulk_allocation_checkbox']) && isset($_POST['staff'])) {

    $staffID = $_POST['staff'];

    $bulkAllocationCheckbox = implode(",", $_POST['bulk_allocation_checkbox']);



    $updateResProspectManagement = "UPDATE res_prospect_management set staffid='$staffID' WHERE id IN ($bulkAllocationCheckbox)";



    if ($conn->query($updateResProspectManagement) === TRUE) {

        $_SESSION['msg'] = "Record updated successfully";

    } else {

        $_SESSION['msg'] = "Error in record update";

        header('Location: prospect_management_pending_allocation_bulk_assigned.php');

    }

} else {

    $_SESSION['msg'] = "Select staff member and prospect";

    header('Location: prospect_management_pending_allocation_bulk_assigned.php');

}

header('Location: prospect_management.php');

?>