<?php
$msg = '';
include("include/settings.php");
include("checksession.php");

if (isset($_POST['action_for']) && !empty($_POST['action_for']) && ($_POST['action_for'] == 'lead_allocate')) {

    $ar_leadID = array();

    if (isset($_POST['action_type']) && !empty($_POST['action_type'])) {

        if ($_POST['action_type'] == 'single') {

            if (isset($_POST['lead_id']) && !empty($_POST['lead_id'])) {

                array_push($ar_leadID, $_POST['lead_id']);
            }
        }

        if ($_POST['action_type'] == 'multiple') {

            if (isset($_POST['lead_id']) && !empty($_POST['lead_id'])) {

                $ar_leadID = $_POST['lead_id'];
            }
        }
    }

    $executive_id = 0;
    if (isset($_POST['executive_id']) && !empty($_POST['executive_id'])) {

        $executive_id = $_POST['executive_id'];
    }

    if (!empty($executive_id) && !empty($ar_leadID)) {

        foreach ($ar_leadID as $key => $value) {

            $update_query = "UPDATE rishta_leadmaster SET lead_allocated_to = " . $executive_id . " WHERE lead_id = " . $value . "  ";
            $resultData = $mysqli->prepare($update_query);
            $resultData->execute();
            $resultData->close();
        }
    }
}
?>