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] = " <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'] . " "; $arrTmp[5] = $fax['clid_number'] . " "; $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(); }
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; }
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 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} <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; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir) { $smarty->assign(array('SEARCH' => _tr('Search'))); $oFax = new paloFaxVisor(); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements()); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All'); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out')); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL)); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true); $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['faxes_delete']); // Se aborta el intento de borrar faxes, si había uno. } $url = array_merge($url, $paramFiltro); // Ejecutar el borrado, si se ha validado. if (isset($_POST['faxes_delete']) && isset($_POST['faxes']) && is_array($_POST['faxes']) && count($_POST['faxes']) > 0) { $msgError = NULL; foreach ($_POST['faxes'] as $idFax) { if (!$oFax->deleteInfoFax($idFax)) { if ($oFax->errMsg = '') { $msgError = _tr('Unable to eliminate pdf file from the path.'); } else { $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg; } } } if (!is_null($msgError)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } } $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("modules/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; $total = $oFax->obtener_cantidad_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $oFax->obtener_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); $oGrid->setColumns(array("", _tr('Type'), _tr('File'), _tr('Company Name'), _tr('Company Fax'), _tr('Fax Destiny'), _tr('Fax Date'), _tr('Status'), _tr('Options'))); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax', 'errormsg') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } if (empty($fax['status']) && !empty($fax['errormsg'])) { $fax['status'] = 'failed'; } $arrData[] = array('<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />', _tr($fax['type']), strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file'], $fax['company_name'], $fax['company_fax'], $fax['destiny_name'] . " - " . $fax['destiny_fax'], $fax['date'], _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']), "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"); } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $oGrid->setData($arrData); $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }
function reportRules($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pRules = new paloSantoRules($pDB); $action = getParameter("action"); $id = getParameter("id"); $smarty->assign("ID", $id); $oFilterForm = new paloForm($smarty, array()); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $first_time = $pRules->isFirstTime(); //$oGrid->setTplFile("$local_templates_dir/_list.tpl"); $totalRules = $pRules->ObtainNumRules(); $error = ""; if ($action == 'edit') { $arrtmp = $pRules->getRule($id); $arripsource = explode("/", $arrtmp['ip_source']); $arripdst = explode("/", $arrtmp['ip_destiny']); $arrValues['id_traffic'] = $arrtmp['traffic']; $arrValues['interface_in'] = $arrtmp['eth_in']; $arrValues['interface_out'] = $arrtmp['eth_out']; $arrValues['ip_source'] = $arripsource[0]; $arrValues['mask_source'] = $arripsource[1]; $arrValues['port_in'] = $arrtmp['sport']; $arrValues['ip_destin'] = $arripdst[0]; $arrValues['mask_destin'] = $arripdst[1]; $arrValues['port_out'] = $arrtmp['dport']; $arrValues['type_icmp'] = $arrtmp['icmp_type']; $arrValues['id_ip'] = $arrtmp['number_ip']; $arrValues['id_protocol'] = $arrtmp['protocol']; $arrValues['target'] = $arrtmp['target']; $arrValues['orden'] = $arrtmp['rule_order']; $arrValues['state'] = $arrtmp['state']; $arrValues['id'] = $id; $content = newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $action); return $content; } elseif ($action == 'Activate') { $pRules->setActivated($id); } elseif ($action == 'Desactivate') { $pRules->setDesactivated($id); } $limit = 30; $total = $totalRules; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("FireWall Rules")); $oGrid->setIcon("/modules/{$module_name}/images/security_firewall_rules.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = "?menu={$module_name}"; $oGrid->setURL($url); $arrData = null; $arrResult = $pRules->ObtainRules($limit, $offset); $start = getParameter("start"); $accion = getParameter("nav"); if ($accion == "end") { if ($total % $limit == 0) { $start = $total - 2 * $limit + 1; } else { $start = $total - $total % $limit - $limit + 1; } } elseif ($accion == "previous") { $start = $start - 2 * $limit; } if ($first_time) { $arrColumns = array("", _tr("Order"), _tr("Traffic"), _tr("Target"), _tr("Interface"), _tr("IP Source"), _tr("IP Destiny"), _tr("Protocol"), _tr("Details")); } else { $oGrid->deleteList("Are you sure you wish to delete the Rule?", "delete", _tr("Delete")); $arrColumns = array("", _tr("Order"), _tr("Traffic"), _tr("Target"), _tr("Interface"), _tr("IP Source"), _tr("IP Destiny"), _tr("Protocol"), _tr("Details"), "", ""); } $oGrid->setColumns($arrColumns); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { if (!$first_time) { $arrTmp[0] = "<input type='checkbox' name='id_" . $value['id'] . "' />"; $arrTmp[1] = "<div id='div_{$value['id']}' style='width: 22px; font-size: 14pt;color:#E35332;float:left;text-align:right'>{$value['rule_order']} </div>"; } if (!$first_time) { //if($offset!=0) $arrTmp[1] .= "<a href='javascript:void(0);' class='up' id='rulerup_{$value['id']}_{$value['rule_order']}'>" . "<img src='modules/{$module_name}/images/up.gif' border=0 title='" . _tr('Up') . "' /></a>" . "<a href='javascript:void(0);' class='down' id='rulerdown_{$value['id']}_{$value['rule_order']}'>" . "<img src='modules/{$module_name}/images/down.gif' border=0 title='" . _tr('Down') . "' /></a>"; /*else $arrTmp[1].="<a href='?menu=$module_name&action=$changeOrder&id=$value[id]&order=$value[rule_order]&direction=up;' class='up' id='rulerup_$value[id]_$value[rule_order]'>"."<img src='modules/$module_name/images/up.gif' border=0 title='"._tr('Up')."' /></a>"."<a href='javascript:void(0);' class='down' id='rulerdown_$value[id]_$value[rule_order]'>"."<img src='modules/$module_name/images/down.gif' border=0 title='"._tr('Down')."' /></a>";*/ } if ($value['traffic'] == "INPUT") { $image = "modules/{$module_name}/images/fw_input.gif"; $title = _tr("INPUT"); $arrTmp[4] = _tr("IN") . ": {$value['eth_in']}"; } elseif ($value['traffic'] == "OUTPUT") { $image = "modules/{$module_name}/images/fw_output.gif"; $title = _tr("OUTPUT"); $arrTmp[4] = _tr("OUT") . ": {$value['eth_out']}"; } else { $image = "modules/{$module_name}/images/fw_forward.gif"; $title = _tr("FORWARD"); $arrTmp[4] = _tr("IN") . ": {$value['eth_in']}<br />" . _tr("OUT") . ": {$value['eth_out']}"; } $arrTmp[2] = "<a><img src='{$image}' border=0 title='" . _tr($title) . "'</a>"; if ($value['target'] == "ACCEPT") { $image = "modules/{$module_name}/images/target_accept.gif"; $title = _tr("ACCEPT"); } elseif ($value['target'] == "DROP") { $image = "modules/{$module_name}/images/target_drop.gif"; $title = _tr("DROP"); } else { $image = "modules/{$module_name}/images/target_drop.gif"; $title = _tr("REJECT"); } $arrTmp[3] = "<a><img src='{$image}' border=0 title='" . _tr($title) . "'</a>"; $arrTmp[5] = $value['ip_source']; $arrTmp[6] = $value['ip_destiny']; $arrTmp[7] = $value['protocol']; if ($value['protocol'] == "ICMP") { if ($value["icmp_type"] != "" && $value["icmp_type"] != "ANY") { $protocolName = $pRules->getProtocolName($value["icmp_type"]); } else { $protocolName = $value["icmp_type"]; } $arrTmp[8] = _tr("Type") . ": {$protocolName}"; } else { if ($value['protocol'] == "IP") { if ($value["number_ip"] != "" && $value["number_ip"] != "ANY") { $protocolName = $pRules->getProtocolName($value["number_ip"]); } else { $protocolName = $value["number_ip"]; } $arrTmp[8] = _tr("Number Protocol IP") . ": {$protocolName}"; } else { if ($value['protocol'] == "TCP" || $value['protocol'] == "UDP") { if ($value["sport"] != "" && $value["sport"] != "ANY") { $sportName = $pRules->getProtocolName($value["sport"]); } else { $sportName = $value["sport"]; } if ($value["dport"] != "" && $value["dport"] != "ANY") { $dportName = $pRules->getProtocolName($value["dport"]); } else { $dportName = $value["dport"]; } $arrTmp[8] = _tr("Source Port") . ": {$sportName}" . "<br />" . _tr("Destiny Port") . ": {$dportName}"; } else { if ($value['protocol'] == "STATE") { $arrTmp[8] = $value['state']; } else { $arrTmp[8] = ""; } } } } if (!$first_time) { if ($value['activated'] == 1) { $image = "modules/{$module_name}/images/foco_on.gif"; $activated = "Desactivate"; } else { $image = "modules/{$module_name}/images/foco_off.gif"; $activated = "Activate"; } if ($offset != 0) { $arrTmp[9] = "<a href='?menu={$module_name}&action=" . $activated . "&id=" . $value['id'] . "&nav=next&start={$start}'>" . "<img src='{$image}' border=0 title='" . _tr($activated) . "'</a>"; } else { $arrTmp[9] = "<a href='?menu={$module_name}&action=" . $activated . "&id=" . $value['id'] . "'>" . "<img src='{$image}' border=0 title='" . _tr($activated) . "'</a>"; } $arrTmp[10] = "<a href='?menu={$module_name}&action=edit&id=" . $value['id'] . "'>" . "<img src='modules/{$module_name}/images/edit.gif' border=0 title='" . _tr('Edit') . "'</a>"; } $arrData[] = $arrTmp; } // $arrData[] = array("ctrl" => "separator_line", "start" => 0); } $oGrid->setData($arrData); //$smarty->assign("desactivate", _tr("Desactivate FireWall")); if ($first_time) { $smarty->assign("mb_message", "<b>" . _tr("The firewall is totally desactivated. It is recommended to activate the firewall rules") . "</b>"); $smarty->assign("mb_title", _tr("WARNING")); $mensaje = _tr("The firewall is totally desactivated. It is recommended to activate the firewall rules"); $mensaje2 = _tr("Activate FireWall"); $oGrid->customAction("exec", $mensaje2); } else { $oGrid->customAction("desactivate", _tr("Desactivate FireWall")); $oGrid->addNew("new", _tr("New Rule")); $mensaje = _tr("You have made changes to the definition of firewall rules, for this to take effect in the system press the next button"); $mensaje2 = _tr("Save Changes"); } if ($pRules->isExecutedInSystem()) { $smarty->assign("BORDER", ""); $smarty->assign("DISPLAY", "display:none;"); } else { $smarty->assign("executed_in_sys", $mensaje); $smarty->assign("BORDER", "border:1px solid; color:#AAAAAA"); $smarty->assign("DISPLAY", ""); } $smarty->assign("exec", $mensaje2); if (!$first_time) { if (!$pRules->isExecutedInSystem()) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $mensaje . " <form method='POST' style='margin-bottom:0;' action='?menu_sec_rules'><input class='button' type='submit' name='exec' value='{$mensaje2}'></form>"); } } $contenidoModulo = $oGrid->fetchGrid(); if ($arrConf["mainTheme"] == "elastixneo") { $contenidoModulo = "<div id='msg_status' class='mensajeStatus'></div>" . $contenidoModulo; } if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action={$url}>{$contenidoModulo}</form>"; } //end grid parameters return $contenidoModulo; }
function viewFormDomain($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang) { $pEmail = new paloEmail($pDB); $oGrid = new paloSantoGrid($smarty); $arrDomains = $pEmail->getDomains(); $end = count($arrDomains); $arrData = array(); $oGrid->pagingShow(true); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setTitle(_tr("Domain List")); $oGrid->setIcon("modules/{$module_name}/images/email_domains.png"); $arrColumns = array(_tr("Domain"), _tr("Number of Accounts")); $oGrid->setColumns($arrColumns); $total = 0; $limit = 20; $limitInferior = ""; $limitSuperior = ""; $oGrid->setLimit($limit); $oGrid->addNew("submit_create_domain", _tr('Create Domain')); if (is_array($arrDomains) && $end > 0) { $oGrid->setTotal($end); $offset = $oGrid->calculateOffset(); $cont = 0; $limitInferior = $offset; $limitSuperior = $offset + $limit - 1; foreach ($arrDomains as $domain) { $arrTmp = array(); if ($cont > $limitSuperior) { break; } if ($cont >= $limitInferior & $cont <= $limitSuperior) { $arrTmp[0] = " <a href='?menu=email_domains&action=view&id=" . $domain[0] . "'>{$domain['1']}</a>"; //obtener el numero de cuentas que posee ese email $arrTmp[1] = $pEmail->getNumberOfAccounts($domain[0]); $arrData[] = $arrTmp; } $cont++; } } else { $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } $oGrid->setData($arrData); $content = $oGrid->fetchGrid(); return $content; }
function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $pACL, $arrConf, $user, $extension, $esAdministrador) { $pMonitoring = new paloSantoMonitoring($pDB); //var_dump($arrConfg); $pMonitoring->setConfig($arrConf); $filter_field = getParameter("filter_field"); switch ($filter_field) { case "dst": $filter_field = "dst"; $nameFilterField = _tr("Destination"); break; case "userfield": $filter_field = "userfield"; $nameFilterField = _tr("Type"); break; default: $filter_field = "src"; $nameFilterField = _tr("Source"); break; } if ($filter_field == "userfield") { $filter_value = getParameter("filter_value_userfield"); $filter = ""; $filter_userfield = $filter_value; } else { $filter_value = getParameter("filter_value"); $filter = $filter_value; $filter_userfield = ""; } switch ($filter_value) { case "outgoing": $smarty->assign("SELECTED_2", "Selected"); $nameFilterUserfield = _tr("Outgoing"); break; case "queue": $smarty->assign("SELECTED_3", "Selected"); $nameFilterUserfield = _tr("Queue"); break; case "group": $smarty->assign("SELECTED_4", "Selected"); $nameFilterUserfield = _tr("Group"); break; default: $smarty->assign("SELECTED_1", "Selected"); $nameFilterUserfield = _tr("Incoming"); break; } $date_ini = getParameter("date_start"); $date_end = getParameter("date_end"); $path_record = $arrConf['records_dir']; $_POST['date_start'] = isset($date_ini) ? $date_ini : date("d M Y"); $_POST['date_end'] = isset($date_end) ? $date_end : date("d M Y"); if ($date_ini === "") { $_POST['date_start'] = " "; } if ($date_end === "") { $_POST['date_end'] = " "; } if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } $date_initial = date('Y-m-d', strtotime($_POST['date_start'])) . " 00:00:00"; $date_final = date('Y-m-d', strtotime($_POST['date_end'])) . " 23:59:59"; $_DATA = $_POST; //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Monitoring")); $oGrid->setIcon("modules/{$module_name}/images/pbx_monitoring.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Monitoring")); if ($esAdministrador) { $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $totalMonitoring = 0; } $url = array('menu' => $module_name); $paramFilter = array('filter_field' => $filter_field, 'filter_value' => $filter, 'filter_value_userfield' => $filter_userfield, 'date_start' => $_POST['date_start'], 'date_end' => $_POST['date_end']); $url = array_merge($url, $paramFilter); $oGrid->setURL($url); $arrData = null; if ($oGrid->isExportAction()) { $limit = $totalMonitoring; $offset = 0; $arrColumns = array(_tr("Date"), _tr("Time"), _tr("Source"), _tr("Destination"), _tr("Duration"), _tr("Type"), _tr("File")); $oGrid->setColumns($arrColumns); if ($esAdministrador) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $arrResult = array(); } if (is_array($arrResult) && $totalMonitoring > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = date('d M Y', strtotime($value['calldate'])); $arrTmp[1] = date('H:i:s', strtotime($value['calldate'])); $arrTmp[2] = $value['src']; $arrTmp[3] = $value['dst']; $arrTmp[4] = $value['dstchannel']; $arrTmp[5] = SecToHHMMSS($value['duration']); $file = $value['uniqueid']; $namefile = basename($value['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($namefile == 'deleted') { $arrTmp[6] = _tr('Deleted'); } else { switch ($namefile[0]) { case "O": $arrTmp[6] = _tr("Outgoing"); break; case "g": $arrTmp[6] = _tr("Group"); break; case "q": $arrTmp[6] = _tr("Queue"); break; default: $arrTmp[6] = _tr("Incoming"); break; } } $arrTmp[7] = $namefile; $arrTmp[8] = $value['note']; $arrTmp[9] = $value['delivery_id']; $arrData[] = $arrTmp; } } } else { $limit = 20; $total = $totalMonitoring; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); if ($esAdministrador) { $oGrid->deleteList(_tr("message_alert"), 'submit_eliminar', _tr("Delete")); $buttonDelete = ""; } else { $buttonDelete = ""; } $arrColumns = array($buttonDelete, "Ngày", "Giờ", "Gọi từ", "Gọi đến", "Nhân viên/PSTN", "Thời gian gọi", "Loại", "Ghi âm", "Nội dung", "Giao vé"); $oGrid->setColumns($arrColumns); if ($esAdministrador) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, null, $date_initial, $date_final); } elseif (!($extension == "" || is_null($extension))) { $arrResult = $pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, $extension, $date_initial, $date_final); } else { $arrResult = array(); } if (is_array($arrResult) && $total > 0) { $src = ""; $dst = ""; foreach ($arrResult as $key => $value) { if ($esAdministrador) { $arrTmp[0] = "<input type='checkbox' name='id_" . $value['uniqueid'] . "' />"; } else { $arrTmp[0] = ""; } $arrTmp[1] = date('d M Y', strtotime($value['calldate'])); $arrTmp[2] = date('H:i:s', strtotime($value['calldate'])); if (!isset($value['src']) || $value['src'] == "") { $src = "<font color='gray'>" . _tr("unknown") . "</font>"; } else { $src = $value['src']; } if (!isset($value['dst']) || $value['dst'] == "") { $dst = "<font color='gray'>" . _tr("unknown") . "</font>"; } else { $dst = $value['dst']; } $arrTmp[3] = $src; $arrTmp[4] = $dst; $arrTmp[5] = channel_lookup($pDB, $value['dstchannel']); $arrTmp[6] = "<label title='" . $value['duration'] . " seconds' style='color:green'>" . SecToHHMMSS($value['duration']) . "</label>"; //$file = base64_encode($value['userfield']); $file = $value['uniqueid']; $namefile = basename($value['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($namefile == 'deleted') { $arrTmp[7] = _tr('Deleted'); } else { switch ($namefile[0]) { case "O": $arrTmp[7] = _tr("Outgoing"); break; case "g": $arrTmp[7] = _tr("Group"); break; case "q": $arrTmp[7] = _tr("Queue"); break; default: $arrTmp[7] = _tr("Incoming"); break; } } if ($namefile != 'deleted') { $recordingLink = "<a href=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&id={$file}&namefile={$namefile}&rawmode=yes',350,100);\">" . _tr("Listen") . "</a> "; $recordingLink .= "<a href='?menu={$module_name}&action=download&id={$file}&namefile={$namefile}&rawmode=yes' >" . _tr("Download") . "</a>"; } else { $recordingLink = ''; } $arrTmp[8] = $recordingLink; $arrTmp[9] = is_null($value['note_id']) ? '-' : '<a href="javascript:void(0)" onclick="view_note(\'' . $value['note_id'] . '\')">Xem</a>'; $arrTmp[10] = is_null($value['delivery_id']) ? '-' : '<a href="javascript:void(0)" onclick="view_delivery(\'' . $value['delivery_id'] . '\')">Xem</a>'; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); //begin section filter $arrFormFilterMonitoring = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormFilterMonitoring); $smarty->assign("INCOMING", _tr("Incoming")); $smarty->assign("OUTGOING", _tr("Outgoing")); $smarty->assign("QUEUE", _tr("Queue")); $smarty->assign("GROUP", _tr("Group")); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_field"] = $filter_field; $_POST["filter_value"] = $filter; $_POST["filter_value_userfield"] = $filter_userfield; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $paramFilter['date_start'] . ", " . _tr("End Date") . " = " . $paramFilter['date_end'], $paramFilter, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); if ($filter_field == "userfield") { $oGrid->addFilterControl(_tr("Filter applied ") . " {$nameFilterField} = {$nameFilterUserfield}", $_POST, array('filter_field' => "src", 'filter_value_userfield' => "incoming")); } else { $oGrid->addFilterControl(_tr("Filter applied ") . " {$nameFilterField} = {$filter}", $_POST, array('filter_field' => "src", "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; }
function showLanguages($smarty, $module_name, $local_templates_dir, $arrLang, $arrLangModule) { //$oPaloSanto = new paloSantoLanguageAdmin(); $pLanguages = new paloSantoLanguageAdmin(); $arrFormElements = array("module" => array("LABEL" => $arrLangModule["Select Module"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $pLanguages->leer_directorio_modulos(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "language" => array("LABEL" => $arrLangModule["Select Language"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $pLanguages->leer_directorio_lenguajes(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); $smarty->assign("SAVE_ALL", "Save All"); $module = getParameter("module"); $language = getParameter("language"); $action = getParameter('nav'); $start = getParameter('start'); $smarty->assign("start_value", $start); $smarty->assign("nav_value", $action); $_POST["module"] = $module; $_POST["language"] = $language; $oGrid = new paloSantoGrid($smarty); if (!is_null($module) && !is_null($language)) { $nameModule = $arrFormElements["module"]["INPUT_EXTRA_PARAM"][$module]; $valueLanguage = $arrFormElements["language"]["INPUT_EXTRA_PARAM"][$language]; } else { $nameModule = ""; $valueLanguage = ""; } $oGrid->addFilterControl(_tr("Filter applied: ") . $nameModule . " = " . $valueLanguage, $_POST, array("module" => null, "language" => null)); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //Paginacion $limit = 20; $total_datos = $pLanguages->ObtainNumLanguages($module, $language); $total = $total_datos; $oGrid->addNew("new", _tr("Add")); $oGrid->customAction("save_all", _tr("Save All")); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("Language Admin")); $oGrid->setIcon("images/list.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = "?menu={$module_name}&module={$module}&language={$language}"; $oGrid->setURL($url); $arrColumns = array(_tr("Key"), _tr("Value")); $oGrid->setColumns($arrColumns); $arrLangMod = $pLanguages->obtainLanguages($limit, $offset, $module, $language); $arrData = array(); $counter = 1; if (is_array($arrLangMod) && count($arrLangMod) > 0) { foreach ($arrLangMod as $key => $value) { $tmpKey = htmlspecialchars($key); $tmpValue = htmlspecialchars($value); $arrTmp[0] = $tmpKey; $arrTmp[1] = "<input class='table_data' style='width:450px' type='text' name=\"langvalue_{$counter}\" id=\"langvalue_{$counter}\" value=\"{$tmpValue}\" /><input type='hidden' name='langkey_{$counter}' id='langkey_{$counter}' value='{$tmpKey}'>"; $counter++; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); $oGrid->showFilter(trim($htmlFilter)); $moduleContent = $oGrid->fetchGrid(); if (strpos($moduleContent, '<form') === FALSE) { $moduleContent = "<form method='POST' style='margin-bottom:0;' action={$url}>{$moduleContent}</form>"; } return $moduleContent; }
function reportPuertos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pPuertos = new paloSantoPortService($pDB); $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->addNew("new", _tr("Define Port")); $oGrid->deleteList("Are you sure you wish to delete the port(s).?", "delete", _tr("Delete")); $totalPuertos = $pPuertos->ObtainNumPuertos($field_type, $field_pattern); $limit = 20; $total = $totalPuertos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->setTitle(_tr("Define Ports")); $oGrid->setIcon("modules/{$module_name}/images/security_define_ports.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = array("menu" => $module_name, "filter_type" => $field_type, "filter_txt" => $field_pattern); $oGrid->setURL($url); $arrData = null; $arrResult = $pPuertos->ObtainPuertos($limit, $offset, $field_type, $field_pattern); $button_eliminar = ""; $arrColumns = array($button_eliminar, _tr("Name"), _tr("Protocol"), _tr("Details"), _tr("Option")); $oGrid->setColumns($arrColumns); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = "<input type='checkbox' name='" . $value['id'] . "' id='" . $value['id'] . "'>"; $arrTmp[1] = $value['name']; $arrTmp[2] = $value['protocol']; if ($value['protocol'] == "TCP" || $value['protocol'] == "UDP") { $port = $value['details']; $arrTmp[3] = stripos($port, ":") === false ? _tr('Port') . " " . $value['details'] : _tr('Ports') . " " . $value['details']; } elseif ($value['protocol'] == "ICMP") { $arr = explode(":", $value['details']); if (isset($arr[1])) { $arrTmp[3] = "Type: " . $arr[0] . " Code: " . $arr[1]; } } else { $arrTmp[3] = "Protocol Number: " . $value['details']; } $arrTmp[4] = " <a href='?menu={$module_name}&action=view&id=" . $value['id'] . "'>" . _tr('View') . "</a>"; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); //begin section filter $arrFormFilterPuertos = createFieldForm(); $oFilterForm = new paloForm($smarty, $arrFormFilterPuertos); $smarty->assign("SHOW", _tr("Show")); $_POST["filter_type"] = $field_type; $_POST["filter_txt"] = $field_pattern; if (is_null($field_type) || $field_type == "") { $nameFieldType = ""; } else { $nameFieldType = $arrFormFilterPuertos["filter_type"]["INPUT_EXTRA_PARAM"][$field_type]; } $oGrid->addFilterControl(_tr("Filter applied: ") . $nameFieldType . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => "x")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid(); if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action={$url}>{$contenidoModulo}</form>"; } //end grid parameters return $contenidoModulo; }
function report_AccessAudit($smarty, $module_name, $local_templates_dir) { global $arrPermission; $pAccessLogs = new paloSantoAccessaudit(); $listaFechas = $pAccessLogs->astLog->listarFechas(); $arrFormElements = createFieldFilter($listaFechas); $field_pattern = getParameter("filter"); $busqueda = getParameter('busqueda'); $sUltimaBusqueda = getParameter('ultima_busqueda'); $iUltimoOffset = getParameter('ultimo_offset'); if (is_null($busqueda) || trim($busqueda) == '') { $busqueda = ''; } if ($busqueda != '') { $_POST['busqueda'] = $busqueda; } /* Última búsqueda, si existe */ if (is_null($sUltimaBusqueda) || $sUltimaBusqueda == '' || is_null($iUltimoOffset) || !ereg('^[[:digit:]]+$', $iUltimoOffset)) { $sUltimaBusqueda = NULL; $iUltimoOffset = NULL; } if (!ereg($arrFormElements['filter']['VALIDATION_EXTRA_PARAM'], $field_pattern)) { $field_pattern = $listaFechas[count($listaFechas) - 1]; } $_POST['filter'] = $field_pattern; $oFilterForm = new paloForm($smarty, $arrFormElements); $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Audit")); $oGrid->setIcon("web/apps/{$module_name}/images/security_audit.png"); $oGrid->pagingShow(true); // show paging section. if (in_array("export", $arrPermission)) { $oGrid->enableExport(); } // enable export. $oGrid->setNameFile_Export(_tr("Access audit")); if (in_array("export", $arrPermission)) { $isExport = $oGrid->isExportAction(); } else { $isExport = false; } $total_datos = $pAccessLogs->ObtainNumAccessLogs($field_pattern); $totalBytes = $total_datos[0]; $iNumLineasPorPagina = 30; $iEstimadoBytesPagina = $iNumLineasPorPagina * 128; $iOffsetVerdadero = getParameter('offset'); if (is_null($iOffsetVerdadero) || !ereg('^[[:digit:]]+$', $iOffsetVerdadero)) { $iOffsetVerdadero = 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; } if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); } /* 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 = 30; $total = (int) ($totalBytes / 128); $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; } if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); } 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; //$accion = "next"; if ($start + $limit <= 1) { break; } /*$inicioRango = $page * $iEstimadoBytesPagina; $arrResult =$pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport); $offset = $arrResult[0]['offset']; $oGrid->setOffsetValue($offset); $oGrid->setEnd(((int)($offset / 128) + $iNumLineasPorPagina) <= $oGrid->getTotal() ? (int)($offset / 128) + $iNumLineasPorPagina : $oGrid->getTotal()); $oGrid->setStart(($oGrid->getTotal()==0) ? 0 : (1 + (int)($offset / 128)));*/ $inicioBusqueda = $page * $iEstimadoBytesPagina - $iEstimadoBytesPagina; $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioBusqueda, $field_pattern, NULL, $isExport); $offset = $arrResult[0]['offset']; $oGrid->setOffsetValue($offset); break; } } // Buscar la cadena de texto indicada, y modificar offset si se encuentra $smarty->assign("SEARCHNEXT", _tr('Search')); if (isset($_POST['searchnext']) && $busqueda != '') { $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset); $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda); if (!is_null($posBusqueda)) { $offset = $posBusqueda[1]; $smarty->assign('SEARCHNEXT', _tr('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) { $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset); $pAccessLogs->astLog->siguienteMensaje(); // Sólo para ignorar primera ocurrencia $posBusqueda = $pAccessLogs->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'] : ''); $oGrid->setURL($url); //Fin Paginacion if ($isExport) { $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } else { $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $offset, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport); } if (!$isExport) { $arrResult = array_slice($arrResult, 0, $iNumLineasPorPagina); } $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; } } $arrColumns = array(_tr("Date"), _tr("Type"), _tr("User"), _tr("Message")); $oGrid->setColumns($arrColumns); $oGrid->setData($arrData); $oGrid->setStart($totalBytes == 0 ? 0 : 1 + (int) ($offset / 128)); $t = (int) ($totalBytes / 128); $e = (int) ($offset / 128) + $iNumLineasPorPagina; $e = $t <= $e ? $t : $e; $oGrid->setEnd($e + 1); $oGrid->setTotal($t + 1); $oGrid->setLimit(30); $_POST['offset'] = $offset; $smarty->assign("SHOW", _tr("Show")); $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)); return $oGrid->fetchGrid(); }
function reportUser($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $idOrgFil = getParameter("idOrganization"); $username = getParameter("username"); $total = 0; if ($credentials['userlevel'] == "superadmin") { if (!empty($idOrgFil)) { $total = $pACL->getNumUsers($idOrgFil, $username); } else { $idOrgFil = 0; //opcion default se muestran todos los usuarios $total = $pACL->getNumUsers(null, $username); } } else { $idOrgFil = $credentials['id_organization']; $total = $pACL->getNumUsers($idOrgFil, $username); } if ($total === false) { $total = 0; $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Couldn't be retrieved user data")); } //url $url['menu'] = $module_name; $url['idOrganization'] = $idOrgFil; $url['username'] = $module_name; $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('User List')); $oGrid->setIcon("../web/_common/images/user.png"); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $arrColumns = array(); if ($credentials["userlevel"] == "superadmin") { $arrColumns[] = _tr("Organization"); //delete } $arrColumns[] = _tr("Username"); $arrColumns[] = _tr("Name"); $arrColumns[] = _tr("Group"); $arrColumns[] = _tr("Extension") . " / " . _tr("Fax Extension"); $arrColumns[] = _tr("Used Space") . " / " . _tr("Email Quota"); if (in_array('reconstruct_mailbox', $arrPermission)) { $arrColumns[] = ""; } //reconstruct mailbox $oGrid->setColumns($arrColumns); $arrData = array(); if ($credentials['userlevel'] == "superadmin") { if ($idOrgFil != 0) { $arrUsers = $pACL->getUsersPaging($limit, $offset, $idOrgFil, $username); } else { $arrUsers = $pACL->getUsersPaging($limit, $offset, null, $username); } } else { $arrUsers = $pACL->getUsersPaging($limit, $offset, $idOrgFil, $username); } if ($arrUsers === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); } //si es un usuario solo se ve a si mismo //si es un administrador ve a todo los usuarios de foreach ($arrUsers as $user) { $arrTmp = array(); if ($credentials["userlevel"] == "superadmin") { $arrOgz = $pORGZ->getOrganizationById($user[4]); $arrTmp[] = htmlentities($arrOgz["name"], ENT_COMPAT, 'UTF-8'); //organization } $arrTmp[] = " <a href='?menu=userlist&action=view&id={$user['0']}'>" . $user[1] . "</a>"; //username $arrTmp[] = htmlentities($user[2], ENT_COMPAT, 'UTF-8'); //name $gpTmp = $pACL->getGroupNameByid($user[7]); $arrTmp[] = $gpTmp == "superadmin" ? _tr("NONE") : $gpTmp; if (!isset($user[5]) || $user[5] == "") { $ext = _tr("Not assigned"); } else { $ext = $user[5]; } if (!isset($user[6]) || $user[6] == "") { $faxExt = _tr("Not assigned"); } else { $faxExt = $user[6]; } $arrTmp[] = $ext . " / " . $faxExt; if ($user[4] != 1) { //user that belong organization 1 do not have email account $arrTmp[] = obtener_quota_usuario($user[1], $module_name); //email quota if (in_array('reconstruct_mailbox', $arrPermission)) { $arrTmp[] = " <a href='#' onclick=mailbox_reconstruct('{$user[1]}')>" . _tr('Reconstruct Mailbox') . "</a>"; //reconstruct mailbox } } else { $arrTmp[] = ''; $arrTmp[] = ''; } $arrData[] = $arrTmp; $end++; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input name='search_org' type='submit' class='button' value='" . _tr('Search') . "'>"); if ($pORGZ->getNumOrganization(array()) > 0) { $arrOrgz = array(0 => _tr("all")); if (in_array('create_user', $arrPermission)) { $oGrid->addNew("create_user", _tr("Create New User")); } if ($credentials['userlevel'] == "superadmin") { foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["id"]] = $value["name"]; } $_POST["idOrganization"] = $idOrgFil; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$idOrgFil], $_POST, array("idOrganization" => 0), true); //organization } $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Username") . " = " . $username, $_POST, array("username" => "")); //username $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("In order to use this module must exist at least 1 organization in the Elastix Server")); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportBillingRates($smarty, $module_name, $local_templates_dir, &$pDB, &$pDB2, &$pDB3, $arrConf, $arrLang) { $pBillingRates = new paloSantoBillingRates($pDB); $action = getParameter("nav"); $start = getParameter("start"); $as_csv = getParameter("exportcsv"); $arrResult = ""; $arrColumns = ""; //obtain parameters from new rates $prefix_new = getParameter("Prefix"); $name_new = getParameter("Name"); $rate_new = getParameter("Rate"); $rate_offset_new = getParameter("Rate_offset"); $trunk_new = getParameter("Trunk"); $hidden_digits = getParameter("Hidden_Digits"); $id = getParameter("id"); //exists Default rate in rate.db // actualizar los rates por defecto en settings $cant = $pBillingRates->contRates(); if (isset($cant['cant']) & $cant['cant'] < 1) { $pBillingRates->existsDefaultRate($pDB3); } $action = getAction(); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $totalBillingRates = $pBillingRates->getNumBillingRates(); $url = array('menu' => $module_name); //$oGrid->enableExport(); // enable csv export. $oGrid->pagingShow(true); // show paging section. $oGrid->setTitle(_tr("Billing Rates")); $oGrid->setIcon("modules/{$module_name}/images/reports_billing_rates.png"); $oGrid->setNameFile_Export("Billing_Rates"); $oGrid->setURL($url); $oGrid->addNew("new_rate", _tr("create_rate")); $smarty->assign("module_name", $module_name); $arrData = null; if ($oGrid->isExportAction()) { $limit = $totalBillingRates; $offset = 0; $arrResult = $pBillingRates->getBillingRates($limit, $offset); if (is_array($arrResult) && $totalBillingRates > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = isset($value['prefix']) & $value['prefix'] != "" ? $value['prefix'] : "*"; $arrTmp[1] = isset($value['name']) & $value['name'] != "" ? $value['name'] : "-"; $arrTmp[2] = isset($value['rate']) & $value['rate'] != "" ? $value['rate'] : "-"; $arrTmp[3] = isset($value['rate_offset']) & $value['rate_offset'] != "" ? $value['rate_offset'] : "-"; $arrTmp[4] = isset($value['hided_digits']) & $value['hided_digits'] != "" ? $value['hided_digits'] : "-"; $arrTmp[5] = isset($value['trunk']) & $value['trunk'] != "" ? $value['trunk'] : "*"; $arrTmp[6] = isset($value['fecha_creacion']) & $value['fecha_creacion'] != "" ? $value['fecha_creacion'] : "-"; $arrData[] = $arrTmp; } } $arrColumns = array(_tr("Prefix"), _tr("Name"), _tr("Rate"), _tr("Rate Offset"), _tr("Hidden_Digits"), _tr("Trunk"), _tr("Creation Date")); } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($totalBillingRates); $offset = $oGrid->calculateOffset(); $arrResult = $pBillingRates->getBillingRates($limit, $offset); if (is_array($arrResult) && $totalBillingRates > 0) { foreach ($arrResult as $key => $value) { if ($value['name'] == "Default") { $default = $arrLang['Default']; $arrTmp[0] = "<font color='green'>*</font>"; $arrTmp[1] = "<font color='green'>" . $default . "</font>"; $arrTmp[2] = "<font color='green'>" . $value['rate'] . "</font>"; $arrTmp[3] = "<font color='green'>" . $value['rate_offset'] . "</font>"; $arrTmp[4] = "<font color='green'>" . $value['hided_digits'] . "</font>"; $arrTmp[5] = "<font color='green'>*</font>"; $arrTmp[6] = "<font color='green'>" . $value['fecha_creacion'] . "</font>"; $arrTmp[7] = "<a href='?menu={$module_name}&action=view&id=" . $value['id'] . "'>" . _tr("View") . "</a>"; } else { $arrTmp[0] = $value['prefix']; $arrTmp[1] = $value['name']; $arrTmp[2] = $value['rate']; $arrTmp[3] = $value['rate_offset']; $arrTmp[4] = $value['hided_digits']; $arrTmp[5] = $value['trunk']; $arrTmp[6] = $value['fecha_creacion']; $arrTmp[7] = "<a href='?menu={$module_name}&action=view&id=" . $value['id'] . "'>" . _tr("View") . "</a>"; } $arrData[] = $arrTmp; } } // arreglo de columnas $arrColumns = array(_tr("Prefix"), _tr("Name"), _tr("Rate"), _tr("Rate Offset"), _tr("Hidden_Digits"), _tr("Trunk"), _tr("Creation Date"), _tr("View")); } $oGrid->setColumns($arrColumns); $oGrid->setData($arrData); //begin section filter $arrFormFilterBillingRates = createFieldFilter($arrLang); $oFilterForm = new paloForm($smarty, $arrFormFilterBillingRates); $smarty->assign("import_rate", _tr("import_rate")); $smarty->assign("by_min", _tr("by_min")); $smarty->assign("Date_close", _tr("Date close")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->customAction("import_rate", _tr("import_rate")); $content = $oGrid->fetchGrid(); return $content; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir, $pDB, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $smarty->assign(array('SEARCH' => _tr('Search'))); $smarty->assign('USERLEVEL', $credentials['userlevel']); $arrOrgz = array(0 => "all"); $organization = getParameter('organization'); if ($credentials['userlevel'] == 'superadmin') { if (empty($organization)) { $organization = 0; } if ($pORGZ->getNumOrganization(array()) > 0) { foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["id"]] = $value["name"]; } } } else { $tmpOrg = $pORGZ->getOrganizationById($credentials['id_organization']); $arrOrgz[$tmpOrg["id"]] = $tmpOrg['name']; $organization = $credentials['id_organization']; } $oFax = new paloFaxVisor($pDB); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements($arrOrgz)); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All'); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out')); if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $organization; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$organization], $_POST, array("organization" => 0), true); //organization } $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL)); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true); $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; } $url = array_merge($url, $paramFiltro); $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("web/apps/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; if ($organization == 0) { $total = $oFax->obtener_cantidad_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } else { $total = $oFax->obtener_cantidad_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } if ($total === false) { $total = 0; $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $delete = in_array('delete_fax', $arrPermission); $edit = in_array('edit_fax', $arrPermission); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); if ($delete) { $columns[] = "<input type='checkbox' class='checkall'/>"; } if ($credentials['userlevel'] == 'superadmin') { $columns[] = _tr('Organization'); } $columns[] = _tr('Type'); $columns[] = _tr('File'); $columns[] = _tr('Fax Cid Name'); $columns[] = _tr('Fax Cid Number'); $columns[] = _tr('Fax Destiny'); $columns[] = _tr('Fax Date'); $columns[] = _tr('Status'); if ($edit) { $columns[] = _tr('Options'); } $oGrid->setColumns($columns); if ($total > 0) { if ($organization == 0) { $arrResult = $oFax->obtener_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } else { $arrResult = $oFax->obtener_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } else { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } $doc = explode(".", $fax['pdf_file']); $iddoc = $doc[0]; $arrTmp = array(); if ($delete) { $arrTmp[] = '<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />'; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = 'ttt'; } //$arrOrg[$fax['id_organization']]; $arrTmp[] = _tr($fax['type']); $arrTmp[] = strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file']; $arrTmp[] = $fax['company_name']; $arrTmp[] = $fax['company_fax']; $arrTmp[] = $fax['destiny_name'] . " - " . $fax['destiny_fax']; $arrTmp[] = $fax['date']; $arrTmp[] = _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']); if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"; } $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($delete) { $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); } $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }
function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ''; $pMonitoring = new paloSantoMonitoring($pDB); $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); $pPBX = new paloAsteriskDB($arrConf['elastix_dsn']["elastix"]); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $date_start = getParameter('date_start'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_start)) { $date_start = date("d M Y"); } $date_end = getParameter('date_end'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_end)) { $date_end = date("d M Y"); } $arrType = array("" => "", "conference" => _tr("Conference"), "group" => _tr("Group"), "queue" => _tr("Queue"), 'incoming' => _tr('Incoming'), 'outgoing' => _tr("Outgoing")); $type = getParameter("type"); $type = array_key_exists($type, $arrType) ? $type : ""; $source = getParameter("source"); if (isset($source) && $source != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($source); if ($expression === false) { $source = ''; } } $destination = getParameter("destination"); if (isset($destination) && $destination != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($destination); if ($expression === false) { $destination = ''; } } $url['menu'] = $module_name; $url['organization'] = $arrProp['organization'] = $domain; $url['date_start'] = $arrProp['date_start'] = $date_start; $url['date_end'] = $arrProp['date_end'] = $date_end; $url['source'] = $arrProp['source'] = $source; $url['destination'] = $arrProp['destination'] = $destination; $url['type'] = $arrProp['type'] = $type; //permission $delete = in_array("delete", $arrPermission); $export = in_array("export", $arrPermission); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Monitoring")); $oGrid->setIcon("web/apps/{$module_name}/images/pbx_monitoring.png"); $oGrid->pagingShow(true); // show paging section. if ($export) { $oGrid->enableExport(); } // enable export. $oGrid->setNameFile_Export(_tr("Monitoring")); $oGrid->setURL($url); if ($delete && !$oGrid->isExportAction()) { $arrColumns[] = ""; } if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr('organization'); } $arrColumns[] = _tr("Date"); $arrColumns[] = _tr("Time"); $arrColumns[] = _tr("Source"); $arrColumns[] = _tr("Destination"); $arrColumns[] = _tr("Duration"); $arrColumns[] = _tr("Type"); $arrColumns[] = _tr("File"); if (!$oGrid->isExportAction()) { $arrColumns[] = ""; //to display audio } $oGrid->setColumns($arrColumns); $totalMonitoring = $pMonitoring->getNumMonitoring($arrProp); if ($totalMonitoring === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; $totalMonitoring = 0; } $arrData = array(); $arrResult = array(); if ($totalMonitoring != 0) { if ($oGrid->isExportAction()) { $arrResult = $pMonitoring->getMonitoring($arrProp); } else { $limit = 20; $total = $totalMonitoring; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrProp['limit'] = $limit; $arrProp['offset'] = $offset; $arrResult = $pMonitoring->getMonitoring($arrProp); } } if ($arrResult === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; } else { if ($oGrid->isExportAction()) { if (!$export) { $arrData = _tr('INVALID ACTION'); } foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } $arrTmp[] = $namefile; $arrData[] = $arrTmp; } } else { $i = 0; foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='recordDel[]' value='{$monitoring['uniqueid']}' />"; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } if ($namefile == 'deleted') { $arrTmp[] = $namefile; $arrTmp[] = ""; } else { $explod_name = explode(".", $namefile); $ext = array_pop($explod_name); if ($ext == 'gsm' || $ext == 'WAV') { $div_display = "<a href=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&id={$monitoring['uniqueid']}&rawmode=yes',350,100)\"><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/></a> "; } else { $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/> </span></div>"; } $download = "<a href='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'>" . $namefile . "</a>"; $arrTmp[] = $div_display . $download; $arrTmp[] = "<audio></audio>"; } $i++; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } //begin section filter $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "delete", _tr("Delete Selected"), false); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true); } $_POST['date_start'] = $arrProp['date_start']; $_POST['date_end'] = $arrProp['date_end']; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrProp['date_start'] . ", " . _tr("End Date") . " = " . $arrProp['date_end'], $arrProp, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); //DATE START - DATE END $_POST["type"] = $type; // type $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type") . " = " . $arrType[$type], $_POST, array("type" => "")); $_POST["source"] = $source; // source $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source") . " = " . $source, $_POST, array("source" => "")); $_POST["destination"] = $destination; // destination $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination") . " = " . $source, $_POST, array("destination" => "")); $arrForm = createFieldFilter($arrOrgz, $arrType); $oFilterForm = new paloForm($smarty, $arrForm); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); //end section filter $content = $oGrid->fetchGrid(); return $content; }
function viewMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEmailList = new paloSantoEmailList($pDB); $id_list = getParameter("id"); if (!$pEmailList->listExistsbyId($id_list)) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The List entered does not exist")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); $smarty->assign("IDEMAILLIST", $id_list); $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")); $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("/modules/{$module_name}/images/email.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = array('menu' => $module_name, 'action' => 'view_memberlist', 'id' => $id_list, 'filter_type' => $field_type, 'filter_txt' => $field_pattern); $oGrid->setURL($url); $arrColumns = array(_tr("Member name"), _tr("Member email")); $oGrid->setColumns($arrColumns); $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern); $arrData = null; if (is_array($arrResult) && $totalMembers > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value["namemember"]; $arrTmp[1] = $value["mailmember"]; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); $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")); $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true); //$arrFiltro = array("filter_type"=>$field_type,"filter_txt"=>$field_pattern); $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(); if (strpos($content, '<form') === FALSE) { $content = "<form method='POST' style='margin-bottom:0;' action=" . construirURL($url) . ">{$content}</form>"; } return $content; }