Esempio n. 1
0
function listarUsuarios($pDB, $smarty, $module_name, $local_templates_dir)
{
    global $arrLang;
    $oUsuarios = new UsuariosECCP($pDB);
    $smarty->assign(array('MODULE_NAME' => $module_name, 'LABEL_CREATE_USER' => _tr('New ECCP User')));
    // Manejar posible borrado de agentes
    if (isset($_POST['delete']) && isset($_POST['id']) && ctype_digit($_POST['id'])) {
        $bExito = $oUsuarios->borrarUsuario($_POST['id']);
        if (!$bExito) {
            $smarty->assign(array('mb_title' => _tr('Error when deleting user'), 'mb_message' => $oUsuarios->errMsg));
        }
    }
    // Listar todos los agentes
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit(50);
    $oGrid->setTotal($oUsuarios->contarUsuarios());
    $offset = $oGrid->calculateOffset();
    $listaAgentes = $oUsuarios->listarUsuarios(NULL, $offset, $oGrid->getLimit());
    $arrData = array();
    foreach ($listaAgentes as $t) {
        $arrData[] = array('<input type="radio" name="id" value="' . $t['id'] . '" />', htmlentities($t['username'], ENT_COMPAT, 'UTF-8'), '<a href="?menu=' . $module_name . '&amp;action=edit_user&amp;id=' . $t['id'] . '">[' . _tr('Edit') . ']</a>');
    }
    $url = construirURL(array('menu' => $module_name), array('nav', 'start'));
    $arrGrid = array("title" => _tr('ECCP User List'), "url" => $url, "icon" => 'images/user.png', "width" => "99%", "columns" => array(0 => array("name" => '<input type="submit" class="button" name="delete" value="' . htmlentities(_tr('Delete'), ENT_COMPAT, 'UTF-8') . '" onclick="return confirmSubmit(' . "'" . htmlentities(_tr('Are you sure to delete this user?'), ENT_COMPAT, 'UTF-8') . "'" . ')" />'), 1 => array("name" => _tr('Name')), 2 => array("name" => _tr('Options'))));
    $oGrid->showFilter($smarty->fetch("{$local_templates_dir}/filter-list-users.tpl"));
    $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    if (strpos($sContenido, '<form') === FALSE) {
        $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
    }
    return $sContenido;
}
Esempio n. 2
0
function listPackages($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $oPackages = new PaloSantoPackages($arrConf['ruta_yum']);
    $submitInstalado = getParameter('submitInstalado');
    $nombre_paquete = getParameter('nombre_paquete');
    $smarty->assign(array('module_name' => $module_name, 'RepositoriesUpdate' => _tr('Repositories Update'), 'Search' => _tr('Search'), 'UpdatingRepositories' => _tr('Updating Repositories'), 'InstallPackage' => _tr('Installing Package'), 'UpdatePackage' => _tr('Updating Package'), 'accionEnProceso' => _tr('There is an action in process'), 'msgConfirmDelete' => _tr('You will uninstall package along with everything what it depends on it. System can lose important functionalities or become unstable! Are you sure want to Uninstall?'), 'msgConfirmInstall' => _tr('Are you sure want to Install this package?'), 'UninstallPackage' => _tr('Uninstalling Package'), 'msgConfirmUpdate' => _tr('Are you sure want to Update this package?')));
    $arrPaquetes = $oPackages->listarPaquetes($submitInstalado == 'all' ? 'all' : 'installed', $nombre_paquete);
    if ($oPackages->bActualizar) {
        $smarty->assign("mb_title", _tr("Message"));
        $smarty->assign("mb_message", _tr("The repositories are not up to date. Click on the") . " <b>\"" . _tr('Repositories Update') . "\"</b> " . _tr("button to list all available packages."));
    }
    // Pagination
    $limit = 20;
    $total = count($arrPaquetes);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $arrPaquetes = array_slice($arrPaquetes, $offset, $limit);
    $arrData = array();
    foreach ($arrPaquetes as $paquete) {
        $packageActions = array();
        $tmpPaquete = $paquete['name'] . '.' . $paquete['arch'];
        if ($paquete['canupdate']) {
            $packageActions[] = "<a href='#'  onclick=" . "confirmUpdate('{$tmpPaquete}')" . ">[" . _tr('Update') . "]</a>";
        }
        if (is_null($paquete['version'])) {
            $packageActions[] = "<a href='#'  onclick=" . "installaPackage('{$tmpPaquete}',0)" . ">[" . _tr('Install') . "]</a>";
        } else {
            $packageActions[] = "<a href='#'  onclick=" . "confirmDelete('{$tmpPaquete}')" . ">[" . _tr('Uninstall') . "]</a>";
        }
        $rowData = array($paquete['name'], $paquete['arch'], $paquete['summary'], is_null($paquete['version']) ? _tr('(not installed)') : $paquete['version'] . '-' . $paquete['release'], is_null($paquete['latestversion']) ? _tr('(not available)') : $paquete['latestversion'] . '-' . $paquete['latestrelease'], $paquete['repo'], implode('&nbsp;', $packageActions));
        if ($paquete['canupdate']) {
            $rowData[0] = '<b>' . $rowData[0] . '</b>';
            $rowData[4] = '<b>' . $rowData[4] . '</b>';
        }
        $arrData[] = $rowData;
    }
    $url = array('menu' => $module_name, 'submitInstalado' => $submitInstalado, 'nombre_paquete' => $nombre_paquete);
    $arrGrid = array("title" => _tr('Packages'), "icon" => "web/apps/{$module_name}/images/system_updates_packages.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(array("name" => _tr("Package Name")), array("name" => _tr("Architecture")), array("name" => _tr("Package Info")), array('name' => _tr('Current Version')), array('name' => _tr('Available Version')), array("name" => _tr("Repositor Place")), array("name" => _tr("Status"))));
    /*Inicio Parte del Filtro*/
    $arrFilter = filterField();
    $oFilterForm = new paloForm($smarty, $arrFilter);
    if (getParameter('submitInstalado') == 'all') {
        $arrFilter["submitInstalado"] = 'all';
        $tipoPaquete = _tr('All Package');
    } else {
        $arrFilter["submitInstalado"] = 'installed';
        $tipoPaquete = _tr('Package Installed');
    }
    $arrFilter["nombre_paquete"] = $nombre_paquete;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Status") . " =  {$tipoPaquete}", $arrFilter, array("submitInstalado" => "installed"), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = {$nombre_paquete}", $arrFilter, array("nombre_paquete" => ""));
    $oGrid->addButtonAction('update_repositorios', _tr('Repositories Update'), null, 'mostrarReloj()');
    $oGrid->showFilter($oFilterForm->fetchForm("{$local_templates_dir}/new.tpl", '', $arrFilter));
    return $oGrid->fetchGrid($arrGrid, $arrData);
}
Esempio n. 3
0
function listFax($smarty, $module_name, $local_templates_dir)
{
    $limit = 30;
    $oFax = new paloFax();
    $total = $oFax->getTotalFax();
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->pagingShow(true);
    $oGrid->setURL("?menu=faxlist");
    $oGrid->setTitle(_tr("Virtual Fax List"));
    $oGrid->setIcon("/modules/{$module_name}/images/fax_virtual_fax_list.png");
    $arrColumns = array(_tr("Virtual Fax Name"), _tr("Fax Extension"), _tr("Secret"), _tr("Destination Email"), _tr("Caller ID Name"), _tr("Caller ID Number"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    $offset = $oGrid->calculateOffset();
    $arrFax = $oFax->getFaxList($offset, $limit);
    $arrFaxStatus = $oFax->getFaxStatus();
    $arrData = array();
    foreach ($arrFax as $fax) {
        $arrTmp = array();
        $arrTmp[0] = "&nbsp;<a href='?menu=faxnew&action=view&id=" . $fax['id'] . "'>" . $fax['name'] . "</a>";
        $arrTmp[1] = $fax['extension'];
        $arrTmp[2] = $fax['secret'];
        $arrTmp[3] = $fax['email'];
        $arrTmp[4] = $fax['clid_name'] . "&nbsp;";
        $arrTmp[5] = $fax['clid_number'] . "&nbsp;";
        $arrTmp[6] = $arrFaxStatus['modems']['ttyIAX' . $fax['dev_id']] . ' on ttyIAX' . $fax['dev_id'];
        $arrData[] = $arrTmp;
    }
    $session = getSession();
    $session['faxlist']['faxListStatus'] = $arrData;
    putSession($session);
    $oGrid->setData($arrData);
    return $oGrid->fetchGrid();
}
Esempio n. 4
0
function reportTelefonosinactivos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pTelefonosinactivos = new paloSantoTelefonosinactivos($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Teléfonos inactivos"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Teléfonos inactivos"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Cliente"), _tr("Cédula"), _tr("Descripción"), _tr("Telefono"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pTelefonosinactivos->getNumTelefonosinactivos($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 200;
        // Default 20
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pTelefonosinactivos->getTelefonosinactivos($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['cliente'];
            $arrTmp[1] = $value['ci'];
            $arrTmp[2] = $value['descripcion'];
            $arrTmp[3] = $value['telefono'];
            $arrTmp[4] = "<a href=index.php?menu={$module_name}&id={$value['id']}&action=activar>Activar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 5
0
function reportDHCP_Configuration($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pDHCP_Configuration = new paloSantoDHCP_Configuration($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $action = getParameter("nav");
    $start = getParameter("start");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $nameOpt = array("hostname" => _tr('Host Name'), "ipaddress" => _tr('IP Address'), "macaddress" => _tr('MAC Address'));
    if (isset($nameOpt[$filter_field])) {
        $valorFiltro = $nameOpt[$filter_field];
    } else {
        $valorFiltro = "";
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . " " . $valorFiltro . " = {$filter_value}", $_POST, array("filter_field" => "hostname", "filter_value" => ""));
    $totalDHCP_Configuration = $pDHCP_Configuration->contarIpFijas($filter_field, $filter_value);
    $oGrid->addNew("new_dhcpconft", _tr("Assign IP Address"));
    $oGrid->deleteList("Are you sure you wish to delete the DHCP configuration.", "delete_dhcpConf", _tr("Delete"));
    $limit = 20;
    $total = $totalDHCP_Configuration;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->calculatePagination($action, $start);
    $offset = $oGrid->getOffsetValue();
    $end = $oGrid->getEnd();
    $arrData = null;
    $arrResult = $pDHCP_Configuration->leerIPsFijas($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = "<input type='checkbox' name='DhcpConfID_{$value['id']}' />";
            $arrTmp[1] = "<a href='?menu={$module_name}&action=view_dhcpconf&id=" . $value['id'] . "'>" . $value['hostname'] . "</a>";
            $arrTmp[2] = $value['ipaddress'];
            $arrTmp[3] = $value['macaddress'];
            $arrData[] = $arrTmp;
        }
    }
    $buttonDelete = "";
    $arrGrid = array("title" => _tr('Assign IP Address to Host'), "icon" => "web/apps/{$module_name}/images/system_network_assign_ip_address.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => array('menu' => $module_name, 'filter_field' => $filter_field, 'filter_value' => $filter_value), "columns" => array(0 => array("name" => $buttonDelete, "property1" => ""), 1 => array("name" => _tr('Host Name'), "property1" => ""), 2 => array("name" => _tr('IP Address'), "property1" => ""), 3 => array("name" => _tr('MAC Address'), "property1" => "")));
    //begin section filter
    $arrFormFilterDHCP_Configuration = createFieldFilter();
    $oFilterForm = new paloForm($smarty, $arrFormFilterDHCP_Configuration);
    $smarty->assign("SHOW", _tr('Show'));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
    //end grid parameters
    return $contenidoModulo;
}
Esempio n. 6
0
function reportListadodecampañas($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodecampañas = new paloSantoListadodecampañas($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de bases recargables"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de campañas"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Nombre"), _tr("Campania"), _tr("Fecha Inicial"), _tr("Fecha Final"), _tr("# de Clientes"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodecampañas->getNumListadodecampañas($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodecampañas->getListadodecampañas($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrBasesAgentes = $pListadodecampañas->getBasesAgentes($value['id']);
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = $value['campania'];
            $arrTmp[2] = $value['fecha_inicio'];
            $arrTmp[3] = $value['fecha_fin'];
            $arrTmp[4] = $value['clientes'];
            if ($value['status'] == "A") {
                $arrTmp[5] = "<a href=index.php?menu=hispana_listado_recarga&action=inactivar&id=" . $value['id'] . ">Inactivar</a>";
            } else {
                $arrTmp[5] = "<a href=index.php?menu=hispana_listado_recarga&action=activar&id=" . $value['id'] . ">Activar</a>";
            }
            $arrTmp[5] = $arrTmp[5] . "/ <a href=index.php?menu=hispana_base_recarga&edit_base=si&id_base=" . $value['id_base'] . "&id_campania=" . $value['id_campania'] . ">Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 7
0
function reportListadodecampañas($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodecampañas = new paloSantoListadodecampañas($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de Reportes Offline"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de Reportes Offline"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campania"), _tr("Tipo"), _tr("Status"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodecampañas->getNumListadodecampañas($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodecampañas->getListadodecampañas($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            //$arrBasesAgentes = $pListadodecampañas->getBasesAgentes($value['id']);
            $arrTmp[0] = $value['nombre'];
            $arrTmp[1] = $value['tipo'];
            if ($value['status'] == "I") {
                $arrTmp[2] = "En Proceso";
                $arrTmp[3] = "";
            } else {
                $arrTmp[2] = "Finalizado";
                $arrTmp[3] = "<a href=" . $value['ruta'] . ">Descargar</a>";
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 8
0
function listRepositories($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $oRepositories = new PaloSantoRepositories();
    $arrReposActivos = array();
    $typeRepository = getParameter("typeRepository");
    if (isset($_POST['submit_aceptar'])) {
        foreach ($_POST as $key => $value) {
            if (substr($key, 0, 5) == 'repo-') {
                $arrReposActivos[] = substr($key, 5);
            }
        }
        $oRepositories->setRepositorios($arrConf['ruta_repos'], $arrReposActivos, $typeRepository, $arrConf["main_repos"]);
    }
    $option["main"] = "";
    $option["others"] = "";
    $option["all"] = "";
    $arrRepositorios = $oRepositories->getRepositorios($arrConf['ruta_repos'], $typeRepository, $arrConf["main_repos"]);
    $limit = 40;
    $total = count($arrRepositorios);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $arrData = array();
    $version = $oRepositories->obtenerVersionDistro();
    $arch = $oRepositories->obtenerArquitectura();
    if (is_array($arrRepositorios)) {
        for ($i = $offset; $i < $end; $i++) {
            $activo = "";
            if ($arrRepositorios[$i]['activo']) {
                $activo = "checked='checked'";
            }
            $arrData[] = array("<input {$activo} name='repo-" . $arrRepositorios[$i]['id'] . "' type='checkbox' id='repo-{$i}' />", $valor = str_replace(array("\$releasever", "\$basearch"), array($version, $arch), $arrRepositorios[$i]['name']));
        }
    }
    if (isset($typeRepository)) {
        $oGrid->setURL("?menu={$module_name}&typeRepository={$typeRepository}");
        $_POST["typeRepository"] = $typeRepository;
    } else {
        $oGrid->setURL("?menu={$module_name}");
        $_POST["typeRepository"] = "main";
    }
    $arrGrid = array("title" => _tr("Repositories"), "icon" => "web/apps/{$module_name}/images/system_updates_repositories.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => _tr("Active"), "property1" => ""), 1 => array("name" => _tr("Name"), "property1" => "")));
    $oGrid->customAction('submit_aceptar', _tr('Save/Update'));
    $oGrid->addButtonAction("default", _tr('Default'), null, "defaultValues({$total},'{$version}','{$arch}')");
    $FilterForm = new paloForm($smarty, createFilter());
    $arrOpt = array("main" => _tr('Main'), "others" => _tr('Others'), "all" => _tr('All'));
    if (isset($arrOpt[$typeRepository])) {
        $valorfiltro = $arrOpt[$typeRepository];
    } else {
        $valorfiltro = _tr('Main');
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Repo") . " = " . $valorfiltro, $_POST, array("typeRepository" => "main"), true);
    $htmlFilter = $FilterForm->fetchForm("{$local_templates_dir}/new.tpl", "", $_POST);
    $oGrid->showFilter($htmlFilter);
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
    return $contenidoModulo;
}
Esempio n. 9
0
function reportListadodebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodebases = new paloSantoListadodebases($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de bases"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de bases"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Base"), _tr("CI"), _tr("Nombre"), _tr("Apellido"), _tr("Provincia"), _tr("Ciudad"), _tr("Nacimiento"), _tr("Correo personal"), _tr("Correo trabajo"), _tr("Estado civil"), _tr("Action"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodebases->getNumListadodebases($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        //$limit  = 20;
        $limit = 200;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodebases->getListadodebases($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['base'];
            $arrTmp[1] = $value['ci'];
            $arrTmp[2] = $value['nombre'];
            $arrTmp[3] = $value['apellido'];
            $arrTmp[4] = $value['provincia'];
            $arrTmp[5] = $value['ciudad'];
            $arrTmp[6] = $value['nacimiento'];
            $arrTmp[7] = $value['correo_personal'];
            $arrTmp[8] = $value['correo_trabajo'];
            $arrTmp[9] = $value['estado_civil'];
            $arrTmp[10] = "<a href='?menu=hispana_clientes_datosbasicos&ci=" . $value['ci'] . "'>Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 10
0
function reportReporteGeneraldeGestión($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pReporteGeneraldeGestión = new paloSantoReporteGeneraldeGestión($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Reporte General de Gestión"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Reporte General de Gestión"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Cliente"), _tr("CI"), _tr("Teléfono"), _tr("Agente"), _tr("Calltype"), _tr("Fecha"), _tr("Audio"));
    $oGrid->setColumns($arrColumns);
    $total = $pReporteGeneraldeGestión->getNumReporteGeneraldeGestión($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pReporteGeneraldeGestión->getReporteGeneraldeGestión($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['cliente'];
            $arrTmp[2] = $value['cedula'];
            $arrTmp[3] = $value['telefono'];
            $arrTmp[4] = $value['agente'];
            $arrTmp[5] = $value['calltype'];
            $arrTmp[6] = $value['fecha'];
            if (stripos($value['calltype'], "contactado") >= 0) {
                $arrTmp[7] = "<a href=monitoring_translator.php?action=download&id=" . $value['timestamp'] . "&rawmode=yes>Descargar</a>";
            }
            //$arrTmp[7] = "";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 11
0
function reportIncomingcallsmonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang)
{
    $pIncomingcallsmonitoring = new paloSantoIncomingcallsmonitoring($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $action = getParameter("nav");
    $start = getParameter("start");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $totalIncomingcallsmonitoring = $pIncomingcallsmonitoring->ObtainNumIncomingcallsmonitoring($filter_field, $filter_value);
    $limit = 20;
    $total = $totalIncomingcallsmonitoring;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->calculatePagination($action, $start);
    $offset = $oGrid->getOffsetValue();
    $end = $oGrid->getEnd();
    $url = "?menu={$module_name}&filter_field={$filter_field}&filter_value={$filter_value}";
    $arrData = null;
    $arrResult = $pIncomingcallsmonitoring->ObtainIncomingcallsmonitoring($limit, $offset, $arrLang, $filter_field, $filter_value);
    if (is_array($arrResult)) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['queue'];
            $arrTmp[1] = isset($value['entered']) ? $value['entered'] : "0";
            $arrTmp[2] = isset($value['answered']) ? $value['answered'] : "0";
            $arrTmp[3] = isset($value['abandoned']) ? $value['abandoned'] : "0";
            $arrTmp[4] = isset($value['waiting_calls']) ? $value['waiting_calls'] : "0";
            $arrTmp[5] = isset($value['without_monitoring']) ? $value['without_monitoring'] : "0";
            $arrData[] = $arrTmp;
        }
    }
    $arrGrid = array("title" => $arrLang["Incoming calls monitoring"], "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(0 => array("name" => $arrLang["Queue"], "property1" => ""), 1 => array("name" => $arrLang["Entered"], "property1" => ""), 2 => array("name" => $arrLang["Answered"], "property1" => ""), 3 => array("name" => $arrLang["Abandoned"], "property1" => ""), 4 => array("name" => $arrLang["Waiting calls"], "property1" => ""), 5 => array("name" => $arrLang["Without monitoring"], "property1" => "")));
    //begin section filter
    $arrFormFilterIncomingcallsmonitoring = createFieldFilter($arrLang);
    $oFilterForm = new paloForm($smarty, $arrFormFilterIncomingcallsmonitoring);
    //     $smarty->assign("SHOW", $arrLang["Show"]);
    //     $htmlFilter = $oFilterForm->fetchForm("$local_templates_dir/filter.tpl","",$_POST);
    //end section filter
    //     $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    if (strpos($content, '<form') === FALSE) {
        $content = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
    }
    $sReloadScript = <<<SCRIPT_RELOAD
<script>
function reload() {
    xajax_create_report();
    setTimeout("reload()",5000);
}
reload();
</script>
SCRIPT_RELOAD;
    $content = $sReloadScript . $content;
    return $content;
}
Esempio n. 12
0
function reportDhcpClientlist($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pDhcpClientlist = new paloSantoDhcpClienList($pDB);
    $filter_field = "";
    $filter_value = "";
    $action = getParameter("nav");
    $start = getParameter("start");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $limit = 20;
    $arrResult = $pDhcpClientlist->getDhcpClientList();
    $total = count($arrResult);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->calculatePagination($action, $start);
    $offset = $oGrid->getOffsetValue();
    $end = $oGrid->getEnd();
    $url = "?menu={$module_name}";
    $arrData = null;
    if (is_array($arrResult) && count($arrResult) > 0) {
        for ($i = 1; $i <= $total; $i++) {
            //$arrTmp[0]  = "<input type='checkbox' name='DhcpListID_$i'  />";
            //          $arrTmp[1] = "<a href='?menu=$module_name&action=show&id=".$id."'>".$arrResult[$id]['iphost']."</a>";
            $arrTmp[0] = "" . $arrResult[$i]['iphost'];
            $arrTmp[1] = "" . $arrResult[$i]['macaddress'];
            $arrTmp[2] = "<a href='?menu={$module_name}&action=see_dhcpclient&id=" . $i . "'>" . _tr("View Details") . "</a>";
            $arrData[] = $arrTmp;
        }
    }
    $buttonDelete = "<input type='submit' name='delete_dhcpclient' value='" . _tr("Delete") . "' class='button' onclick=\" return confirmSubmit('" . _tr("Are you sure you wish to delete the Ip.") . "');\" />";
    $arrGrid = array("title" => _tr("DHCP Client List"), "icon" => "web/apps/{$module_name}/images/system_network_dhcp_client_list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(0 => array("name" => _tr("IP Address"), "property1" => ""), 1 => array("name" => _tr("MAC Address"), "property1" => ""), 2 => array("name" => _tr("Action"), "property1" => "")));
    //begin section filter
    // $arrFormFilterDhcplist = createFieldFilter();
    // $oFilterForm = new paloForm($smarty, $arrFormFilterDhcplist);
    //     $smarty->assign("SHOW", _tr("Show"));
    $smarty->assign("NEW_DHCPCLIENT", _tr("New Dhcp client"));
    //  $htmlFilter = $oFilterForm->fetchForm("$local_templates_dir/filter.tpl","",$_POST);
    //end section filter
    //  $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
    if (strpos($contenidoModulo, '<form') === FALSE) {
        $contenidoModulo = "<form  method='POST' style='margin-bottom:0;' action={$url}>{$contenidoModulo}</form>";
    }
    //end grid parameters
    return $contenidoModulo;
}
Esempio n. 13
0
function listURL($pDB, $smarty, $module_name, $local_templates_dir)
{
    $urls = new externalUrl($pDB);
    $grid = new paloSantoGrid($smarty);
    $dtypes = descOpenType();
    // para el pagineo
    $grid->setLimit(15);
    $grid->setTotal($urls->countURLs());
    $offset = $grid->calculateOffset();
    $listaUrls = $urls->getURLs($grid->getLimit(), $grid->getOffsetValue());
    $data = array();
    foreach ($listaUrls as $tuplaUrl) {
        $data[] = array($tuplaUrl['active'] ? _tr('Yes') : _tr('No'), $dtypes[$tuplaUrl['opentype']], htmlentities($tuplaUrl['urltemplate'], ENT_COMPAT, 'UTF-8'), htmlentities($tuplaUrl['description'], ENT_COMPAT, 'UTF-8'), "<a href='?menu={$module_name}&amp;action=edit_url&amp;id_url=" . $tuplaUrl['id'] . "'>[" . _tr('Edit') . "]</a>");
    }
    //$grid->addNew("?menu=$module_name&action=new_url", _tr('New URL'), true);
    $grid->showFilter("<div align=\"right\"><a href=\"?menu={$module_name}&action=new_url\"><b>" . _tr('New URL') . "&raquo;</b></a></div>");
    $grid->setTitle(_tr('External URLs'));
    $grid->setColumns(array(_tr('Active'), _tr('Opens in'), _tr('URL Template'), _tr('Description'), _tr('Options')));
    $grid->setData($data);
    return $grid->fetchGrid();
}
Esempio n. 14
0
function reportMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pEmailList = new paloSantoEmailList($pDB);
    $id_list = getParameter("id");
    if ($credentials['userlevel'] == 'superadmin') {
        $emailList = $pEmailList->getEmailList($id_list);
    } else {
        $emailList = $pEmailList->getEmailList($id_list, $credentials['domain']);
    }
    if ($emailList == false) {
        $smarty->assign("mb_title", _tr("Error"));
        $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist");
        $smarty->assign("mb_message", $error);
        return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $field_type = getParameter("filter_type");
    $field_pattern = getParameter("filter_txt");
    $smarty->assign("IDEMAILLIST", $id_list);
    $smarty->assign("ACTION", 'view_memberlist');
    $smarty->assign("SHOW", _tr("Show"));
    $smarty->assign("RETURN", _tr("Return"));
    $smarty->assign("LINK", "?menu={$module_name}&action=export&id={$id_list}&rawmode=yes");
    $smarty->assign("EXPORT", _tr("Export Members"));
    $edit_permission = in_array('edit_list', $arrPermission);
    $totalMembers = $pEmailList->getTotalMembers($id_list);
    $oGrid = new paloSantoGrid($smarty);
    $limit = 20;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($totalMembers);
    $oGrid->setTitle(_tr("List Members of") . " " . $pEmailList->getListName($id_list));
    $oGrid->setIcon("web/apps/{$module_name}/images/email.png");
    $oGrid->pagingShow(true);
    $offset = $oGrid->calculateOffset();
    $url['menu'] = $module_name;
    $url['action'] = 'view_memberlist';
    $url['id'] = $id_list;
    $url['filter_type'] = $field_type;
    $url['filter_txt'] = $field_pattern;
    $oGrid->setURL($url);
    if ($edit_permission) {
        $arrColumns[] = '';
    }
    $arrColumns[] = _tr("Member name");
    $arrColumns[] = _tr("Member email");
    $oGrid->setColumns($arrColumns);
    $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern);
    $arrData = null;
    //print_r($arrResult);
    if (is_array($arrResult) && $totalMembers > 0) {
        foreach ($arrResult as $list) {
            $arrTmp = array();
            if ($edit_permission) {
                $arrTmp[] = "<input type='checkbox' name='del_emailmembers[{$list["mailmember"]}]'>";
            }
            $arrTmp[] = $list["namemember"];
            $arrTmp[] = $list["mailmember"];
            $arrData[] = $arrTmp;
        }
    }
    $arrFormFilterMembers = createFieldFilterViewMembers();
    $oFilterForm = new paloForm($smarty, $arrFormFilterMembers);
    $arrType = array("name" => _tr("Name"), "email" => _tr("Email"));
    if (!is_null($field_type)) {
        $nameField = $arrType[$field_type];
    } else {
        $nameField = "";
    }
    $oGrid->customAction("return", _tr("Return"));
    if ($edit_permission) {
        $oGrid->addNew("new_memberlist", _tr("Add Member(s) to List"));
        $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."), "remove_memberlist", _tr("Delete"));
    }
    $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . $nameField . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/view_members.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid(array(), $arrData);
    return $content;
}
Esempio n. 15
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoForm.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoTrunk.class.php";
    require_once "libs/misc.lib.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $contenido = '';
    $msgError = '';
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk";
    $pDB = new paloDB($dsn);
    $pDBSetting = new paloDB($arrConf['elastix_dsn']['settings']);
    $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']);
    $arrForm = array("default_rate" => array("LABEL" => $arrLang["Default Rate"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""), "default_rate_offset" => array("LABEL" => $arrLang["Default Rate Offset"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""));
    $oForm = new paloForm($smarty, $arrForm);
    $oForm->setViewMode();
    //obtener el valor de la tarifa por defecto
    $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate");
    $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset");
    $smarty->assign("EDIT", $arrLang["Edit"]);
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
    if (isset($_POST['edit_default'])) {
        $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate");
        $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset");
        $oForm = new paloForm($smarty, $arrForm);
        $smarty->assign("CANCEL", $arrLang["Cancel"]);
        $smarty->assign("SAVE", $arrLang["Save"]);
        $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
        $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
    } else {
        if (isset($_POST['save_default'])) {
            $oForm = new paloForm($smarty, $arrForm);
            $arrDefaultRate['default_rate'] = $_POST['default_rate'];
            $arrDefaultRate['default_rate_offset'] = $_POST['default_rate_offset'];
            if ($oForm->validateForm($_POST)) {
                $bValido = set_key_settings($pDBSetting, 'default_rate', $arrDefaultRate['default_rate']);
                $bValido = set_key_settings($pDBSetting, 'default_rate_offset', $arrDefaultRate['default_rate_offset']);
                if (!$bValido) {
                    echo $arrLang["Error when saving default rate"];
                } else {
                    header("Location: index.php?menu=billing_setup");
                }
            } else {
                // Error
                $smarty->assign("mb_title", $arrLang["Validation Error"]);
                $smarty->assign("mb_message", $arrLang["Value for rate is not valid"]);
                $smarty->assign("CANCEL", $arrLang["Cancel"]);
                $smarty->assign("SAVE", $arrLang["Save"]);
                $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
                $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
            }
        }
    }
    $arrTrunks = array();
    $arrData = array();
    $arrTrunksBill = array();
    //obtener todos los trunks
    $oTrunk = new paloTrunk($pDBTrunk);
    //obtener todos los trunks que son para billing
    //$arrTrunksBill=array("DAHDI/g0","DAHDI/g1");
    getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill);
    if (isset($_POST['submit_bill_trunks'])) {
        //obtengo las que estan guardadas y las que ahora no estan
        $selectedTrunks = isset($_POST['trunksBills']) ? array_keys($_POST['trunksBills']) : array();
        if (count($selectedTrunks) > 0) {
            foreach ($selectedTrunks as $selectedTrunk) {
                $nuevaListaTrunks[] = base64_decode($selectedTrunk);
            }
        } else {
            $nuevaListaTrunks = array();
        }
        $listaTrunksNuevos = array_diff($nuevaListaTrunks, $arrTrunksBill);
        $listaTrunksAusentes = array_diff($arrTrunksBill, $nuevaListaTrunks);
        //tengo que borrar los trunks ausentes
        //tengo que agregar los trunks nuevos
        // print_r($listaTrunksNuevos);
        //print_r($listaTrunksAusentes);
        if (count($listaTrunksAusentes) > 0) {
            $bExito = $oTrunk->deleteTrunksBill($listaTrunksAusentes);
            if (!$bExito) {
                $msgError = $oTrunk->errMsg;
            }
        }
        if (count($listaTrunksNuevos) > 0) {
            $bExito = $oTrunk->saveTrunksBill($listaTrunksNuevos);
            if (!$bExito) {
                $msgError .= $oTrunk->errMsg;
            }
        }
        if (!empty($msgError)) {
            $smarty->assign("mb_message", $msgError);
        }
    }
    getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill);
    $end = count($arrTrunks);
    if (is_array($arrTrunks)) {
        foreach ($arrTrunks as $trunk) {
            $arrTmp = array();
            $checked = in_array($trunk[1], $arrTrunksBill) ? "checked" : "";
            $arrTmp[0] = "<input type='checkbox' name='trunksBills[" . base64_encode($trunk[1]) . "]' {$checked}>";
            $arrTmp[1] = $trunk[1];
            $arrData[] = $arrTmp;
        }
    }
    $arrGrid = array("title" => $arrLang["Trunk Bill Configuration"], "icon" => "/modules/{$module_name}/images/reports_billing_setup.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Trunk"], "property1" => "")));
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->pagingShow(false);
    $oGrid->customAction('submit_bill_trunks', _tr('Billing Capable'));
    $trunk_config = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    if (strpos($trunk_config, '<form') === FALSE) {
        $trunk_config = "<form style='margin-bottom:0;' method='POST' action='?menu=billing_setup'>{$trunk_config}</form>";
    }
    //mostrar los dos formularios
    $contenido .= $strReturn . $trunk_config;
    return $contenido;
}
Esempio n. 16
0
function report_TicketDelivery($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $img_dir = "modules/{$module_name}/images/";
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Yêu cầu giao vé");
    $oGrid->setTableName("delivery_grid");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("ticket_delivery");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Vé đính kèm", "Ngày nhận tiền", "Xử lý", "Chi tiết", " ");
    $oGrid->setColumns($arrColumns);
    $total = $pTicket_Delivery->getNumTicket_Delivery($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pTicket_Delivery->getTicket_Delivery($limit, $offset, $filter);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            // show files
            $download = '';
            foreach ($value['ticket_attachment'] as $row) {
                $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
                $filename = $row['filename'];
                $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
            }
            $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
            $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '
            <a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
            $print .= '&nbsp;&nbsp;' . $enable;
            // function show base on status
            if ($value['isActive'] == '0') {
                $value['status'] = 'Đã hủy';
            }
            switch ($value['status']) {
                case 'Mới':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                case 'Đang giao':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
                    break;
                case 'Đã nhận tiền':
                    $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
                    break;
                case 'Chờ xử lý':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                default:
                    $function = '';
            }
            // show ticket code
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = '<span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span>';
            $arrTmp[4] = '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a>';
            $arrTmp[5] = $value['pay_amount'];
            $arrTmp[6] = $ticket;
            $arrTmp[7] = showStatus($value['status']);
            $arrTmp[8] = $value['delivery_name'];
            $arrTmp[9] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[10] = $download;
            $arrTmp[11] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[12] = $function;
            $arrTmp[13] = '<a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a>';
            $arrTmp[14] = $print;
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 17
0
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $padress_book = new paloAdressBook($pDB);
    $arrBooker = $padress_book->getBookerList();
    $arrPayment_type = array(0 => 'Khách lẻ không thường xuyên', 1 => 'Khách lẻ thường xuyên', 2 => 'Khách hàng công ty', 3 => 'Khách hàng đại lý');
    $arrComboElements = array("customer_code" => "Mã khách hàng", "firstname" => "Tên khách hàng", "phone" => "Số điện thoại", "email" => "Email", "agent_id" => "Booker", "sale" => "Kinh Doanh", "booker" => "Kế Toán", "type" => "Loại khách hàng");
    $arrFormElements = array("field" => array("LABEL" => "Tìm theo", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value')), "booker" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrBooker, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "payment" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrPayment_type, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", "Tìm");
    $smarty->assign("module_name", $module_name);
    $field = NULL;
    $pattern = NULL;
    $namePattern = NULL;
    if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") {
        $field = $_POST['field'];
        $pattern = "%" . trim($_POST['pattern']) . "%";
        $namePattern = trim($_POST['pattern']);
        //$nameField=$arrComboElements[$field];
        //$agent_id = $_POST['booker'];
        //$payment_type = $_POST['booker'];
    }
    $arrFilter = array("field" => $field, "pattern" => $namePattern);
    $startDate = $endDate = date("Y-m-d H:i:s");
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("HNH_KhachHang");
    $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter);
    $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE);
    $total_datos = $total[0]["total"];
    //Paginacion
    if ($oGrid->isExportAction()) {
        $total = $total_datos;
        $limit = $total;
        $arr_cols = array(0 => array("name" => "Mã KH", "property1" => ""), 1 => array("name" => "Tên khách hàng", "property1" => ""), 2 => array("name" => "Họ/Hình thức", "property1" => ""), 3 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 4 => array("name" => "Email/Liên hệ", "property1" => ""), 5 => array("name" => "Booker", "property1" => ""), 6 => array("name" => "Kinh doanh", "property1" => ""), 7 => array("name" => "Kế toán", "property1" => ""), 8 => array("name" => "Phân loại", "property1" => ""), 9 => array("name" => "Thẻ thành viên", "property1" => ""), 10 => array("name" => "Cách thanh toán", "property1" => ""));
    } else {
        $limit = 20;
        $total = $total_datos;
        $arr_cols = array(0 => array("name" => "", "property1" => ""), 1 => array("name" => "Mã KH", "property1" => ""), 2 => array("name" => "Tên khách hàng", "property1" => ""), 3 => array("name" => "Họ/Hình thức", "property1" => ""), 4 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 5 => array("name" => "Email/Liên hệ", "property1" => ""), 6 => array("name" => "Booker", "property1" => ""), 7 => array("name" => "Kinh doanh", "property1" => ""), 8 => array("name" => "Kế toán", "property1" => ""), 9 => array("name" => "Phân loại", "property1" => ""), 10 => array("name" => "Thẻ thành viên", "property1" => ""), 11 => array("name" => "Cách thanh toán", "property1" => ""), 12 => array("name" => "Lựa chọn", "property1" => ""));
    }
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $inicio = $total == 0 ? 0 : $offset + 1;
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    //Fin Paginacion
    $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE);
    //var_dump($arrResult);die;
    $arrData = null;
    //echo print_r($arrResult,true);
    if (is_array($arrResult) && $total > 0) {
        if ($oGrid->isExportAction()) {
            foreach ($arrResult as $key => $adress_book) {
                $typeContact = "";
                switch ($adress_book['type']) {
                    case '0':
                        $typeContact = "Khách hàng lẽ";
                        break;
                    case '1':
                        $typeContact = "Khách lẽ thường xuyên";
                        break;
                    case '2':
                        $typeContact = 'Khách hàng công ty';
                        break;
                    case '3':
                        $typeContact = "Khách hàng đại lý";
                        break;
                    default:
                        break;
                }
                $phone_list = '';
                if (isset($adress_book['number']) && count($adress_book['number']) > 0) {
                    foreach ($adress_book['number'] as $phone) {
                        $phone_list .= is_null($phone) || trim($phone) == '' ? '' : $phone . '\\n';
                    }
                }
                //SDT column
                $email_list = '';
                if (count($adress_book['email']) > 0) {
                    foreach ($adress_book['email'] as $email) {
                        $email_list .= is_null($email) || trim($email) == '' ? '' : $email . '\\n';
                    }
                }
                $arrTmp[] = $adress_book['customer_code'];
                //Ten column
                $arrTmp[] = $adress_book['firstname'];
                //Ten column
                $arrTmp[] = $adress_book['lastname'];
                //Ten column
                $arrTmp[] = $phone_list;
                $arrTmp[] = $email_list;
                $arrTmp[] = $adress_book['booker'];
                $arrTmp[] = $adress_book['sale'];
                $arrTmp[] = $adress_book['accountant'];
                $arrTmp[] = $typeContact;
                $arrTmp[] = $adress_book['membership'];
                $arrTmp[] = $adress_book['payment'];
                $arrData[] = $arrTmp;
            }
        } else {
            foreach ($arrResult as $key => $adress_book) {
                switch ($adress_book['type']) {
                    case '0':
                        $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/nor-customer.png" title="Khách hàng lẽ"/>KLE';
                        break;
                    case '1':
                        $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/fre-customer.png" title="Khách hàng lẽ thường xuyên"/>KLE-TX';
                        break;
                    case '2':
                        $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/company.png" title="Khách hàng công ty"/>CTY';
                        break;
                    case '3':
                        $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/agency.png" title="Khách hàng đại lý"/>DLY';
                        break;
                    default:
                        break;
                }
                $phone_list = '';
                if (isset($adress_book['number']) && count($adress_book['number']) > 0) {
                    foreach ($adress_book['number'] as $phone) {
                        $phone1 = explode('-', $phone);
                        $call = trim($phone1[0]);
                        $phone_list .= is_null($call) || trim($call) == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $call . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $call . "'/></a> " . $phone . '<br/>';
                        //SDT column
                    }
                }
                $email_list = '';
                if (count($adress_book['email']) > 0) {
                    foreach ($adress_book['email'] as $email) {
                        $phone1 = explode('-', $email);
                        $addr = trim($phone1[0]);
                        $email_list .= is_null($addr) || trim($addr) == '' ? '' : '<a title="Gửi mail đến hộp mail này" href="mailto:' . $addr . '?Subject=[CallCenter]:" target="_top">' . $email . '</a><br/>';
                    }
                }
                $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}'  />";
                $arrTmp[1] = $adress_book['customer_code'];
                //Ten column
                $arrTmp[2] = $adress_book['firstname'];
                //Ten column
                $arrTmp[3] = $adress_book['lastname'];
                //Ten column
                $arrTmp[4] = $phone_list;
                $arrTmp[5] = $email_list;
                $arrTmp[6] = $adress_book['booker'];
                $arrTmp[7] = $adress_book['sale'];
                $arrTmp[8] = $adress_book['accountant'];
                $arrTmp[9] = $typeContact;
                $arrTmp[10] = $adress_book['membership'];
                $arrTmp[11] = $adress_book['payment'];
                $arrTmp[12] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/extra.png' title='Xem'></a>&nbsp;\n                <a href='?menu={$module_name}&action=edit&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/edit.png' title='Sửa'></a> ";
                $arrData[] = $arrTmp;
            }
        }
    }
    $oGrid->deleteList("Bạn có muốn xóa khách hàng này không?", "delete", "Xóa");
    $arrGrid = array("title" => "Thông tin khách hàng", "url" => array('menu' => $module_name, 'filter' => $pattern), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => $arr_cols);
    $oGrid->addNew("new", "Thêm khách hàng");
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}
Esempio n. 18
0
function reportTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $name = getParameter('name');
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    //name
    $pTG = new paloSantoTG($pDB, $domain);
    $total = $pTG->getNumTG($domain, $name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => "all");
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pTG->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Time Groups List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Name");
    $oGrid->setColumns($arrColum);
    $arrTG = array();
    $arrData = array();
    if ($total != 0) {
        $arrTG = $pTG->getTGs($domain, $name, $limit, $offset);
    }
    if ($arrTG === false) {
        $error = _tr("Error to obtain Time Groups") . $pTG->errMsg;
        $arrTG = array();
    }
    $arrData = array();
    foreach ($arrTG as $tg) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$tg["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=edit&id_tg=" . $tg['id'] . "&organization={$tg['organization_domain']}'>" . $tg['name'] . "</a>";
        $arrData[] = $arrTmp;
    }
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Time Group"), array_slice($arrOrgz, 1), $selected = null, "create_tg", $onchange_select = null);
            } else {
                $oGrid->addNew("create_tg", _tr("ADD Time Group"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["name"] = $name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Time Condition Group") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Esempio n. 19
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    include_once "modules/{$module_name}/libs/paloSantoCallsDetail.class.php";
    include_once "modules/agent_console/getinfo.php";
    global $arrConf;
    load_language_module($module_name);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // added by Tri Do
    $sAction = getParameter('action');
    switch ($sAction) {
        case 'viewNote':
            return viewNote();
            break;
        case 'viewDelivery':
            return view_delivery();
            break;
        default:
            break;
    }
    // Cadenas estáticas de Smarty
    $smarty->assign(array("Filter" => _tr('Filter'), "SHOW" => _tr("Show")));
    $bElastixNuevo = method_exists('paloSantoGrid', 'setURL');
    // Variables iniciales para posición de grid
    $offset = 0;
    $limit = 50;
    $total = 0;
    // Para poder consultar las colas activas
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $ampconfig = $pConfig->leer_configuracion(false);
    $ampdsn = $ampconfig['AMPDBENGINE']['valor'] . "://" . $ampconfig['AMPDBUSER']['valor'] . ":" . $ampconfig['AMPDBPASS']['valor'] . "@" . $ampconfig['AMPDBHOST']['valor'] . "/asterisk";
    $oQueue = new paloQueue($ampdsn);
    $listaColas = $oQueue->getQueue();
    if (!is_array($listaColas)) {
        $smarty->assign("mb_title", _tr("Error when connecting to database"));
        $smarty->assign("mb_message", $oQueue->errMsg);
    }
    // Para poder consultar los agentes de campañas
    $pDB = new paloDB($cadena_dsn);
    $oCallsDetail = new paloSantoCallsDetail($pDB);
    $listaAgentes = $oCallsDetail->getAgents();
    // Para llenar el select de agentes
    $urlVars = array('menu' => $module_name);
    $arrFormElements = createFieldFilter($listaAgentes, $listaColas);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Validar y aplicar las variables de filtro
    $paramLista = NULL;
    $paramFiltro = array();
    foreach (array('date_start', 'date_end', 'calltype', 'agent', 'queue', 'phone') as $k) {
        $paramFiltro[$k] = getParameter($k);
    }
    if (!isset($paramFiltro['date_start'])) {
        $paramFiltro['date_start'] = date("d M Y");
    }
    if (!isset($paramFiltro['date_end'])) {
        $paramFiltro['date_end'] = date("d M Y");
    }
    if (!$oFilterForm->validateForm($paramFiltro)) {
        // Hay un error al validar las variables del filtro
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oFilterForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>";
        $strErrorMsg = implode(', ', array_keys($arrErrores));
        $smarty->assign("mb_message", $strErrorMsg);
    } else {
        $urlVars = array_merge($urlVars, $paramFiltro);
        $paramLista = $paramFiltro;
        $paramLista['date_start'] = translateDate($paramFiltro['date_start']) . " 00:00:00";
        $paramLista['date_end'] = translateDate($paramFiltro['date_end']) . " 23:59:59";
    }
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    // Inicio de objeto grilla y asignación de filtro
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->enableExport();
    // enable export.
    $oGrid->showFilter($htmlFilter);
    $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes';
    // Ejecutar la consulta con las variables ya validadas
    $arrData = array();
    $total = 0;
    if (is_array($paramLista)) {
        $total = $oCallsDetail->contarDetalleLlamadas($paramLista);
        if (is_null($total)) {
            $smarty->assign("mb_title", _tr("Error when connecting to database"));
            $smarty->assign("mb_message", $oCallsDetail->errMsg);
            $total = 0;
        } else {
            // Habilitar la exportación de todo el contenido consultado
            if ($bExportando) {
                $limit = $total;
            }
            // Calcular el offset de la petición de registros
            if ($bElastixNuevo) {
                $oGrid->setLimit($limit);
                $oGrid->setTotal($total);
                $offset = $oGrid->calculateOffset();
            } else {
                // Si se quiere avanzar a la sgte. pagina
                if (isset($_GET['nav']) && $_GET['nav'] == "end") {
                    // Mejorar el sgte. bloque.
                    if ($total % $limit == 0) {
                        $offset = $total - $limit;
                    } else {
                        $offset = $total - $total % $limit;
                    }
                }
                // Si se quiere avanzar a la sgte. pagina
                if (isset($_GET['nav']) && $_GET['nav'] == "next") {
                    $offset = $_GET['start'] + $limit - 1;
                }
                // Si se quiere retroceder
                if (isset($_GET['nav']) && $_GET['nav'] == "previous") {
                    $offset = $_GET['start'] - $limit - 1;
                }
            }
            // Ejecutar la consulta de los datos en el offset indicado
            $recordset = $oCallsDetail->leerDetalleLlamadas($paramLista, $limit, $offset);
            // add STT
            for ($i = 0; $i < count($recordset); $i++) {
                $recordset[$i]['stt'] = $i + 1;
            }
            if (!is_array($recordset)) {
                $smarty->assign("mb_title", _tr("Error when connecting to database"));
                $smarty->assign("mb_message", $oCallsDetail->errMsg);
                $total = 0;
            } else {
                function _calls_detail_map_recordset($cdr)
                {
                    $mapaEstados = array('abandonada' => 'Bỏ nhỡ', 'Abandoned' => 'Bỏ nhỡ', 'terminada' => 'Đã nghe', 'Success' => 'Đã nghe', 'fin-monitoreo' => _tr('End Monitor'), 'Failure' => _tr('Failure'), 'NoAnswer' => _tr('NoAnswer'), 'OnQueue' => _tr('OnQueue'), 'Placing' => _tr('Placing'), 'Ringing' => _tr('Ringing'), 'ShortCall' => _tr('ShortCall'), 'activa' => 'Đang gọi');
                    return array($cdr['stt'], $cdr[0], htmlentities($cdr[1], ENT_COMPAT, "UTF-8"), substr($cdr[2], 0, 10), substr($cdr[2], 11, 8), substr($cdr[3], 0, 10), substr($cdr[3], 11, 8), is_null($cdr[4]) ? '-' : formatoSegundos($cdr[4]), is_null($cdr[5]) ? '-' : formatoSegundos($cdr[5]), $cdr[6], $cdr[8], $cdr[9], isset($mapaEstados[$cdr[10]]) ? $mapaEstados[$cdr[10]] : _tr($cdr[10]), is_null($cdr[12]) || trim($cdr[12] == '') ? '' : '<a href="javascript:void(0)" onclick="view_note(\'' . $cdr[11] . '\')">Xem</a>');
                }
                $arrData = array_map('_calls_detail_map_recordset', $recordset);
            }
        }
    }
    $arrColumnas = array('STT', 'Số Agent', 'Nhân viên', _tr("Start Date"), _tr("Start Time"), _tr("End Date"), _tr("End Time"), "Thời lượng", _tr("Thời gian chờ"), _tr("Queue"), _tr("Số điện thoại"), _tr("Chuyển máy"), _tr("Status"), 'Nội dung');
    if ($bElastixNuevo) {
        $oGrid->setURL(construirURL($urlVars, array("nav", "start")));
        $oGrid->setData($arrData);
        $oGrid->setColumns($arrColumnas);
        $oGrid->setTitle('Chi tiết cuộc gọi Call Center');
        $oGrid->pagingShow(true);
        $oGrid->setNameFile_Export(_tr("Calls Detail"));
        return $oGrid->fetchGrid();
    } else {
        global $arrLang;
        $url = construirURL($urlVars, array("nav", "start"));
        function _map_name($s)
        {
            return array('name' => $s);
        }
        $arrGrid = array("title" => _tr("Calls Detail"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas));
        if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) {
            return $oGrid->fetchGridPDF($arrGrid, $arrData);
        }
        if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) {
            return $oGrid->fetchGridXLS($arrGrid, $arrData);
        }
        if ($bExportando) {
            header("Cache-Control: private");
            header("Pragma: cache");
            // Se requiere para HTTPS bajo IE6
            header('Content-disposition: inline; filename="calls_detail.csv"');
            header("Content-Type: text/csv; charset=UTF-8");
        }
        if ($bExportando) {
            return $oGrid->fetchGridCSV($arrGrid, $arrData);
        }
        $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
        if (strpos($sContenido, '<form') === FALSE) {
            $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
        }
        return $sContenido;
    }
}
Esempio n. 20
0
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $padress_book = new paloAdressBook($pDB);
    $pACL = new paloACL($pDB_2);
    $user = $_SESSION["elastix_user"];
    $id_user = $pACL->getIdUser($user);
    $extension = $pACL->getUserExtension($user);
    if (is_null($extension) || $extension == "") {
        if ($pACL->isUserAdministratorGroup($user)) {
            $smarty->assign("mb_title", _tr("MESSAGE"));
            $smarty->assign("mb_message", "<b>" . $arrLang["You don't have extension number associated with user"] . "</b>");
        } else {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
        }
    }
    if (getParameter('select_directory_type') != null && getParameter('select_directory_type') == 'external') {
        $smarty->assign("external_sel", 'selected=selected');
        $directory_type = 'external';
    } else {
        $smarty->assign("internal_sel", 'selected=selected');
        $directory_type = 'internal';
    }
    $_POST['select_directory_type'] = $directory_type;
    $arrComboElements = array("name" => $arrLang["Name"], "telefono" => $arrLang["Phone Number"]);
    if ($directory_type == 'external') {
        $arrComboElements["last_name"] = $arrLang["Last Name"];
    }
    $arrFormElements = array("field" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value')));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", $arrLang["Show"]);
    $smarty->assign("NEW_adress_book", $arrLang["New Contact"]);
    $smarty->assign("CSV", $arrLang["CSV"]);
    $smarty->assign("module_name", $module_name);
    $smarty->assign("Phone_Directory", $arrLang["Phone Directory"]);
    $smarty->assign("Internal", $arrLang["Internal"]);
    $smarty->assign("External", $arrLang["External"]);
    $field = NULL;
    $pattern = NULL;
    $namePattern = NULL;
    $allowSelection = array("name", "telefono", "last_name");
    if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") {
        $field = $_POST['field'];
        if (!in_array($field, $allowSelection)) {
            $field = "name";
        }
        $pattern = "%{$_POST['pattern']}%";
        $namePattern = $_POST['pattern'];
        $nameField = $arrComboElements[$field];
    }
    $arrFilter = array("select_directory_type" => $directory_type, "field" => $field, "pattern" => $namePattern);
    $startDate = $endDate = date("Y-m-d H:i:s");
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Phone Directory") . " =  {$directory_type} ", $arrFilter, array("select_directory_type" => "internal"), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter);
    if ($directory_type == 'external') {
        $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE, $id_user);
    } else {
        $total = $padress_book->getDeviceFreePBX($dsnAsterisk, NULL, NULL, $field, $pattern, TRUE);
    }
    $total_datos = $total[0]["total"];
    //Paginacion
    $limit = 20;
    $total = $total_datos;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $inicio = $total == 0 ? 0 : $offset + 1;
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    //Fin Paginacion
    if ($directory_type == 'external') {
        $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE, $id_user);
    } else {
        $arrResult = $padress_book->getDeviceFreePBX($dsnAsterisk, $limit, $offset, $field, $pattern);
    }
    $arrData = null;
    //echo print_r($arrResult,true);
    if (is_array($arrResult) && $total > 0) {
        $arrMails = array();
        $typeContact = "";
        if ($directory_type == 'internal') {
            $arrMails = $padress_book->getMailsFromVoicemail();
        }
        foreach ($arrResult as $key => $adress_book) {
            if ($directory_type == 'external') {
                $exten = explode(".", $adress_book["picture"]);
                if (isset($exten[count($exten) - 1])) {
                    $exten = $exten[count($exten) - 1];
                }
                $picture = "/var/www/address_book_images/{$adress_book['id']}_Thumbnail.{$exten}";
                if (file_exists($picture)) {
                    $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='image' border='0' src='index.php?menu={$module_name}&action=getImage&idPhoto={$adress_book['id']}&thumbnail=yes&rawmode=yes'/></a>";
                } else {
                    $defaultPicture = "modules/{$module_name}/images/Icon-user_Thumbnail.png";
                    $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img border='0' alt='image' src='{$defaultPicture}'/></a>";
                }
            }
            $arrTmp[0] = $directory_type == 'external' ? "<input type='checkbox' name='contact_{$adress_book['id']}'  />" : '';
            if ($directory_type == 'external') {
                $email = $adress_book['email'];
                if ($adress_book['status'] == 'isPublic') {
                    if ($id_user == $adress_book['iduser']) {
                        $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public_edit.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public editable'] . "</span></div></div>";
                        $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}'  />";
                    } else {
                        $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                        $arrTmp[0] = "";
                    }
                } else {
                    $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='private' style='padding: 5px;' title='" . $arrLang['Private Contact'] . "' border='0' src='modules/{$module_name}/images/contact.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Private'] . "</span></div></div>";
                }
            } else {
                if (isset($arrMails[$adress_book['id']])) {
                    $email = $arrMails[$adress_book['id']];
                    $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                } else {
                    $email = '';
                    $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                }
            }
            $arrTmp[2] = $directory_type == 'external' ? "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'>" . htmlspecialchars($adress_book['last_name'], ENT_QUOTES, "UTF-8") . " " . htmlspecialchars($adress_book['name'], ENT_QUOTES, "UTF-8") . "</a>" : $adress_book['description'];
            $arrTmp[3] = $directory_type == 'external' ? $adress_book['telefono'] : $adress_book['id'];
            $arrTmp[4] = $email;
            $arrTmp[5] = "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['id'] . "&type=" . $directory_type . "'><img border=0 src='/modules/{$module_name}/images/call.png' /></a>";
            $arrTmp[6] = "<a href='?menu={$module_name}&action=transfer_call&id=" . $adress_book['id'] . "&type=" . $directory_type . "'>{$arrLang["Transfer"]}</a>";
            $arrTmp[7] = $typeContact;
            $arrData[] = $arrTmp;
        }
    }
    if ($directory_type == 'external') {
        $name = "";
        $picture = $arrLang["picture"];
        $oGrid->deleteList(_tr("Are you sure you wish to delete the contact."), "delete", _tr("Delete"));
    } else {
        $name = "";
        $picture = "";
    }
    $arrGrid = array("title" => $arrLang["Address Book"], "url" => array('menu' => $module_name, 'filter' => $pattern, 'select_directory_type' => $directory_type), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $name, "property1" => ""), 1 => array("name" => $picture, "property1" => ""), 2 => array("name" => $arrLang["Name"], "property1" => ""), 3 => array("name" => $arrLang["Phone Number"], "property1" => ""), 4 => array("name" => $arrLang["Email"], "property1" => ""), 5 => array("name" => $arrLang["Call"], "property1" => ""), 6 => array("name" => $arrLang["Transfer"], "property1" => ""), 7 => array("name" => $arrLang["Type Contact"], "property1" => "")));
    $oGrid->addNew("new", _tr("New Contact"));
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}
Esempio n. 21
0
function reportGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $idOrgFil = getParameter("idOrganization");
    if ($userLevel1 == "superadmin") {
        if (!empty($idOrgFil)) {
            $cntGroups = $pACL->getNumGroups($idOrgFil);
        } else {
            $idOrgFil = 0;
            //opcion default se muestran todos los grupos
            $cntGroupsMO = $pACL->getNumGroups(1);
            //obtenemos en numero de grupos que pertenecen a
            //la organizacion 1 y lo restamos del total de grupos
            $cntGroups = $pACL->getNumGroups() - $cntGroupsMO;
        }
    } else {
        $idOrgFil = $idOrganization;
        $cntGroups = $pACL->getNumGroups($idOrganization);
    }
    if ($cntGroups === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pACL->errMsg));
        $total = 0;
    } else {
        $total = $cntGroups;
    }
    //url
    $url['menu'] = $module_name;
    $url['idOrganization'] = $idOrgFil;
    $total = $total == NULL ? 0 : $total;
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $oGrid->setURL($url);
    $oGrid->setTitle(_tr('Group List'));
    $oGrid->setIcon("web/apps/{$module_name}/images/system_groups.png");
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    if ($userLevel1 == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Group Name");
    $arrColumns[] = _tr("Group Description");
    $oGrid->setColumns($arrColumns);
    if ($idOrgFil != 0) {
        $Groups = $pACL->getGroupsPaging($limit, $offset, $idOrgFil);
    } else {
        $Groups = $pACL->getGroupsPaging($limit, $offset);
    }
    $arrData = array();
    foreach ($Groups as $group) {
        if ($group[3] != 1) {
            $arrTmp = array();
            if ($userLevel1 == "superadmin") {
                $orgz = $pORGZ->getOrganizationById($group[3]);
                $arrTmp[] = htmlentities($orgz["name"], ENT_COMPAT, 'UTF-8');
                //organization
            }
            $arrTmp[] = "&nbsp;<a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>";
            //id,group name
            $arrTmp[] = _tr($group[2]);
            //description
            $arrData[] = $arrTmp;
        }
    }
    if ($pORGZ->getNumOrganization(array()) > 0) {
        global $arrPermission;
        if (in_array('create_group', $arrPermission)) {
            $oGrid->addNew("create_group", _tr("Create New Group"));
        }
        if ($userLevel1 == "superadmin") {
            $arrOrgz = array(0 => _tr("all"));
            foreach ($pORGZ->getOrganization(array()) as $value) {
                if ($value["id"] != 1) {
                    $arrOrgz[$value["id"]] = $value["name"];
                }
            }
            $arrFormElements = createFieldFilter($arrOrgz);
            $oFilterForm = new paloForm($smarty, $arrFormElements);
            $_POST["idOrganization"] = $idOrgFil;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$idOrgFil], $_POST, array("idOrganization" => 0), true);
            $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
            $oGrid->showFilter(trim($htmlFilter));
        }
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You need have created at least one organization before you can create a new group"));
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    return $contenidoModulo;
}
Esempio n. 22
0
function reportListadodeCallTypes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pListadodeCallTypes = new paloSantoListadodeCallTypes($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Listado de Call Types"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Listado de Call Types"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Campaña"), _tr("Call Type"), _tr("Clase de Call Type"), _tr("Peso"), _tr("Status"), _tr("Acción"));
    $oGrid->setColumns($arrColumns);
    $total = $pListadodeCallTypes->getNumListadodeCallTypes($filter_field, $filter_value);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pListadodeCallTypes->getListadodeCallTypes($limit, $offset, $filter_field, $filter_value);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['campania'];
            $arrTmp[1] = $value['call_type'];
            $arrTmp[2] = $value['clase'];
            $arrTmp[3] = $value['peso'];
            $arrTmp[4] = $value['status'] == "A" ? "Activo" : "Inactivo";
            $arrTmp[5] = "<a href=index.php?menu={$module_name}&id={$value['id']}&id_campania={$value['id_campania']}&action=change_status&status=";
            if ($value['status'] == "A") {
                $arrTmp[5] .= "I";
                $accion = "Desactivar";
            } else {
                $arrTmp[5] .= "A";
                $accion = "Activar";
            }
            $arrTmp[5] .= ">{$accion}</a>";
            $arrTmp[5] .= " <a href=index.php?menu=hispana_call_types&id={$value['id']}&id_campania={$value['id_campania']}&action=view_edit>Editar</a>";
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Esempio n. 23
0
function listarArchivos($module_name, $smarty, $local_templates_dir, $sDirectorio)
{
    global $arrLang;
    // Función que rechaza los directorios punto y doble punto
    function _reject_dotdirs($s)
    {
        return !($s == '.' || $s == '..');
    }
    $listaArchivos = file_exists($sDirectorio) && is_dir($sDirectorio) ? array_filter(scandir($sDirectorio), '_reject_dotdirs') : NULL;
    if (!is_array($listaArchivos)) {
        $smarty->assign("msj_err", _tr('This is not a valid directory'));
    }
    // Filtrar por la cadena indicada en el filtro
    $sSubStrArchivo = getParameter('file');
    if ($sSubStrArchivo != '') {
        $t = array();
        foreach ($listaArchivos as $sArchivo) {
            if (strpos($sArchivo, $sSubStrArchivo) !== FALSE) {
                $t[] = $sArchivo;
            }
        }
        $listaArchivos = $t;
    }
    // Mapear de la lista de archivos al listado completo con URLs
    $arrData = array();
    foreach ($listaArchivos as $sArchivo) {
        $arrData[] = array(sprintf('<a href="%s">%s</a>', construirURL(array('menu' => $module_name, 'action' => 'edit', 'file' => $sArchivo, 'search' => $sSubStrArchivo, 'nav' => getParameter('nav'), 'page' => getParameter('page'))), htmlentities($sArchivo, ENT_COMPAT, 'UTF-8')), filesize($sDirectorio . $sArchivo));
    }
    ////PARA EL PAGINEO
    $total = count($arrData);
    $limit = 25;
    $offset = 0;
    $oForm = new paloForm($smarty, array("file" => array("LABEL" => _tr("File"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")));
    $smarty->assign("Filter", _tr('Filter'));
    $smarty->assign("NEW_FILE", _tr("New File"));
    $smarty->assign('url_new', construirURL(array('menu' => $module_name, 'action' => 'new')));
    $oGrid = new paloSantoGrid($smarty);
    $arr = array("file" => getParameter("file"), "filter" => "Filter");
    if (empty($_POST)) {
        $_POST = $arr;
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("File") . " = " . $sSubStrArchivo, $_POST, array("file" => ""));
    $htmlFilter = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("File Editor"), $_POST);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $inicio = $total == 0 ? 0 : $offset + 1;
    $fin = $offset + $limit <= $total ? $offset + $limit : $total;
    $leng = $fin - $inicio;
    $arrDatosGrid = array_slice($arrData, $inicio - 1, $leng + 1);
    $arrGrid = array("title" => _tr("File Editor"), "url" => array('menu' => $module_name, 'file' => $sSubStrArchivo), "icon" => "/modules/{$module_name}/images/pbx_tools_asterisk_file_editor.png", "width" => "99%", "start" => $inicio, "end" => $fin, "total" => $total, "columns" => array(0 => array("name" => _tr("File List"), "property1" => ""), 1 => array("name" => _tr("File Size"), "property1" => "")));
    $oGrid->addNew("?menu={$module_name}&action=new", _tr("New File"), true);
    $oGrid->showFilter($htmlFilter);
    return $oGrid->fetchGrid($arrGrid, $arrDatosGrid, $arrLang);
}
Esempio n. 24
0
function report_AsteriskLogs($smarty, $module_name, $local_templates_dir, $arrLang)
{
    $arrFormElements = array("filter" => array("LABEL" => $arrLang["Date"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => NULL, "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}$'), "busqueda" => array("LABEL" => $arrLang['Search string'], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", 'VALIDATION_TYPE' => 'text', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_EXTRA_PARAM' => ''), "offset" => array("LABEL" => $arrLang["offset"], "REQUIRED" => "no", "INPUT_TYPE" => "HIDDEN", "INPUT_EXTRA_PARAM" => NULL, "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => '^[[:digit:]]+$'), "ultima_busqueda" => array("LABEL" => $arrLang['Search string'], "REQUIRED" => "no", "INPUT_TYPE" => "HIDDEN", 'VALIDATION_TYPE' => 'text', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_EXTRA_PARAM' => ''), "ultimo_offset" => array("LABEL" => $arrLang["offset"], "REQUIRED" => "no", "INPUT_TYPE" => "HIDDEN", "INPUT_EXTRA_PARAM" => NULL, "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => '^[[:digit:]]+$'));
    $smarty->assign("SHOW", $arrLang["Show"]);
    $smarty->assign("SEARCHNEXT", $arrLang['Search']);
    $field_pattern = getParameter("filter");
    $busqueda = getParameter('busqueda');
    if (is_null($busqueda) || trim($busqueda) == '') {
        $busqueda = '';
    }
    /* Última búsqueda, si existe */
    $sUltimaBusqueda = getParameter('ultima_busqueda');
    $iUltimoOffset = getParameter('ultimo_offset');
    if (is_null($sUltimaBusqueda) || $sUltimaBusqueda == '' || is_null($iUltimoOffset) || !ereg('^[[:digit:]]+$', $iUltimoOffset)) {
        $sUltimaBusqueda = NULL;
        $iUltimoOffset = NULL;
    }
    $pAsteriskLogs = new paloSantoAsteriskLogs($pDB);
    $listaFechas = $pAsteriskLogs->astLog->listarFechas();
    if (!ereg($arrFormElements['filter']['VALIDATION_EXTRA_PARAM'], $field_pattern)) {
        $field_pattern = $listaFechas[count($listaFechas) - 1];
    }
    $_POST['filter'] = $field_pattern;
    $total_datos = $pAsteriskLogs->ObtainNumAsteriskLogs($field_pattern);
    $comboFechas = array();
    foreach ($listaFechas as $f) {
        $comboFechas[$f] = $f;
    }
    $arrFormElements['filter']['INPUT_EXTRA_PARAM'] = $comboFechas;
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    if ($busqueda != '') {
        $_POST['busqueda'] = $busqueda;
    }
    $oGrid = new paloSantoGrid($smarty);
    $iNumLineasPorPagina = 30;
    $iEstimadoBytesPagina = $iNumLineasPorPagina * 128;
    $iOffsetVerdadero = getParameter('offset');
    if (is_null($iOffsetVerdadero) || !ereg('^[[:digit:]]+$', $iOffsetVerdadero)) {
        $iOffsetVerdadero = 0;
    }
    $totalBytes = $total_datos[0];
    if ($iOffsetVerdadero >= $totalBytes) {
        $iOffsetVerdadero = 0;
    }
    if (isset($_GET['filter']) && isset($_POST['filter']) && $_GET['filter'] != $_POST['filter']) {
        $iOffsetVerdadero = 0;
    }
    /* Para ubicarse en la página, se obtiene la región 5 páginas estimadas hacia delante y 
         5 páginas estimadas hacia atrás desde el offset indicado.
       */
    $inicioRango = $iOffsetVerdadero - 5 * $iEstimadoBytesPagina;
    if ($inicioRango < 0) {
        $inicioRango = 0;
    }
    $arrResult = $pAsteriskLogs->ObtainAsteriskLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern);
    /* Localizar la línea del offset verdadero, así como los offsets de las páginas previa y siguiente */
    for ($iPos = 0; $iPos < count($arrResult); $iPos++) {
        if ($arrResult[$iPos]['offset'] >= $iOffsetVerdadero) {
            break;
        }
    }
    $iPosPrevio = $iPos - $iNumLineasPorPagina;
    $iPosSiguiente = $iPos + $iNumLineasPorPagina;
    if ($iPosPrevio < 0) {
        $iPosPrevio = 0;
    }
    if ($iPosSiguiente > count($arrResult) - 1) {
        $iPosSiguiente = count($arrResult) - 1;
    }
    $iOffsetPrevio = $arrResult[$iPosPrevio]['offset'];
    $iOffsetSiguiente = $arrResult[$iPosSiguiente]['offset'];
    $limit = $iNumLineasPorPagina;
    $total = (int) ($totalBytes / 128);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $iOffsetVerdadero;
    $nav = getParameter('nav');
    if ($nav) {
        switch ($nav) {
            case 'start':
                $offset = 0;
                break;
            case 'end':
                /* Caso especial: se debe tomar la última sección del log */
                $inicioRango = $totalBytes - 5 * $iEstimadoBytesPagina;
                if ($inicioRango < 0) {
                    $inicioRango = 0;
                }
                $arrResult = $pAsteriskLogs->ObtainAsteriskLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern);
                if (count($arrResult) <= $iNumLineasPorPagina) {
                    $offset = $arrResult[0]['offset'];
                } else {
                    $offset = $arrResult[count($arrResult) - $iNumLineasPorPagina]['offset'];
                }
                break;
            case 'next':
                $offset = $iOffsetSiguiente;
                break;
            case 'previous':
                $offset = $iOffsetPrevio;
                break;
            case 'bypage':
                $numPage = $limit == 0 ? 0 : ceil($total / $limit);
                $page = getParameter("page");
                if (preg_match("/[0-9]+/", $page) == 0) {
                    // no es un número
                    $page = 1;
                }
                if ($page > $numPage) {
                    // se está solicitando una pagina mayor a las que existen
                    $page = $numPage;
                }
                $start = ($page - 1) * $limit + 1 - $limit;
                if ($start + $limit <= 1) {
                    $offset = 0;
                    break;
                }
                $inicioBusqueda = $page * $iEstimadoBytesPagina - $iEstimadoBytesPagina;
                $arrResult = $pAsteriskLogs->ObtainAsteriskLogs(10 * $iEstimadoBytesPagina, $inicioBusqueda, $field_pattern);
                $offset = $arrResult[0]['offset'];
                $oGrid->setOffsetValue($offset);
                break;
        }
    }
    // Buscar la cadena de texto indicada, y modificar offset si se encuentra
    if (isset($_POST['searchnext']) && $busqueda != '') {
        $pAsteriskLogs->astLog->posicionarMensaje($field_pattern, $offset);
        $posBusqueda = $pAsteriskLogs->astLog->buscarTextoMensaje($busqueda);
        if (!is_null($posBusqueda)) {
            $offset = $posBusqueda[1];
            $smarty->assign('SEARCHNEXT', $arrLang['Search next']);
            $_POST['ultima_busqueda'] = $busqueda;
            $_POST['ultimo_offset'] = $offset;
            // Si el offset anterior indicado es idéntico al offset recién encontrado
            // y la cadena de búsqueda es también idéntica, se asume que se ha
            // pedido una búsqueda de la siguiente ocurrencia.
            if (!is_null($sUltimaBusqueda) && !is_null($iUltimoOffset) && $offset == $iUltimoOffset && $sUltimaBusqueda == $busqueda) {
                $pAsteriskLogs->astLog->posicionarMensaje($field_pattern, $offset);
                $pAsteriskLogs->astLog->siguienteMensaje();
                // Sólo para ignorar primera ocurrencia
                $posBusqueda = $pAsteriskLogs->astLog->buscarTextoMensaje($busqueda);
                if (!is_null($posBusqueda)) {
                    $offset = $posBusqueda[1];
                    $_POST['ultimo_offset'] = $offset;
                }
            }
        } else {
        }
    }
    $url = array('menu' => $module_name, 'filter' => $field_pattern, 'offset' => $offset, 'busqueda' => $busqueda, 'ultima_busqueda' => isset($_POST['ultima_busqueda']) ? $_POST['ultima_busqueda'] : '', 'ultimo_offset' => isset($_POST['ultimo_offset']) ? $_POST['ultimo_offset'] : '');
    //Fin Paginacion
    $arrResult = $pAsteriskLogs->ObtainAsteriskLogs(10 * $iEstimadoBytesPagina, $offset, $field_pattern, $busqueda != '' ? $busqueda : NULL);
    $arrResult = array_slice($arrResult, 0, $iNumLineasPorPagina);
    $posLog = $pAsteriskLogs->astLog->obtenerPosicionMensaje();
    $arrData = null;
    if (is_array($arrResult) && $totalBytes > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['fecha'];
            $arrTmp[1] = $value['tipo'];
            $arrTmp[2] = $value['origen'];
            $arrTmp[3] = $value['linea'];
            $arrData[] = $arrTmp;
        }
    }
    $_POST['offset'] = $offset;
    //$defaultEnd=end($comboFechas);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Date") . " = " . $_POST['filter'], $_POST, array('filter' => $listaFechas[count($listaFechas) - 1]), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr('Search string') . " = " . $busqueda, $_POST, array('busqueda' => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    $arrGrid = array("title" => $arrLang["Asterisk Logs"], "url" => $url, "icon" => "/modules/{$module_name}/images/reports_asterisk_logs.png", "width" => "99%", "start" => $totalBytes == 0 ? 0 : 1 + (int) ($offset / 128), "end" => (int) ($offset / 128) + $iNumLineasPorPagina, "total" => (int) ($totalBytes / 128), "columns" => array(0 => array("name" => $arrLang['Date'], "property1" => ""), 1 => array("name" => $arrLang['Type'], "property1" => ""), 2 => array("name" => $arrLang['Source'], "property1" => ""), 3 => array("name" => $arrLang['Message'], "property1" => "")));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    /*$current_page=getParameter("page");
      print($current_page);
      $contenidoModulo .= "<script type='text/javascript'>
          var offset = ".$offset.";
          var limit = ".$limit.";
          var current_page = ".$current_page.";
                      alert(current_page);
              var start = current_page * limit;
              page = Math.floor(start / limit);
          $('#pageup').val(page);
          $('#pagedown').val(page);
      </script>";*/
    return $contenidoModulo;
}
Esempio n. 25
0
function _moduleContent(&$smarty, $module_name)
{
    require_once "modules/{$module_name}/libs/ringgroup.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // DSN para consulta de cdrs
    $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb');
    $pDB = new paloDB($dsn);
    $oCDR = new paloSantoCDR($pDB);
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    if (!empty($pDBACL->errMsg)) {
        return "ERROR DE DB: {$pDBACL->errMsg}";
    }
    $pACL = new paloACL($pDBACL);
    if (!empty($pACL->errMsg)) {
        return "ERROR DE ACL: {$pACL->errMsg}";
    }
    $exten = '6868';
    //$pACL->getUserExtension($_SESSION['elastix_user']);
    $isAdministrator = true;
    //$pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
    if (is_null($exten) || $exten == "") {
        if (!$isAdministrator) {
            $smarty->assign('mb_message', "<b>" . _tr("contact_admin") . "</b>");
            return "";
        } else {
            $smarty->assign('mb_message', "<b>" . _tr("no_extension") . "</b>");
        }
    }
    // Para usuarios que no son administradores, se restringe a los CDR de la
    // propia extensión
    $sExtension = $isAdministrator ? '' : $pACL->getUserExtension($_SESSION['elastix_user']);
    // DSN para consulta de ringgroups
    $dsn_asterisk = generarDSNSistema('asteriskuser', 'asterisk');
    $pDB_asterisk = new paloDB($dsn_asterisk);
    $oRG = new RingGroup($pDB_asterisk);
    $dataRG = $oRG->getRingGroup();
    $dataRG[''] = _tr('(Any ringgroup)');
    // Cadenas estáticas en la plantilla
    $smarty->assign(array("Filter" => _tr("Filter")));
    $arrFormElements = array("date_start" => array("LABEL" => _tr("Start Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "date_end" => array("LABEL" => _tr("End Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "field_name" => array("LABEL" => _tr("Field Name"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("dst" => _tr("Destination"), "src" => _tr("Source"), "channel" => _tr("Src. Channel"), "accountcode" => _tr("Account Code"), "dstchannel" => _tr("Dst. Channel")), "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)\$"), "field_pattern" => array("LABEL" => _tr("Field"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[\\*|[:alnum:]@_\\.,/\\-]+\$"), "status" => array("LABEL" => _tr("Status"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("ALL" => _tr("ALL"), "ANSWERED" => _tr("ANSWERED"), "BUSY" => _tr("BUSY"), "FAILED" => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "ringgroup" => array("LABEL" => _tr("Ring Group"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $dataRG, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Parámetros base y validación de parámetros
    $url = array('menu' => $module_name);
    $paramFiltroBase = $paramFiltro = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'dst', 'field_pattern' => '', 'status' => 'ALL', 'ringgroup' => '');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    if ($paramFiltro['date_start'] === "") {
        $paramFiltro['date_start'] = " ";
    }
    if ($paramFiltro['date_end'] === "") {
        $paramFiltro['date_end'] = " ";
    }
    $valueFieldName = $arrFormElements['field_name']["INPUT_EXTRA_PARAM"][$paramFiltro['field_name']];
    $valueStatus = $arrFormElements['status']["INPUT_EXTRA_PARAM"][$paramFiltro['status']];
    $valueRingGRoup = $arrFormElements['ringgroup']["INPUT_EXTRA_PARAM"][$paramFiltro['ringgroup']];
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . $valueFieldName . " = " . $paramFiltro['field_pattern'], $paramFiltro, array('field_name' => "dst", 'field_pattern' => ""));
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Status") . " = " . $valueStatus, $paramFiltro, array('status' => 'ALL'), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Ring Group") . " = " . $valueRingGRoup, $paramFiltro, array('ringgroup' => ''));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    if (!$oFilterForm->validateForm($paramFiltro)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $paramFiltro = $paramFiltroBase;
        unset($_POST['delete']);
        // Se aborta el intento de borrar CDRs, si había uno.
    }
    // Tradudir fechas a formato ISO para comparación y para API de CDRs.
    $url = array_merge($url, $paramFiltro);
    $paramFiltro['date_start'] = translateDate($paramFiltro['date_start']) . ' 00:00:00';
    $paramFiltro['date_end'] = translateDate($paramFiltro['date_end']) . ' 23:59:59';
    // Valores de filtrado que no se seleccionan mediante filtro
    if ($sExtension != '') {
        $paramFiltro['extension'] = $sExtension;
    }
    // Ejecutar el borrado, si se ha validado.
    if (isset($_POST['delete'])) {
        if ($isAdministrator) {
            if ($paramFiltro['date_start'] <= $paramFiltro['date_end']) {
                $r = $oCDR->borrarCDRs($paramFiltro);
                if (!$r) {
                    $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
                }
            } else {
                $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Please End Date must be greater than Start Date")));
            }
        } else {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Only administrators can delete CDRs")));
        }
    }
    $oGrid->setTitle(_tr("CDR Report"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("CDRReport"));
    $oGrid->setURL($url);
    //if($isAdministrator)
    //$oGrid->deleteList("Are you sure you wish to delete CDR(s) Report(s)?","delete",_tr("Delete"));
    $arrData = null;
    if (!isset($sExtension) || $sExtension == "" && !$isAdministrator) {
        $total = 0;
    } else {
        $total = $oCDR->contarCDRs($paramFiltro);
    }
    if ($oGrid->isExportAction()) {
        $limit = $total;
        $offset = 0;
        $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = date("d-m-Y H:i:s", strtotime($value[0]));
                $arrTmp[1] = $value[1];
                $arrTmp[2] = $value[11];
                $arrTmp[3] = $value[3];
                $arrTmp[4] = $value[9];
                $arrTmp[5] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[6]}s";
                if ($value[6] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[7] = $sTiempo;
                $arrData[] = $arrTmp;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        $arrColumns = array('STT', _tr("Date"), _tr("Source"), _tr("Destination"), _tr("Src. Channel"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            $index = 0;
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = $index;
                $arrTmp[1] = date("d-m-Y H:i:s", strtotime($value[0]));
                $arrTmp[2] = $value[1];
                $arrTmp[3] = $value[2];
                $arrTmp[4] = channel_lookup($pDB_asterisk, $value[3]);
                $arrTmp[5] = channel_lookup($pDB_asterisk, $value[4]);
                $arrTmp[6] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[8]}s";
                if ($value[7] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[7] = $sTiempo;
                $arrData[] = $arrTmp;
                $index++;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    }
    $oGrid->setData($arrData);
    $smarty->assign("SHOW", _tr("Show"));
    $oGrid->showFilter($htmlFilter);
    $content = $oGrid->fetchGrid();
    return $content;
}
Esempio n. 26
0
function listarColas($pDB, $smarty, $module_name, $local_templates_dir)
{
    require_once "libs/paloSantoGrid.class.php";
    global $arrLang;
    $oColas = new paloSantoColaEntrante($pDB);
    // Verificar si alguna cola debe activarse o inactivarse
    if (!is_null($id = getParameter('id'))) {
        if (!is_null(getParameter('activate'))) {
            $bExito = $oColas->cambiarMonitoreoCola($id, 'A');
        } elseif (!is_null(getParameter('deactivate'))) {
            $bExito = $oColas->cambiarMonitoreoCola($id, 'I');
        }
        if (!$bExito) {
            $smarty->assign("mb_title", _tr('Unable to change activation'));
            $smarty->assign("mb_message", $oColas->errMsg);
        }
    }
    // Estado indicado por el filtro
    $sEstado = getParameter('estatus');
    if (is_null($sEstado)) {
        $sEstado = 'A';
    }
    if (!in_array($sEstado, array('', 'A', 'I'))) {
        $sEstado = 'A';
    }
    if ($sEstado == '') {
        $sEstado = NULL;
    }
    // Consulta de las colas
    $arrDataQueues = $oColas->leerColas(NULL, $sEstado);
    if (!is_array($arrDataQueues)) {
        $smarty->assign("mb_title", _tr('Unable to read queues'));
        $smarty->assign("mb_message", _tr('Cannot read queues') . ' - ' . $oColas->errMsg);
        $arrDataQueues = array();
    }
    // Construcción del reporte
    $end = count($arrDataQueues);
    $url = construirUrl(array('menu' => $module_name), array('nav', 'start'));
    $arrGrid = array("title" => _tr('Queue List'), 'url' => $url, "icon" => "images/list.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(array("name" => "<input class=\"button\" type=\"submit\" name=\"activate\" value=\"" . _tr('Activate') . "\" />" . "<input class=\"button\" type=\"submit\" name=\"deactivate\" value=\"" . _tr('Deactivate') . "\" />"), array("name" => _tr('Name Queue')), array("name" => _tr('Status')), array("name" => _tr('Options'))));
    $oGrid = new paloSantoGrid($smarty);
    $arrData = array();
    foreach ($arrDataQueues as $tuplaQueue) {
        $arrData[] = array("<input type=\"radio\" name=\"id\" value=\"{$tuplaQueue['id']}\" />", $tuplaQueue['queue'], $tuplaQueue['estatus'] == 'A' ? _tr('Active') : _tr('Inactive'), "<a href=\"?menu={$module_name}&amp;action=edit_queue&amp;id_queue={$tuplaQueue['id']}\">[" . htmlentities(_tr('Edit'), ENT_COMPAT, 'UTF-8') . "]</a>");
    }
    $oGrid->showFilter('<table width="100%" border="0"><tr>' . '<td align="right"><b>' . _tr('Status') . '</b></td>' . '<td align="left"><select name="estatus" onchange="submit();">' . combo(array('' => _tr('all'), 'A' => _tr('active'), 'I' => _tr('inactive')), $sEstado) . '</select></td>' . '<td align="right"><b><a href="?menu=' . $module_name . '&amp;action=new_queue">' . _tr('Select Queue') . '&nbsp;&raquo;</a></b></td>' . '</tr></table>');
    $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    if (strpos($sContenido, '<form') === FALSE) {
        $sContenido = "<form  method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>";
    }
    return $sContenido;
}
Esempio n. 27
0
function addRemovePortsUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf)
{
    // Listar los usuarios y preparar el combo de usuarios disponibles
    $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
    $id_user = getParameter('id_user');
    $userlist = $pACL->getUsers();
    $cbo_users = array();
    foreach ($userlist as $userinfo) {
        $cbo_users[$userinfo[0]] = $userinfo[1] . ' - ' . $userinfo[2];
    }
    // Verificar si el usuario existe
    if (!is_null($id_user)) {
        if (!isset($cbo_users[$id_user])) {
            Header("Location: ?menu={$module_name}");
            return NULL;
        }
    } else {
        $id_user = $userlist[0][0];
    }
    $ps = new paloSantoPortService($pDB);
    $pk = new paloSantoPortKnockUsers($pDB);
    // Construir lista de puertos autorizados
    $userauth = $pk->listAuthorizationsForUser($id_user);
    $portauths = array();
    if (is_array($userauth)) {
        foreach ($userauth as $auth) {
            $portauths[$auth['id_port']] = $auth['id'];
        }
    }
    $portlist = $ps->ObtainPuertos($ps->ObtainNumPuertos('', ''), 0, '', '');
    $listaIdPuertos = array();
    foreach ($portlist as $portinfo) {
        $listaIdPuertos[] = $portinfo['id'];
    }
    if (isset($_POST['apply']) && is_array($_POST['auth_port'])) {
        // Se requiere aplicar lista de cambios
        $listaNuevosPuertos = array_keys($_POST['auth_port']);
        $bReglasBorradas = FALSE;
        // Borrar la autorización de todos los puertos que ya no aparecen
        $bExito = TRUE;
        foreach ($portauths as $id_port => $id_auth) {
            if (!in_array($id_port, $listaNuevosPuertos)) {
                if (!$pk->deleteAuthorization($id_auth)) {
                    $smarty->assign("mb_title", _tr("ERROR"));
                    $smarty->assign("mb_message", $pk->errMsg);
                    $bExito = FALSE;
                    break;
                } else {
                    unset($portauths[$id_port]);
                    $bReglasBorradas = TRUE;
                }
            }
        }
        if (!$bExito) {
            break;
        }
        // Ingresar la autorización de los puertos nuevos
        foreach ($listaNuevosPuertos as $id_port) {
            if (in_array($id_port, $listaIdPuertos) && !isset($portauths[$id_port])) {
                $id_nueva_auth = $pk->insertAuthorization($id_user, $id_port);
                if (is_null($id_nueva_auth)) {
                    $smarty->assign("mb_title", _tr("ERROR"));
                    $smarty->assign("mb_message", $pk->errMsg);
                    $bExito = FALSE;
                    break;
                } else {
                    $portauths[$id_port] = $id_nueva_auth;
                }
            }
        }
        if ($bExito) {
            if ($bReglasBorradas) {
                // Ejecutar iptables para revocar las reglas del usuario
                require_once "modules/sec_rules/libs/paloSantoRules.class.php";
                $pr = new paloSantoRules($pDB);
                $pr->activateRules();
            }
            Header("Location: ?menu={$module_name}");
            return NULL;
        }
    }
    $data = array();
    if (is_array($portlist)) {
        foreach ($portlist as $portinfo) {
            $id_port = $portinfo['id'];
            $protocol_details = '';
            switch ($portinfo['protocol']) {
                case 'TCP':
                case 'UDP':
                    $protocol_details = (stripos($portinfo['details'], ':') === false ? _tr('Port') : _tr('Ports')) . ' ' . $portinfo['details'];
                    break;
                case 'ICMP':
                    $arr = explode(':', $portinfo['details']);
                    if (isset($arr[1])) {
                        $protocol_details = _tr('Type') . ": " . $arr[0] . " " . _tr('Code') . ": " . $arr[1];
                    }
                    break;
                default:
                    $protocol_details = _tr('Protocol Number') . ': ' . $portinfo['details'];
                    break;
            }
            $data[] = array("<input type=\"checkbox\" name=\"auth_port[{$id_port}]\" " . (isset($portauths[$id_port]) ? 'checked="checked"' : '') . ' />', htmlentities($portinfo['name'], ENT_COMPAT, 'UTF-8'), htmlentities($portinfo['protocol'], ENT_COMPAT, 'UTF-8'), $protocol_details);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr('Add/remove ports for user'));
    $oGrid->setColumns(array('', _tr('Port'), _tr('Protocol'), _tr('Details')));
    $oGrid->addSubmitAction('apply', _tr('Apply changes'), "modules/{$module_name}/images/Check.png");
    $oGrid->addComboAction('id_user', _tr('User'), $cbo_users, $id_user, 'refresh', 'submit();');
    // Construcción de la vista de puertos autorizados
    $oGrid->pagingShow(false);
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $oGrid->setData($data);
    return $oGrid->fetchGrid();
}
Esempio n. 28
0
function reportOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $other_destination_name = getParameter("other_destination_name");
    $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain);
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['other_destination_name'] = $other_destination_name;
    $total = $pOtherDestinations->getNumOtherDestinations($domain, $other_destination_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pOtherDestinations->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Other Destinations List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Other Destination Name");
    $arrColum[] = _tr("Dial Destination");
    $oGrid->setColumns($arrColum);
    $arrOtherDestinations = array();
    $arrData = array();
    if ($total != 0) {
        $arrOtherDestinations = $pOtherDestinations->getOtherDestinations($domain, $other_destination_name, $limit, $offset);
    }
    if ($arrOtherDestinations === false) {
        $error = _tr("Error to obtain Other Destinations") . $pOtherDestinations->errMsg;
        $arrOtherDestinations = array();
    }
    foreach ($arrOtherDestinations as $row) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$row["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id=" . $row['id'] . "&organization={$row['organization_domain']}'>" . htmlentities($row["description"], ENT_QUOTES, "UTF-8") . "</a>";
        $arrTmp[] = $row["destdial"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Other Destination"), array_slice($arrOrgz, 1), $selected = null, "create_other_destination", $onchange_select = null);
            } else {
                $oGrid->addNew("create_other_destination", _tr("ADD Other Destination"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["other_destination_name"] = $other_destination_name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Other Destination Name") . " = " . $other_destination_name, $_POST, array("other_destination_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Esempio n. 29
0
function reportMail($smarty, $module_name, $local_templates_dir, &$arrConf, &$pImap)
{
    $jsonObject = new PaloSantoJSON();
    $arrFilter = array();
    //obtenemos el mailbox que deseamos leer
    $mailbox = getParameter('folder');
    $action = getParameter('action');
    //creamos la connección al mailbox
    $pImap->setMailbox($mailbox);
    $smarty->assign("CURRENT_MAILBOX", $pImap->getMailbox());
    $result = $pImap->login($_SESSION['elastix_user'], $_SESSION['elastix_pass2']);
    if ($result === false) {
        if ($action == 'show_messages_folder') {
            $jsonObject->set_error($pImap->errMsg);
            return $jsonObject->createJSON();
        } else {
            $smarty->assign("ERROR_FIELD", $pImap->errMsg);
            return '';
        }
    }
    $listMailbox = $pImap->getMailboxList();
    if ($result === false) {
        $jsonObject->set_error($pImap->errMsg);
        $smarty->assign("ERROR_FIELD", $pImap->errMsg);
        return '';
    } else {
        $smarty->assign('MAILBOX_FOLDER_LIST', $listMailbox);
        $smarty->assign('NEW_FOLDER', _tr('New Folder'));
    }
    $view_filter_opt['all'] = _tr("All");
    $view_filter_opt['seen'] = _tr("Seen");
    $view_filter_opt['unseen'] = _tr("Unseen");
    $view_filter_opt['flagged'] = _tr("Important");
    $view_filter_opt['unflagged'] = _tr("No Important");
    $smarty->assign("ELX_MAIL_FILTER_OPT", $view_filter_opt);
    $filter_view = 'all';
    $tmp_filter_view = getParameter('email_filter1');
    if (array_key_exists($tmp_filter_view, $view_filter_opt)) {
        $filter_view = $tmp_filter_view;
    }
    $arrFilter = array("filter_view" => $filter_view);
    //obtenemos el numero de correos que ahi en el buzon
    //filtrando por los parámetros dados
    $listUID = array();
    $total = $pImap->getNumMails($arrFilter, $listUID);
    if ($total === false) {
        $total = 0;
        $jsonObject->set_error($pImap->errMsg);
        $smarty->assign("ERROR_FIELD", $pImap->errMsg);
    }
    $limit = 50;
    //sacamos calculamos el offset
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $currentPage = $oGrid->calculateCurrentPage();
    $numPage = $oGrid->calculateNumPage();
    $url['menu'] = $module_name;
    $url['email_filter1'] = $filter_view;
    $oGrid->setTitle(_tr('Contacts List'));
    $oGrid->setURL($url);
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $smarty->assign("TOTAL_MAILS", $total);
    $smarty->assign("CURRENT_PAGMAIL", $currentPage);
    $smarty->assign("NUM_PAGMAIL", $numPage);
    $smarty->assign("PAGINA", _tr("Page"));
    $smarty->assign("MESSAGES_LABEL", _tr("Messages"));
    $arrData = array();
    if ($total != 0) {
        $pImap->setMessageByPage($limit);
        $pImap->setOffset($offset);
        $emails = $pImap->readMails($listUID);
        if ($emails !== false) {
            foreach ($emails as $email) {
                $tmp = array();
                $class = 'elx_unseen_email';
                if ($email['SEEN'] == 1) {
                    $class = 'elx_seen_email';
                }
                $tmp[] = "<div class='elx_row {$class}' id={$email['UID']}>";
                $tmp[] = "<div class='ic'>";
                $tmp[] = "<div class='sel'><input type='checkbox' value='{$email['UID']}' class='inp1 checkmail'/></div>";
                //$tmp[]="<div class='icon'><img border='0' src='web/apps/home/images/mail2.png' class='icn_buz'></div>";
                $class = 'elx_unflagged_email';
                if ($email['FLAGGED'] == 1) {
                    $class = 'elx_flagged_email';
                }
                $tmp[] = "<div class='star'><span class='{$class} glyphicon glyphicon-star'></span></div>";
                $tmp[] = "</div>";
                //$tmp[]="<div class='email_msg_attr'>";
                $tmp[] = "<div class='from  elx_row_email_msg'> <span>" . htmlentities($email['from'], ENT_COMPAT, 'UTF-8') . "</span></div>";
                $tmp[] = "<div class='subject elx_row_email_msg'> <span>" . htmlentities($email['subject'], ENT_COMPAT, 'UTF-8') . "</span></div>";
                $tmp[] = "<div class='date elx_row_email_msg'><span>" . $email['date'] . "</span></div>";
                //$tmp[]="</div>";
                $tmp[] = "</div>";
                $arrData[] = $tmp;
            }
            $smarty->assign("MAILS", $arrData);
        } else {
            $jsonObject->set_error($pImap->errMsg);
            $smarty->assign("ERROR_FIELD", $pImap->errMsg);
        }
    }
    $pImap->close_mail_connection();
    $imapAlertErros = cleanAlertsImap();
    $listMailbox = array_diff($listMailbox, array($pImap->getMailbox()));
    $move_folder = array();
    foreach ($listMailbox as $value) {
        $move_folder[$value] = $value;
    }
    $smarty->assign("MOVE_FOLDERS", $move_folder);
    if ($action == 'show_messages_folder') {
        $message['email_content'] = $arrData;
        $message['email_filter1'] = $filter_view;
        $message['move_folders'] = $move_folder;
        $message['imap_alerts'] = $imapAlertErros;
        $message['paging']['total'] = $total;
        $message['paging']['currentPage'] = $currentPage;
        $message['paging']['numPages'] = $numPage;
        $jsonObject->set_message($message);
        return $jsonObject->createJSON();
    }
    $smarty->assign("IMAP_ALERTS", $imapAlertErros);
    $smarty->assign("ICON_TYPE", "web/apps/{$module_name}/images/mail2.png");
    $smarty->assign("FOLDER_LIST_TITLE", _tr("Folders"));
    $mark_opt['seen'] = _tr("Seen");
    $mark_opt['unseen'] = _tr("Unseen");
    $mark_opt['flagged'] = _tr("Important");
    $mark_opt['unflagged'] = _tr("No Important");
    $smarty->assign("ELX_MAIL_MARK_OPT", $mark_opt);
    $smarty->assign("MOVE_TO", _tr("Move to"));
    $smarty->assign("MARK_AS", _tr("Mark message as"));
    $smarty->assign("NO_EMAIL_MSG", _tr("Not messages"));
    $smarty->assign("VIEW", _tr("View"));
    $smarty->assign("SELECTED_VIEW_FILTER", $filter_view);
    $smarty->assign("SEND_MAIL_LABEL", _tr("Send"));
    $smarty->assign("ATTACH_LABEL", _tr("Attach"));
    $smarty->assign("ACTION_MSG", _tr('Actions'));
    $arrActionsMsg['reply'] = _tr('Reply');
    $arrActionsMsg['reply_all'] = _tr('Reply All');
    $arrActionsMsg['forward'] = _tr('Forward');
    $arrActionsMsg['delete'] = _tr('Delete');
    $arrActionsMsg['flag_important'] = _tr('Flag as Important');
    $arrActionsMsg['flag_unimportant'] = _tr('Flag as Unimportant');
    $smarty->assign("ELX_EMAIL_MSG_ACT", $arrActionsMsg);
    $html = $smarty->fetch("file:{$local_templates_dir}/form.tpl");
    $contenidoModulo = "<div>" . $html . "</div>";
    return $contenidoModulo;
}
Esempio n. 30
0
function reportWeakKeys($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pWeakKeys = new paloSantoWeakKeys($pDB);
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $total = $pWeakKeys->getNumWeakKeys($filter_field, $filter_value);
    $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDB2);
    $oGrid->enableExport();
    // enable csv export.
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->setTitle(_tr("Weak Secrets"));
    $oGrid->setIcon("modules/{$module_name}/images/security_weak_keys.png");
    $oGrid->setNameFile_Export(_tr("Weak Secrets"));
    if ($oGrid->isExportAction()) {
        $limit = $total;
        $offset = 0;
        $bExportation = true;
    } else {
        $limit = 30;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $bExportation = false;
    }
    $url = array('menu' => $module_name, 'filter_field' => $filter_field, 'filter_value' => $filter_value);
    $oGrid->setURL($url);
    $arrResult = $pWeakKeys->getWeakKeys($limit, $offset, $filter_field, $filter_value);
    $arrData = null;
    //$arrResult =$pWeakKeys->getWeakKeysChecker();
    $arrColumns = array(_tr("Extension"), _tr("Description"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $tech) {
            foreach ($tech as $key => $value) {
                $arrTmp[0] = $value['id'];
                $arrTmp[1] = $value['description'];
                $mensaje = getMensaje($value['id'], $value['data']);
                if ($mensaje != "OK" && !$bExportation) {
                    if ($pACL->isUserAdministratorGroup($_SESSION['elastix_user']) || $pACL->getUserExtension($_SESSION['elastix_user']) == $value['id']) {
                        $mensaje = _tr("Weak Key") . ": {$mensaje} &nbsp;<a href='?menu={$module_name}&action=change&id={$value['id']}'>" . _tr("Change Secret") . "</a>";
                    }
                }
                $arrTmp[2] = $mensaje;
                $arrData[] = $arrTmp;
            }
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $arrFormFilterWeakKeys = createFieldFilter();
    $oFilterForm = new paloForm($smarty, $arrFormFilterWeakKeys);
    $smarty->assign("SHOW", _tr("Show"));
    $_POST["filter_field"] = $filter_field;
    $_POST["filter_value"] = $filter_value;
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Extension") . " = " . $filter_value, $_POST, array("filter_field" => "extension", "filter_value" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}