function getIndLeaf($arr_param, $total_count)
{
    global $arr_tolist;
    $arr_result = array();
    $main_flag = false;
    foreach ($arr_param as $key => $value) {
        $flag = false;
        for ($i = 0; $i < $total_count; $i++) {
            if ($arr_tolist[$i][2] == $value) {
                $arr_result[] = $arr_tolist[$i][0];
                $flag = true;
            }
        }
        if ($flag == false) {
            $arr_result = array();
            $arr_result[0] = $value;
            $main_flag = true;
            break;
        }
    }
    if ($main_flag == true) {
        return $arr_result;
    } else {
        return getIndLeaf($arr_result, $total_count);
    }
}
Exemplo n.º 2
0
//echo("<br>arr_main:<br>" . count($arr_main));
//print_r($arr_main);
//departments which are not leaf, but received mails to
$arr_diff = array_diff($arr_deptid, $arr_leafdept);
//trace_function
//echo("<br>arr_diff:<br>" . count($arr_diff));
//print_r($arr_diff);
//This loop fetches the first child leaf node of the dept id
//and adds it to the main array
$cnt = count($arr_diff);
$total_count = count($arr_tolist);
foreach ($arr_diff as $key => $val) {
    //trace_function
    //echo("<br>leaf of " . $val . ":");
    //get the first leaf child of the depratment in $val
    $temp = getIndLeaf(array($val), $total_count);
    //trace_function
    //print_r($temp);
    //echo("<br>");
    $arr_main[] = $temp[0];
}
//get unique id from the list of leaf departments from the main array
$arr_new = array_unique($arr_main);
//Get the company list
$var_companylist = "";
//////////////////////////////////////////////////////////////////////////////////////
if (count($arr_new) > 0) {
    //If mail received to a valid department
    //The company id of the departments is fetched and assigned to the
    //$arr_compid array
    $arr_compid = array();