Esempio n. 1
0
function buildReport($arrData, $smarty, $module_name, $endpoint_mask)
{
    if (getParameter("cancel")) {
        unset($_SESSION["endpoint_configurator"]);
    }
    $nav = isset($_GET['nav']) && $_GET['nav'] != '' ? $_GET['nav'] : (isset($_GET['navpost']) && $_GET['navpost'] != '' ? $_GET['navpost'] : NULL);
    $start = isset($_GET['start']) && $_GET['start'] != '' ? $_GET['start'] : (isset($_GET['startpost']) && $_GET['startpost'] != '' ? $_GET['startpost'] : NULL);
    $ip = $_SERVER['SERVER_ADDR'];
    $devices = subMask($ip);
    $limit = 20;
    $total = count($arrData);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    //$offset = $oGrid->getOffSet($limit,$total,$nav,$start);
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    if ($devices <= 20) {
        $devices = pow(2, 32 - $devices);
        $devices = $devices - 2;
        $smarty->assign("mb_title", _tr('WARNING') . ":");
        $smarty->assign("mb_message", _tr("It can take several minutes, because your ip address has some devices, ") . $devices . _tr("hosts"));
    }
    if ($total <= $limit) {
        $arrDataPorcion = $arrData;
    } else {
        $arrDataPorcion = array_slice($arrData, $offset, $limit);
    }
    $arrGrid = array("title" => _tr("Endpoint Configurator"), "url" => array('menu' => $module_name, 'navpost' => $nav, 'startpost' => $start), "icon" => "/modules/{$module_name}/images/pbx_endpoint_configurator.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => "<input type='submit' name='endpoint_set' value='" . _tr('Set') . "' class='button' onclick=\" return confirmSubmit('" . _tr("Are you sure you wish to set endpoint(s)?") . "');\" />", "property1" => ""), 1 => array("name" => "<input type='submit' name='endpoint_unset' value='" . _tr('Unset') . "' class='button' onclick=\" return confirmSubmit('" . _tr("Are you sure you wish to unset endpoint(s)?") . "');\" />", "property1" => ""), 2 => array("name" => _tr("MAC Adress"), "property1" => ""), 3 => array("name" => _tr("IP Adress"), "property1" => ""), 4 => array("name" => _tr("Vendor"), "property1" => ""), 5 => array("name" => _tr("Phone Type"), "property1" => ""), 6 => array("name" => _tr("User Extension"), "property1" => ""), 7 => array("name" => _tr("Current Extension"), "property1" => "")));
    /* $html_filter = "<input type='submit' name='endpoint_scan' value='"._tr('Discover Endpoints in this Network')."' class='button' />";
       $html_filter.= "&nbsp;&nbsp;<input type='text' name='endpoint_mask' value='$endpoint_mask' style='width:130px;' />";*/
    $oGrid->addInputTextAction("endpoint_mask", _tr('Discover Endpoints in this Network'), $endpoint_mask, 'endpoint_scan');
    //$oGrid->showFilter($html_filter,true);
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrDataPorcion);
    return $contenidoModulo;
}