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; }
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(' ', $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); }
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; }
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[] = " <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; }
function reportReportCall($smarty, $module_name, $local_templates_dir, &$pDB_cdr, &$pDB_billing, $arrConf, $arrLang) { $pReportCall = new paloSantoReportCall($pDB_cdr, $pDB_billing); //PARAMETERS $type = getParameter("option_fil"); $value_tmp = getParameter("value_fil"); $date_ini_tmp = getParameter("date_from"); $date_end_tmp = getParameter("date_to"); $order_by_tmp = getParameter("order_by"); $order_type_tmp = getParameter("order_type"); $action = getParameter("nav"); $start = getParameter("start"); $value = isset($value_tmp) ? $value_tmp : ""; $order_by = isset($order_by_tmp) ? $order_by_tmp : 1; $order_type = isset($order_type_tmp) ? $order_type_tmp : "asc"; $date_from = isset($date_ini_tmp) ? $date_ini_tmp : date("d M Y"); $date_to = isset($date_end_tmp) ? $date_end_tmp : date("d M Y"); $date_ini = translateDate($date_from) . " 00:00:00"; $date_end = translateDate($date_to) . " 23:59:59"; //********************************** //begin grid parameters $oGrid = new paloSantoGrid($smarty); $limit = 40; $total = $pReportCall->ObtainNumberDevices($type, $value); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->calculatePagination($action, $start); $offset = $oGrid->getOffsetValue(); $end = $oGrid->getEnd(); $urlFields = array('menu' => $module_name, 'option_fil' => $type, 'value_fil' => $value, 'date_from' => $date_from, 'date_to' => $date_to); $url = construirUrl($urlFields, array('nav', 'start')); $urlFields['order_by'] = $order_by; $urlFields['order_type'] = $order_type; $smarty->assign("order_by", $order_by); $smarty->assign("order_type", $order_type); $arrData = null; $arrResult = $pReportCall->ObtainReportCall($limit, $offset, $date_ini, $date_end, $type, $value, $order_by, $order_type); $order_type = $order_type == "desc" ? "asc" : "desc"; if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $val) { $ext = $val['extension']; $arrTmp[0] = $ext; $arrTmp[1] = $val['user_name']; $arrTmp[2] = $val['num_incoming_call']; $arrTmp[3] = $val['num_outgoing_call']; $arrTmp[4] = "<label style='color: green;' title='{$val['duration_incoming_call']} {$arrLang['seconds']}'>" . $pReportCall->Sec2HHMMSS($val['duration_incoming_call']) . "</label>"; $arrTmp[5] = "<label style='color: green;' title='{$val['duration_outgoing_call']} {$arrLang['seconds']}'>" . $pReportCall->Sec2HHMMSS($val['duration_outgoing_call']) . "</label>"; $arrTmp[6] = "<a href='javascript: popup_ventana(\"?menu={$module_name}&action=graph&rawmode=yes&ext={$ext}&dini={$date_ini}&dfin={$date_end}\");'>" . "" . $arrLang['Call Details'] . "</a>"; $arrData[] = $arrTmp; } } $img = "<img src='images/flecha_{$order_type}.png' border='0' align='absmiddle'>"; $leyend_1 = "<a class='link_summary_off' href='{$url}&order_by=1&order_type=asc'>{$arrLang["Extension"]}</a>"; $leyend_2 = "<a class='link_summary_off' href='{$url}&order_by=2&order_type=asc'>{$arrLang["User name"]}</a>"; $leyend_3 = "<a class='link_summary_off' href='{$url}&order_by=3&order_type=asc'>{$arrLang["Num. Incoming Calls"]}</a>"; $leyend_4 = "<a class='link_summary_off' href='{$url}&order_by=4&order_type=asc'>{$arrLang["Num. Outgoing Calls"]}</a>"; $leyend_5 = "<a class='link_summary_off' href='{$url}&order_by=5&order_type=asc'>{$arrLang["Sec. Incoming Calls"]}</a>"; $leyend_6 = "<a class='link_summary_off' href='{$url}&order_by=6&order_type=asc'>{$arrLang["Sec. Outgoing Calls"]}</a>"; if ($order_by == 1) { $leyend_1 = "<a class='link_summary_on' href='{$url}&order_by=1&order_type={$order_type}'>{$arrLang["Extension"]} {$img}</a>"; } else { if ($order_by == 2) { $leyend_2 = "<a class='link_summary_on' href='{$url}&order_by=2&order_type={$order_type}'>{$arrLang["User name"]} {$img}</a>"; } else { if ($order_by == 3) { $leyend_3 = "<a class='link_summary_on' href='{$url}&order_by=3&order_type={$order_type}'>{$arrLang["Num. Incoming Calls"]} {$img}</a>"; } else { if ($order_by == 4) { $leyend_4 = "<a class='link_summary_on' href='{$url}&order_by=4&order_type={$order_type}'>{$arrLang["Num. Outgoing Calls"]} {$img}</a>"; } else { if ($order_by == 5) { $leyend_5 = "<a class='link_summary_on' href='{$url}&order_by=5&order_type={$order_type}'>{$arrLang["Sec. Incoming Calls"]} {$img}</a>"; } else { if ($order_by == 6) { $leyend_6 = "<a class='link_summary_on' href='{$url}&order_by=6&order_type={$order_type}'>{$arrLang["Sec. Outgoing Calls"]} {$img}</a>"; } } } } } } $arrGrid = array("title" => $arrLang["Summary by Extension"], "icon" => "images/list.png", "width" => "100%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $urlFields, "columns" => array(0 => array("name" => $leyend_1, "property1" => ""), 1 => array("name" => $leyend_2, "property1" => ""), 2 => array("name" => $leyend_3, "property1" => ""), 3 => array("name" => $leyend_4, "property1" => ""), 4 => array("name" => $leyend_5, "property1" => ""), 5 => array("name" => $leyend_6, "property1" => ""), 6 => array("name" => $arrLang["Details"], "property1" => ""))); //begin section filter $arrFormFilterReportCall = createFieldForm($arrLang); $oFilterForm = new paloForm($smarty, $arrFormFilterReportCall); $_POST['option_fil'] = $type; $_POST['value_fil'] = $value; $_POST['date_from'] = $date_from; $_POST['date_to'] = $date_to; $smarty->assign("SHOW", $arrLang["Show"]); if ($_POST["date_from"] === "") { $_POST["date_from"] = " "; } if ($_POST['date_to'] === "") { $_POST['date_to'] = " "; } $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $date_from . ", " . _tr("End Date") . " = " . $date_to, $_POST, array("date_from" => date("d M Y"), "date_to" => date("d M Y")), true); $valueType = ""; if (!is_null($type)) { if ($type == "Ext") { $valueType = _tr("Extension"); } else { $valueType = _tr("User"); } } $oGrid->addFilterControl(_tr("Filter applied: ") . $valueType . " = " . $value, $_POST, array("option_fil" => "Ext", "value_fil" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function report_backup_restore($smarty, $module_name, $local_templates_dir, $dir_backup, &$pDB) { $total_archivos = array_reverse(array_map('basename', glob("{$dir_backup}/*.tar"))); // Paginacion $limit = 10; $total = count($total_archivos); $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $nombre_archivos = array_slice($total_archivos, $offset, $limit); //Fin Paginacion // obtencion de parametros desde la base $pFTPBackup = new paloSantoFTPBackup($pDB); $_DATA = $pFTPBackup->getStatusAutomaticBackupById(1); if (!(is_array($_DATA) & count($_DATA) > 0)) { $_DATA['status'] = "DISABLED"; } $arrData = null; if (is_array($nombre_archivos) && $total > 0) { foreach ($nombre_archivos as $key => $nombre_archivo) { $arrTmp[0] = "<input type='checkbox' name='chk[" . $nombre_archivo . "]' id='chk[" . $nombre_archivo . "]'/>"; $arrTmp[1] = "<a href='?menu={$module_name}&action=download_file&file_name={$nombre_archivo}&rawmode=yes'>{$nombre_archivo}</a>"; $fecha = ""; // se parsea el archivo para obtener la fecha if (preg_match("/\\w*-\\d{4}\\d{2}\\d{2}\\d{2}\\d{2}\\d{2}-\\w{2}\\.\\w*/", $nombre_archivo)) { //elastixbackup-20110720122759-p7.tar $arrMatchFile = preg_split("/-/", $nombre_archivo); $data = $arrMatchFile[1]; $fecha = substr($data, -8, 2) . "/" . substr($data, -10, 2) . "/" . substr($data, 0, 4) . " " . substr($data, -6, 2) . ":" . substr($data, -4, 2) . ":" . substr($data, -2, 2); $id = $arrMatchFile[1] . "-" . $arrMatchFile[2]; } $arrTmp[2] = $fecha; $arrTmp[3] = "<input type='submit' name='submit_restore[" . $nombre_archivo . "]' value='" . _tr('Restore') . "' class='button' />"; $arrData[] = $arrTmp; } } $arrGrid = array("title" => _tr('Backup List'), "url" => array('menu' => $module_name), "icon" => "/modules/{$module_name}/images/system_backup_restore.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => ""), 1 => array("name" => _tr('Name Backup')), 2 => array("name" => _tr('Date')), 3 => array("name" => _tr('Action')))); $time = $_DATA['status']; $smarty->assign("FILE_UPLOAD", _tr('File Upload')); $smarty->assign("AUTOMATIC", _tr('AUTOMATIC')); $smarty->assign("UPLOAD", _tr('Upload')); $smarty->assign("FTP_BACKUP", _tr('FTP Backup')); $oGrid->addNew("backup", _tr("Backup")); $oGrid->deleteList(_tr("Are you sure you wish to delete backup (s)?"), 'delete_backup', _tr("Delete")); $oGrid->customAction("view_form_FTP", _tr("FTP Backup")); $backupIntervals = array('DISABLED' => _tr('DISABLED'), 'DAILY' => _tr('DAILY'), 'MONTHLY' => _tr('MONTHLY'), 'WEEKLY' => _tr('WEEKLY')); $oGrid->addComboAction("time", _tr("AUTOMATIC"), $backupIntervals, $time, 'automatic'); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); return $contenidoModulo; }
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" => "modules/{$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; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoACL.class.php"; include_once "modules/{$module_name}/configs/default.conf.php"; load_language_module($module_name); //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); /////conexion a php $pDB = new paloDB($arrConf['elastix_dsn']['acl']); //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']; if (!empty($pDB->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $arrData = array(); $pACL = new paloACL($pDB); if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } $arrFormElements = array("description" => array("LABEL" => _tr("Description"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => _tr("Group"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); //description id name $contenidoModulo = ""; $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("icon", "modules/{$module_name}/images/system_groups.png"); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); if (isset($_POST['submit_create_group'])) { // Implementar include_once "libs/paloSantoForm.class.php"; $arrFillGroup['group'] = ''; $arrFillGroup['description'] = ''; $oForm = new paloForm($smarty, $arrFormElements); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $arrFillGroup); } else { if (isset($_POST['edit'])) { // Tengo que recuperar la data del usuario $pACL = new paloACL($pDB); $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrFillGroup['group'] = $arrGroup[0][1]; $arrFillGroup['description'] = $arrGroup[0][2]; // Implementar include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr('Edit Group') . " \"" . $arrFillGroup['group'] . "\"", $arrFillGroup); } } else { if (isset($_POST['submit_save_group'])) { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); // Creo el Grupo $pACL->createGroup($_POST['group'], $_POST['description']); if (!empty($pACL->errMsg)) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } } else { if (isset($_POST['submit_apply_changes'])) { $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { $group = $arrGroup[0][1]; $description = $arrGroup[0][2]; include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); if (!$pACL->updateGroup($_POST['id_group'], $_POST['group'], $_POST['description'])) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Manejo de Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $arrFillGroup['group'] = $_POST['group']; $arrFillGroup['description'] = $_POST['description']; $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $arrFillGroup); } } } else { if (isset($_GET['action']) && $_GET['action'] == "view") { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error $oForm->setViewMode(); // Esto es para activar el modo "preview" $arrGroup = $pACL->getGroups($_GET['id']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { // Conversion de formato if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrTmp['group'] = $arrGroup[0][1]; $arrTmp['description'] = $arrGroup[0][2]; $smarty->assign("id_group", htmlspecialchars($_GET['id'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("View Group"), $arrTmp); // hay que pasar el arreglo } } else { if (isset($_POST['delete'])) { //- TODO: Validar el id de group if (isset($_POST['id_group']) && $_POST['id_group'] == '1') { // No se puede eliminar al grupo admin $smarty->assign("mb_message", _tr("The administrator group cannot be deleted because is the default Elastix Group. You can delete any other group.")); } else { if ($pACL->HaveUsersTheGroup($_POST['id_group']) == TRUE) { $smarty->assign("mb_message", _tr("The Group have users assigned. You can delete any group that does not have any users assigned in it.")); } else { $pACL->deleteGroup($_POST['id_group']); } } } $nav = getParameter("nav"); $start = getParameter("start"); $total = $pACL->getNumGroups(); $total = $total == NULL ? 0 : $total; $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->pagingShow(true); $oGrid->setURL("?menu=grouplist"); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $arrGroups = $pACL->getGroupsPaging($limit, $offset); $end = count($arrGroups); $arrData = array(); foreach ($arrGroups as $group) { $arrTmp = array(); if ($group[1] == 'administrator') { $group[1] = _tr('administrator'); } else { if ($group[1] == 'operator') { $group[1] = _tr('operator'); } else { if ($group[1] == 'extension') { $group[1] = _tr('extension'); } } } if ($group[2] == 'total access') { $group[2] = _tr('total access'); } else { if ($group[2] == 'operator') { $group[2] = _tr('operator'); } else { if ($group[2] == 'extension user') { $group[2] = _tr('extension user'); } } } $arrTmp[0] = " <a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>"; //id_group name $arrTmp[1] = $group[2]; //description $arrData[] = $arrTmp; } $arrGrid = array("title" => _tr("Group List"), "icon" => "/modules/{$module_name}/images/system_groups.png", "columns" => array(0 => array("name" => _tr("Group"), "property1" => ""), 1 => array("name" => _tr("Description"), "property1" => ""))); $oGrid->addNew("submit_create_group", _tr("Create New Group")); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); } } } } } return $contenidoModulo; }
function reportGroupPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $wasSaved = false, $value_action = "", $value_start = 0) { global $arrLang; $pGroupPermission = new paloSantoGroupPermission(); $filter_group = getParameter("filter_group"); $id_administrador = 1; $filter_group = isset($filter_group) ? $filter_group : $id_administrador; $filter_resource = getParameter("filter_resource"); $action = getParameter("nav"); $start = getParameter("start"); if ($wasSaved) { $action = $value_action; $start = $value_start; } //begin grid parameters $oGrid = new paloSantoGrid($smarty); $parameter_to_find = array(); $lang = get_language(); if ($lang != "en") { foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); $filter_value = strtolower(trim($filter_resource)); if ($filter_value != "") { if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } } $parameter_to_find[] = $filter_resource; if (empty($parameter_to_find)) { $totalGroupPermission = $pGroupPermission->ObtainNumResouces($filter_resource); } else { $totalGroupPermission = $pGroupPermission->ObtainNumResouces($parameter_to_find); } $limit = 25; $total = $totalGroupPermission; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->calculatePagination($action, $start); $offset = $oGrid->getOffsetValue(); $end = $oGrid->getEnd(); $arrData = null; if (empty($parameter_to_find)) { $arrResult = $pGroupPermission->ObtainResources($limit, $offset, $filter_resource); } else { $arrResult = $pGroupPermission->ObtainResources($limit, $offset, $parameter_to_find); } $url = array('menu' => $module_name, 'filter_group' => $filter_group, 'filter_resource' => $filter_resource); $idGroup = $filter_group; $arrPermisos = $pGroupPermission->loadGroupPermissionsACL($idGroup); $arrPermisos = OrderGroupPermissions($arrPermisos); $isAdministrator = $idGroup == 1 ? true : false; if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $resource) { $disabled = ""; if (($resource["name"] == 'usermgr' || $resource["name"] == 'grouplist' || $resource["name"] == 'userlist' || $resource["name"] == 'group_permission') & $isAdministrator) { $disabled = "disabled='disabled'"; } $checked0 = ""; $checked1 = ""; $checked2 = ""; $checked3 = ""; $checked4 = ""; if (isset($arrPermisos[$resource["name"]])) { $T = $arrPermisos[$resource["name"]]; $T = $T["actions"]; foreach ($T as $num => $key) { if ($key == "access") { $checked0 = "checked"; } if ($key == "view") { $checked1 = "checked"; } if ($key == "create") { $checked2 = "checked"; } if ($key == "delete") { $checked3 = "checked"; } if ($key == "update") { $checked4 = "checked"; } } } $arrTmp[0] = "<input type='checkbox' {$disabled} name='groupPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked0}>"; $arrTmp[1] = _tr($resource["description"]); $arrTmp[2] = "<input type='checkbox' {$disabled} name='viewPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked1}>"; $arrTmp[3] = "<input type='checkbox' {$disabled} name='createPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked2}>"; $arrTmp[4] = "<input type='checkbox' {$disabled} name='deletePermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked3}>"; $arrTmp[5] = "<input type='checkbox' {$disabled} name='updatePermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked4}>"; $arrData[] = $arrTmp; } } $arrGrid = array("title" => _tr("Group Permission"), "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(0 => array("name" => "<input class='button' type='submit' name='apply' value='" . _tr('Apply') . "' />", "property1" => ""), 1 => array("name" => _tr("Resource"), "property1" => ""))); //begin section filter $arrFormFilterGroupPermission = createFieldFilter($pGroupPermission); $oFilterForm = new paloForm($smarty, $arrFormFilterGroupPermission); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_group"] = $filter_group; $_POST["filter_resource"] = $filter_resource; $nameGroup = $arrFormFilterGroupPermission["filter_group"]["INPUT_EXTRA_PARAM"][$filter_group]; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Group") . " = {$nameGroup}", $_POST, array("filter_group" => 1), true); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Resource") . " = {$filter_resource}", $_POST, array("filter_resource" => "")); //ayuda para el pagineo -> estod datos son tomados en la function applyGroupPermission($smarty, $module_name, ...... //ayuda a que despues de "aplicar" se quede en la misma pagina $smarty->assign("resource_apply", htmlspecialchars($filter_resource, ENT_COMPAT, 'UTF-8')); $smarty->assign("limit_apply", htmlspecialchars($limit, ENT_COMPAT, 'UTF-8')); $smarty->assign("offset_apply", htmlspecialchars($offset, ENT_COMPAT, 'UTF-8')); $smarty->assign("action_apply", htmlspecialchars($action, ENT_COMPAT, 'UTF-8')); $smarty->assign("start_apply", htmlspecialchars($start, ENT_COMPAT, 'UTF-8')); $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; }
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; }
function reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount) { if (isset($_POST['delete'])) { //- TODO: Validar el id de user if ($userLevel1 == "admin") { if (isset($_POST['id_user']) && $_POST['id_user'] == '1') { // No se puede elimiar al usuario admin $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["The admin user cannot be deleted because is the default Elastix administrator. You can delete any other user."]); } else { $pACL->deleteUser($_POST['id_user']); } } else { $smarty->assign("mb_message", $arrLang["userNoAllowed"]); } } $nav = getParameter("nav"); $start = getParameter("start"); $total = $pACL->getNumUsers(); $total = $total == NULL ? 0 : $total; $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->pagingShow(true); $oGrid->setURL("?menu=userlist"); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $arrUsers = $pACL->getUsersPaging($limit, $offset); $arrData = array(); $typeUser = ""; foreach ($arrUsers as $user) { $arrMembership = $pACL->getMembership($user[0]); $group = ""; if (is_array($arrMembership)) { foreach ($arrMembership as $groupName => $groupId) { if ($groupName == 'administrator') { $groupName = $arrLang['administrator']; } else { if ($groupName == 'operator') { $groupName = $arrLang['operator']; } else { if ($groupName == 'extension') { $groupName = $arrLang['extension']; } } } $group .= ucfirst($groupName) . " "; } } $arrTmp = array(); //$arrTmp[0] = " <a href='?menu=usernew&action=view&id=" . $user['id'] . "'>" . $user['name'] . "</a>"; //$arrTmp[1] = $user['description']; if ($idUserAccount) { $arrTmp[0] = " <a href='?menu=userlist&action=view&id=" . $user[0] . "'>" . htmlentities($user[1], ENT_COMPAT, 'UTF-8') . "</a>"; $arrTmp[1] = htmlentities($user[2], ENT_COMPAT, 'UTF-8'); $arrTmp[2] = htmlentities($group, ENT_COMPAT, 'UTF-8'); if ($user[3] == '' || is_null($user[3])) { $arrTmp[3] = _tr("No extension associated"); } else { $arrTmp[3] = htmlentities($user[3], ENT_COMPAT, 'UTF-8'); } $arrData[] = $arrTmp; $smarty->assign("usermode", "admin"); $typeUser = "******"; $end++; } else { if ($user[1] == $userAccount) { $arrTmp[0] = " <a href='?menu=userlist&action=view&id=" . $user[0] . "'>" . htmlentities($user[1], ENT_COMPAT, 'UTF-8') . "</a>"; $arrTmp[1] = htmlentities($user[2], ENT_COMPAT, 'UTF-8'); $arrTmp[2] = htmlentities($group, ENT_COMPAT, 'UTF-8'); if ($user[3] == '' || is_null($user[3])) { $arrTmp[3] = _tr("No extension associated"); } else { $arrTmp[3] = htmlentities($user[3], ENT_COMPAT, 'UTF-8'); } $arrData[] = $arrTmp; $smarty->assign("usermode", "other"); $typeUser = "******"; $end++; } } } $arrGrid = array("title" => $arrLang["User List"], "icon" => "images/user.png", "columns" => array(0 => array("name" => $arrLang["Login"], "property1" => ""), 1 => array("name" => $arrLang["Real Name"], "property1" => ""), 2 => array("name" => $arrLang["Group"], "property1" => ""), 3 => array("name" => $arrLang["Extension"], "property1" => ""))); if (!($typeUser == "other")) { $oGrid->addNew("submit_create_user", _tr("Create New User")); } $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function reportReportedeTroncalesusadasporHoraeneldia($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, &$pDB_asterisk) { $pReportedeTroncalesusadasporHoraeneldia = new paloSantoReportedeTroncalesusadasporHoraeneldia($pDB); // PS se obtiene el arreglo con las trunks para mostrarlas en el filtro //$arrTrunk1 = getTrunk($pDB, $pDB_asterisk);//Trunks //diana //llamamos funcion nueva $arrTrunk = obtener_nuevas_trunks($pDB, $pDB_asterisk); // valores del filtro $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); $date_from = getParameter("date_from"); $date_to = getParameter("date_to"); // si la fecha no está seteada en el filtro $_POST["date_from"] = isset($date_from) ? $date_from : date("d M Y"); $_POST["date_to"] = isset($date_to) ? $date_to : date("d M Y"); $date_from = isset($date_from) ? date('Y-m-d', strtotime($date_from)) : date("Y-m-d"); $date_to = isset($date_to) ? date('Y-m-d', strtotime($date_to)) : date("Y-m-d"); // para setear la trunk la primera vez $filter_value = getParameter("filter_value"); if (!isset($filter_value)) { $trunk = array_shift(array_keys($arrTrunk)); //Trunks $_POST["filter_value"] = $trunk; $filter_value = $trunk; } //validacion para que los filtros se queden seteados con el valor correcto, correccion de bug que se estaba dando en caso de pagineo $_POST["filter_value"] = $filter_value; $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); // begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes'; $limit = 50; $offset = 0; // se obtienen los datos que se van a mostrar $arrData = null; $filter_value = trim($filter_value); $recordset = $pReportedeTroncalesusadasporHoraeneldia->listarTraficoLlamadasHora($date_from, $date_to, empty($filter_value) ? NULL : $filter_value); if (!is_array($recordset)) { $smarty->assign(array('mb_title' => _tr('Query Error'), 'mb_message' => $oCalls->errMsg)); $recordset = array(); } $total = count($recordset); $oGrid->setLimit($limit); $oGrid->setTotal($total); if ($bElastixNuevo) { $offset = $oGrid->calculateOffset(); } else { $action = getParameter("nav"); $start = getParameter("start"); $oGrid->calculatePagination($action, $start); $end = $oGrid->getEnd(); } $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value, "date_from" => $date_from, "date_to" => $date_to); // se guarda la data en un arreglo que luego es enviado como parámetro para crear el reporte if (is_array($recordset)) { $arrData = array(); $total = array('entered' => 0, 'terminada' => 0, 'abandonada' => 0, 'en-cola' => 0, 'fin-monitoreo' => 0); foreach ($recordset as $iHora => $tupla) { $arrData[] = array(sprintf('%02d:00:00 - %02d:00:00', $iHora, $iHora + 1), $tupla['entered'], $tupla['terminada'], $tupla['abandonada'], $tupla['en-cola'], $tupla['fin-monitoreo']); foreach (array_keys($total) as $k) { $total[$k] += $tupla[$k]; } } $sTagInicio = !$bExportando ? '<b>' : ''; $sTagFinal = $sTagInicio != '' ? '</b>' : ''; $arrData[] = array($sTagInicio . _tr('TOTAL') . $sTagFinal, $sTagInicio . $total['entered'] . $sTagFinal, $sTagInicio . $total['terminada'] . $sTagFinal, $sTagInicio . $total['abandonada'] . $sTagFinal, $sTagInicio . $total['en-cola'] . $sTagFinal, $sTagInicio . $total['fin-monitoreo'] . $sTagFinal); } //begin section filter $arrFormFilterReportedeTroncalesusadasporHoraeneldia = createFieldFilter($arrTrunk); $smarty->assign("SHOW", _tr("Show")); $oFilterForm = new paloForm($smarty, $arrFormFilterReportedeTroncalesusadasporHoraeneldia); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST, $_GET); //end section filter $oGrid->showFilter($htmlFilter); if ($bElastixNuevo) { $oGrid->setURL($url); $oGrid->setData($arrData); $arrColumnas = array(_tr("Time Period "), _tr("Entered"), _tr("Answered"), _tr("Abandoned"), _tr("In queue"), _tr("Without monitoring ")); $oGrid->setColumns($arrColumnas); $oGrid->setTitle(_tr("Reporte de Troncales usadas por Hora en el dia")); $oGrid->pagingShow(true); $oGrid->setNameFile_Export(_tr("Reporte de Troncales usadas por Hora en el dia")); return $oGrid->fetchGrid(); } else { global $arrLang; $url = construirURL($url, array('nav', 'start')); $offset = 0; $limit = $total + 1; // se crea el grid $arrGrid = array("title" => _tr("Reporte de Troncales usadas por Hora en el dia"), "url" => $url, "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => _tr("Time Period "), "property1" => ""), 1 => array("name" => _tr("Entered"), "property1" => ""), 2 => array("name" => _tr("Answered"), "property1" => ""), 3 => array("name" => _tr("Abandoned"), "property1" => ""), 4 => array("name" => _tr("In queue"), "property1" => ""), 5 => array("name" => _tr("Without monitoring "), "property1" => ""))); if ($bExportando) { $fechaActual = date("d M Y"); header("Cache-Control: private"); header("Pragma: cache"); header('Content-Type: application/octec-stream'); $title = "\"" . $fechaActual . ".csv\""; header("Content-disposition: inline; filename={$title}"); header('Content-Type: application/force-download'); } 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; } }