function listPortKnockUsers(&$smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $pk = new paloSantoPortKnockUsers($pDB); // Manejar la operación de borrar todas las autorizaciones de un usuario if (isset($_POST['delete']) && isset($_POST['id_user'])) { $r = $pk->deleteUserAuthorizations($_POST['id_user']); if (!$r) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pk->errMsg); } else { // Ejecutar iptables para revocar las reglas del usuario require_once "modules/sec_rules/libs/paloSantoRules.class.php"; $pr = new paloSantoRules($pDB); $pr->activateRules(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Revocation successful")); } } $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr('PortKnock Users')); $oGrid->setColumns(array('', _tr('User'), _tr('Authorized ports'), _tr('Options'))); $oGrid->deleteList(_tr('Are you sure you wish to revoke the user authorizations?'), 'delete', _tr('Revoke authorizations')); $oGrid->addNew("?menu={$module_name}&action=new", _tr('Authorize new user'), true); // Construcción de la vista de usuarios autorizados $data = array(); $recordset = $pk->listAuthorizedUsers(); if (is_array($recordset)) { foreach ($recordset as $id_user => $auths) { $userinfo = $pACL->getUsers($id_user); $protocols = array(); foreach ($auths as $a) { $protocols[] = $a['name']; } $data[] = array('<input type="radio" name="id_user" value="' . $id_user . '" />', $userinfo[0][1], implode(' ', $protocols), "<a href=\"?menu={$module_name}&action=edit&id_user={$id_user}\">[" . _tr('Add/Remove Ports') . "]</a>"); } } $oGrid->pagingShow(false); $url = array("menu" => $module_name); $oGrid->setURL($url); $oGrid->setData($data); return $oGrid->fetchGrid(); }
function reportRG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $rg_name = getParameter("rg_name"); $pRG = new paloSantoRG($pDB, $domain); $rg_number = getParameter("rg_number"); if (isset($rg_number) && $rg_number != '') { $expression = $pRG->getRegexPatternFromAsteriskPattern($rg_number); if ($expression === false) { $rg_number = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['rg_number'] = $rg_number; //ring group number $url['rg_name'] = $rg_name; //ring group number $total = $pRG->getNumRG($domain, $rg_number, $rg_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pRG->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('RG List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Number"); $arrColum[] = _tr("Name"); $arrColum[] = _tr("Strategy"); $arrColum[] = _tr("Ring Time"); $arrColum[] = _tr("Ignore CF"); $arrColum[] = _tr("Skip Busy Extensions"); $arrColum[] = _tr("Default Destination"); $oGrid->setColumns($arrColum); $arrRG = array(); $arrData = array(); if ($total != 0) { $arrRG = $pRG->getRGs($domain, $rg_number, $rg_name, $limit, $offset); } if ($arrRG === false) { $error = _tr("Error to obtain Ring Groups") . $pRG->errMsg; $arrRG = array(); } foreach ($arrRG as $rg) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$rg["organization_domain"]]; } $arrTmp[] = " <a href='?menu=ring_group&action=view&id_rg=" . $rg['id'] . "&organization={$rg['organization_domain']}'>" . $rg['rg_number'] . "</a>"; $arrTmp[] = htmlentities($rg["rg_name"], ENT_QUOTES, "UTF-8"); $arrTmp[] = $rg["rg_strategy"]; $arrTmp[] = $rg["rg_time"]; $arrTmp[] = $rg["rg_cf_ignore"]; $arrTmp[] = $rg["rg_skipbusy"]; $arrTmp[] = $rg["destination"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Ring Group"), array_slice($arrOrgz, 1), $selected = null, "create_rg", $onchange_select = null); } else { $oGrid->addNew("create_rg", _tr("ADD Ring Group")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["rg_number"] = $rg_number; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Number") . " = " . $rg_number, $_POST, array("rg_number" => "")); $_POST["rg_name"] = $rg_name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Name") . " = " . $rg_name, $_POST, array("rg_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
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 reportTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $name = getParameter('name'); $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; //name $pTG = new paloSantoTG($pDB, $domain); $total = $pTG->getNumTG($domain, $name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => "all"); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pTG->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Time Groups List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Name"); $oGrid->setColumns($arrColum); $arrTG = array(); $arrData = array(); if ($total != 0) { $arrTG = $pTG->getTGs($domain, $name, $limit, $offset); } if ($arrTG === false) { $error = _tr("Error to obtain Time Groups") . $pTG->errMsg; $arrTG = array(); } $arrData = array(); foreach ($arrTG as $tg) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$tg["organization_domain"]]; } $arrTmp[] = " <a href='?menu={$module_name}&action=edit&id_tg=" . $tg['id'] . "&organization={$tg['organization_domain']}'>" . $tg['name'] . "</a>"; $arrData[] = $arrTmp; } if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Time Group"), array_slice($arrOrgz, 1), $selected = null, "create_tg", $onchange_select = null); } else { $oGrid->addNew("create_tg", _tr("ADD Time Group")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Time Condition Group") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloAdressBook($pDB); $pACL = new paloACL($pDB_2); $user = $_SESSION["elastix_user"]; $id_user = $pACL->getIdUser($user); $extension = $pACL->getUserExtension($user); if (is_null($extension) || $extension == "") { if ($pACL->isUserAdministratorGroup($user)) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", "<b>" . $arrLang["You don't have extension number associated with user"] . "</b>"); } else { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); } } if (getParameter('select_directory_type') != null && getParameter('select_directory_type') == 'external') { $smarty->assign("external_sel", 'selected=selected'); $directory_type = 'external'; } else { $smarty->assign("internal_sel", 'selected=selected'); $directory_type = 'internal'; } $_POST['select_directory_type'] = $directory_type; $arrComboElements = array("name" => $arrLang["Name"], "telefono" => $arrLang["Phone Number"]); if ($directory_type == 'external') { $arrComboElements["last_name"] = $arrLang["Last Name"]; } $arrFormElements = array("field" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value'))); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); $smarty->assign("NEW_adress_book", $arrLang["New Contact"]); $smarty->assign("CSV", $arrLang["CSV"]); $smarty->assign("module_name", $module_name); $smarty->assign("Phone_Directory", $arrLang["Phone Directory"]); $smarty->assign("Internal", $arrLang["Internal"]); $smarty->assign("External", $arrLang["External"]); $field = NULL; $pattern = NULL; $namePattern = NULL; $allowSelection = array("name", "telefono", "last_name"); if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; if (!in_array($field, $allowSelection)) { $field = "name"; } $pattern = "%{$_POST['pattern']}%"; $namePattern = $_POST['pattern']; $nameField = $arrComboElements[$field]; } $arrFilter = array("select_directory_type" => $directory_type, "field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Phone Directory") . " = {$directory_type} ", $arrFilter, array("select_directory_type" => "internal"), true); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter); if ($directory_type == 'external') { $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE, $id_user); } else { $total = $padress_book->getDeviceFreePBX($dsnAsterisk, NULL, NULL, $field, $pattern, TRUE); } $total_datos = $total[0]["total"]; //Paginacion $limit = 20; $total = $total_datos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion if ($directory_type == 'external') { $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE, $id_user); } else { $arrResult = $padress_book->getDeviceFreePBX($dsnAsterisk, $limit, $offset, $field, $pattern); } $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { $arrMails = array(); $typeContact = ""; if ($directory_type == 'internal') { $arrMails = $padress_book->getMailsFromVoicemail(); } foreach ($arrResult as $key => $adress_book) { if ($directory_type == 'external') { $exten = explode(".", $adress_book["picture"]); if (isset($exten[count($exten) - 1])) { $exten = $exten[count($exten) - 1]; } $picture = "/var/www/address_book_images/{$adress_book['id']}_Thumbnail.{$exten}"; if (file_exists($picture)) { $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='image' border='0' src='index.php?menu={$module_name}&action=getImage&idPhoto={$adress_book['id']}&thumbnail=yes&rawmode=yes'/></a>"; } else { $defaultPicture = "modules/{$module_name}/images/Icon-user_Thumbnail.png"; $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img border='0' alt='image' src='{$defaultPicture}'/></a>"; } } $arrTmp[0] = $directory_type == 'external' ? "<input type='checkbox' name='contact_{$adress_book['id']}' />" : ''; if ($directory_type == 'external') { $email = $adress_book['email']; if ($adress_book['status'] == 'isPublic') { if ($id_user == $adress_book['iduser']) { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public_edit.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public editable'] . "</span></div></div>"; $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; } else { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; $arrTmp[0] = ""; } } else { $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='private' style='padding: 5px;' title='" . $arrLang['Private Contact'] . "' border='0' src='modules/{$module_name}/images/contact.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Private'] . "</span></div></div>"; } } else { if (isset($arrMails[$adress_book['id']])) { $email = $arrMails[$adress_book['id']]; $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; } else { $email = ''; $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>"; } } $arrTmp[2] = $directory_type == 'external' ? "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'>" . htmlspecialchars($adress_book['last_name'], ENT_QUOTES, "UTF-8") . " " . htmlspecialchars($adress_book['name'], ENT_QUOTES, "UTF-8") . "</a>" : $adress_book['description']; $arrTmp[3] = $directory_type == 'external' ? $adress_book['telefono'] : $adress_book['id']; $arrTmp[4] = $email; $arrTmp[5] = "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['id'] . "&type=" . $directory_type . "'><img border=0 src='/modules/{$module_name}/images/call.png' /></a>"; $arrTmp[6] = "<a href='?menu={$module_name}&action=transfer_call&id=" . $adress_book['id'] . "&type=" . $directory_type . "'>{$arrLang["Transfer"]}</a>"; $arrTmp[7] = $typeContact; $arrData[] = $arrTmp; } } if ($directory_type == 'external') { $name = ""; $picture = $arrLang["picture"]; $oGrid->deleteList(_tr("Are you sure you wish to delete the contact."), "delete", _tr("Delete")); } else { $name = ""; $picture = ""; } $arrGrid = array("title" => $arrLang["Address Book"], "url" => array('menu' => $module_name, 'filter' => $pattern, 'select_directory_type' => $directory_type), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $name, "property1" => ""), 1 => array("name" => $picture, "property1" => ""), 2 => array("name" => $arrLang["Name"], "property1" => ""), 3 => array("name" => $arrLang["Phone Number"], "property1" => ""), 4 => array("name" => $arrLang["Email"], "property1" => ""), 5 => array("name" => $arrLang["Call"], "property1" => ""), 6 => array("name" => $arrLang["Transfer"], "property1" => ""), 7 => array("name" => $arrLang["Type Contact"], "property1" => ""))); $oGrid->addNew("new", _tr("New Contact")); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
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 reportMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $name = getParameter("name"); 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']; } $url["menu"] = $module_name; $url["organization"] = $domain; $url["name"] = $name; $pMoH = new paloSantoMoH($pDB, $domain); $total = $pMoH->getNumMoH($domain, $name); if ($total === false) { $error = $pMoH->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('MoH Class List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Name"); $arrColum[] = _tr("Type"); $arrColum[] = _tr("Sort"); $arrColum[] = _tr("Directory"); $arrColum[] = _tr("Aplication"); $oGrid->setColumns($arrColum); $arrMoH = array(); $arrData = array(); if ($total != 0) { $arrMoH = $pMoH->getMoHs($domain, $name, $limit, $offset); } if ($arrMoH === false) { $error = _tr("Error to obtain MoH Class") . $pMoH->errMsg; $arrMoH = array(); } $arrData = array(); foreach ($arrMoH as $moh) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { if (empty($moh["organization_domain"])) { $arrTmp[] = ""; $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>"; } else { $arrTmp[] = $arrOrgz[$moh["organization_domain"]]; $arrTmp[] = $moh["description"]; } } else { $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>"; } $arrTmp[] = $moh["mode"]; $arrTmp[] = $moh["sort"]; $arrTmp[] = $moh["directory"]; $arrTmp[] = $moh["application"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if (in_array("create", $arrPermission)) { $oGrid->addNew("create_moh", _tr("Create New Class MoH")); } if ($credentials['userlevel'] == "superadmin") { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); return $contenidoModulo; }
function reportDIDorganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { $pORGZ = new paloSantoOrganization($pDB); $pDID = new paloDidPBX($pDB); $domain = getParameter('domain'); if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } if (!preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $domain)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid domain format")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $total = $pDID->getTotalDID($domain); if ($total === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url['menu'] = $module_name; $url['domain'] = $domain; $oGrid->setTitle(_tr('DID Organization List')); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = ''; $arrColumns[] = _tr("Organization Domain"); } $arrColumns[] = _tr("DID"); $arrColumns[] = _tr("Type"); $arrColumns[] = _tr("Country"); $arrColumns[] = _tr("City"); $arrColumns[] = _tr("Country Code / Area Code"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrDID = $pDID->getDIDs($domain, null, null, null, $limit, $offset); if ($arrDID === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { //si es un usuario solo se ve su didsion //si es un administrador ve todas las didsiones foreach ($arrDID as $did) { $arrTmp = array(); if ($credentials["userlevel"] == "superadmin") { $arrTmp[] = "<input type='checkbox' name='dids[]' value='{$did['id']}' />"; $arrTmp[] = $did["organization_domain"]; } $arrTmp[] = $did['did']; $arrTmp[] = $did["type"]; $arrTmp[] = $did["country"]; $arrTmp[] = $did["city"]; $arrTmp[] = $did["country_code"] . " / " . $did["area_code"]; $arrData[] = $arrTmp; } } if ($credentials['userlevel'] == "superadmin") { $oGrid->addNew("assignDIDs", _tr("Add DID")); $oGrid->deleteList(_tr('Are you sure you wish REMOVE this DID from organization'), 'removeDID', "Remove DID"); } $content = $oGrid->fetchGrid(array(), $arrData); return $content; }
function reportIVR($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $name = getParameter("name"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; if ($credentials['userlevel'] == "superadmin") { if (isset($domain) && $domain != "all") { $pIVR = new paloIvrPBX($pDB, $domain); } else { $pIVR = new paloIvrPBX($pDB, ""); } $total = $pIVR->getTotalIvr($domain, $name); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $pIVR = new paloIvrPBX($pDB, $domain); $total = $pIVR->getTotalIvr($domain, $name); } if ($total === false) { $error = $pIVR->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Ivrs List')); $oGrid->setUrl($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Ivr Name"); $arrColumns[] = _tr("Timeout"); $arrColumns[] = _tr("Enable Call Extensions"); $arrColumns[] = _tr("# Loops"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrIVR = array(); if ($total != 0) { $arrIVR = $pIVR->getIvrs($domain, $name, $limit, $offset); } if ($arrIVR === false) { $error = _tr("Error getting ivr data.") . $pIVR->errMsg; } else { foreach ($arrIVR as $ivr) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$ivr['organization_domain']]; } $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_ivr=" . $ivr['id'] . "&organization={$ivr["organization_domain"]}'>" . htmlentities($ivr["name"], ENT_QUOTES, "UTF-8") . "</a>"; $arrTmp[] = $ivr["timeout"]; $arrTmp[] = $ivr["directdial"]; $arrTmp[] = $ivr["loops"]; $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New IVR"), array_slice($arrOrgz, 1), $selected = null, "create_ivr", $onchange_select = null); } else { $oGrid->addNew("create_ivr", _tr("Create New IVR")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true); } $_POST["name"] = $name; //ivr name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportDID($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pDID = new paloDidPBX($pDB); $pORGZ = new paloSantoOrganization($pDB); $error = ""; $did_number = getParameter("did_number"); // did number $status = getParameter("status"); // asignado o sin asignar $country = getParameter("country"); // pais al que pertence el did $domain = getParameter("organization"); // did que se encuentran asigandos a dicha organizacion $url['menu'] = $module_name; if (isset($did_number) && $did_number != '') { $expression = $pDID->getRegexPatternFromAsteriskPattern($did_number); if ($expression === false) { $did_number = ''; } } $status = empty($status) ? 'all' : $status; $domain = empty($domain) ? 'all' : $domain; $url['did_number'] = $did_number; $url['status'] = $status; $url['country'] = $country; $url['organization'] = $domain; $total = 0; $total = $pDID->getTotalDID($domain, $did_number, $country, $status); if ($total === false) { $error = $pDID->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url = "?menu={$module_name}"; $arrGrid = array("title" => _tr('DID List'), "url" => $url, "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, 'columns' => array(array("name" => _tr("DID")), array("name" => _tr("Organization Domain")), array("name" => _tr("Type")), array("name" => _tr("Country")), array("name" => _tr("Country Code / Area Code")))); $arrData = array(); $arrDID = array(); if ($total != 0) { $arrDID = $pDID->getDIDs($domain, $did_number, $country, $status, $limit, $offset); } if ($arrDID === false) { $error = _tr("Error to obtain DID") . $pDID->errMsg; $arrData = array(); } else { //si es un usuario solo se ve su didsion //si es un administrador ve todas las didsiones foreach ($arrDID as $did) { $arrTmp[0] = " <a href='?menu=did&action=view&id_did=" . $did['id'] . "'>" . $did['did'] . "</a>"; $arrTmp[1] = $did["organization_domain"]; $arrTmp[2] = $did["type"]; $arrTmp[3] = $did["country"]; $arrTmp[4] = $did["country_code"] . " / " . $did["area_code"]; $arrData[] = $arrTmp; } } if (in_array('create', $arrPermission)) { $oGrid->addNew("create_did", _tr("New DID")); } $_POST["did_number"] = $did_number; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("DID Number") . " = " . $did_number, $_POST, array("did_number" => "")); $arrStatus = array("all" => _tr('All'), "free" => _tr("No Assigned"), "busy" => _tr('Assigned')); $_POST["status"] = $status; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Status") . " = " . $arrStatus[$status], $_POST, array("status" => _tr("all")), true); $_POST["country"] = $country; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Country") . " = " . $country, $_POST, array("country" => "")); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); //organization $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='search'>"); $arrFormElements = createFieldFilter($arrOrgz, $arrStatus); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $content = $oGrid->fetchGrid($arrGrid, $arrData); return $content; }
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 reportRecording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $name = getParameter("name"); 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']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; $pRecording = new paloSantoRecordings($pDB); $total = $pRecording->getNumRecording($domain, $name); if ($total === false) { $error = $pRecording->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; //permission $create = in_array("create", $arrPermission); $edit = in_array("edit", $arrPermission); $delete = in_array("delete", $arrPermission); if ($delete) { $check = " <input type='checkbox' name='checkall' class='checkall' id='checkall' onclick='jqCheckAll(this.id);' />"; } else { $check = ""; } $oGrid->setTitle(_tr('Recordings List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColumns[] = $check; if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Name"); //$arrColumns[]=_tr("Source"); $arrColumns[] = _tr(""); $oGrid->setColumns($arrColumns); $arrRecordings = array(); $arrData = array(); if ($total != 0) { $arrRecordings = $pRecording->getRecordings($domain, $name, $limit, $offset); } if ($arrRecordings === false) { $error = _tr("Error to obtain Recordings") . $pRecording->errMsg; $arrRecordings = array(); } $i = 0; foreach ($arrRecordings as $recording) { $arrTmp = array(); $ext = explode(".", $recording["name"]); if ($delete) { $arrTmp[] = " <input type ='checkbox' class='delete' name='record_delete[]' value='" . $recording['uniqueid'] . "' />"; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = $recording["organization_domain"] == '' ? '' : $arrOrgz[$recording["organization_domain"]]; } //$arrTmp[] = $recording["source"]; $idfile = $recording['uniqueid']; if ($ext[1] == "gsm") { $div_display = ''; } else { $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$idfile}&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={$idfile}&rawmode=yes'>" . $recording['name'] . "</a>"; $arrTmp[] = $div_display . $download; $arrTmp[] = "<audio></audio>"; $i++; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($create) { $oGrid->addNew("add_recording", _tr("Add Recording")); } if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "remove", _tr("Delete Selected"), false); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); return $contenidoModulo; }
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloPhoneBook($pDB); $arrComboElements = array("firstname" => "Tên", "lastname" => "Họ", "extension" => "Số nội bộ", "mobile" => "Số điện thoại", "company_mobile" => "Số công ty"); $arrFormElements = array("field" => array("LABEL" => "Tìm theo", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value'))); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", "Tìm"); $smarty->assign("NEW_adress_book", "Thêm khách hàng mới"); $smarty->assign("CSV", $arrLang["CSV"]); $smarty->assign("module_name", $module_name); $field = NULL; $pattern = NULL; $namePattern = NULL; $allowSelection = array("firstname", "lastname", "extension", "mobile", "company_mobile"); if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; if (!in_array($field, $allowSelection)) { $field = "firstname"; } $pattern = "%{$_POST['pattern']}%"; $namePattern = $_POST['pattern']; $nameField = $arrComboElements[$field]; } $arrFilter = array("field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $arrFilter); $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE); $total_datos = $total[0]["total"]; //Paginacion $limit = 20; $total = $total_datos; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE); //var_dump($arrResult);die; $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $adress_book) { $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; $arrTmp[1] = $adress_book['firstname']; //Ten column $arrTmp[2] = $adress_book['lastname']; //Ten column $arrTmp[3] = $adress_book['department']; //Ten column $arrTmp[4] = is_null($adress_book['company_mobile']) || $adress_book['company_mobile'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['company_mobile'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['company_mobile'] . "'/></a>" . $adress_book['company_mobile']; $arrTmp[5] = is_null($adress_book['mobile']) || $adress_book['mobile'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['mobile'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['mobile'] . "'/></a>" . $adress_book['mobile']; $arrTmp[6] = is_null($adress_book['extension']) || $adress_book['extension'] == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['extension'] . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $adress_book['extension'] . "'/></a>" . $adress_book['extension']; $arrTmp[7] = '<a title="Gửi mail đến hộp mail này" href="mailto:' . $adress_book['email'] . '?Subject=[CallCenter]:" target="_top">' . $adress_book['email'] . '</a>'; $arrTmp[8] = $adress_book['note']; $arrTmp[9] = "<a href='?menu={$module_name}&action=edit&id=" . $adress_book['id'] . "'>Edit</a>"; $arrData[] = $arrTmp; } } $oGrid->deleteList("Bạn có muốn xóa người này không?", "delete", "Xóa"); $arrGrid = array("title" => "Danh bạ điện thoại", "url" => array('menu' => $module_name, 'filter' => $pattern), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => '', "property1" => ""), 1 => array("name" => "Tên", "property1" => ""), 2 => array("name" => "Họ", "property1" => ""), 3 => array("name" => "Phòng - Công ty", "property1" => ""), 4 => array("name" => "Số di động công ty", "property1" => ""), 5 => array("name" => "Số di động", "property1" => ""), 6 => array("name" => "Số nội bộ", "property1" => ""), 7 => array("name" => "Email", "property1" => ""), 8 => array("name" => "Ghi chú", "property1" => ""), 9 => array("name" => "Sửa", "property1" => ""))); $oGrid->addNew("new", "Thêm danh bạ"); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function reportConference($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $error = ""; $date = date("Y-m-d H:i"); $state_conf = getParameter("state_conf"); $name_conf = getParameter("name_conf"); $type_conf = getParameter("type_conf"); if (empty($state_conf)) { $state_conf = "all"; } if (empty($type_conf)) { $type_conf = "both"; } if (is_null($name_conf)) { $name_conf = ""; } 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']; } $url['menu'] = $module_name; $url["state_conf"] = $state_conf; $url["name_conf"] = $name_conf; $url["type_conf"] = $type_conf; $url['date'] = $date; $pconference = new paloConference($pDB, $domain); $total = $pconference->getTotalConference($domain, $date, $state_conf, $type_conf, $name_conf); if ($total === false) { $error = $pconference->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Conference')); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); //permission $delete = in_array("delete_conf", $arrPermission); $create = in_array("create_conf", $arrPermission); $edit = in_array("edit_conf", $arrPermission); $invite_part = in_array("admin_conference_participant", $arrPermission); if ($delete) { $arrColum[] = _tr(""); } $arrColum[] = _tr("Name"); $arrColum[] = _tr("Room Number"); $arrColum[] = _tr("Period"); $arrColum[] = _tr("Participants / MaxUsers"); $arrColum[] = _tr("Status"); $oGrid->setColumns($arrColum); $arrData = array(); $arrconference = array(); if ($total != 0) { $arrconference = $pconference->getConferesPagging($domain, $date, $limit, $offset, $state_conf, $type_conf, $name_conf); } $session = getSession(); if ($arrconference === false) { $error = _tr("Error getting conference data.") . $pconference->errMsg; } else { foreach ($arrconference as $conf) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='confdel[]' value='{$conf['bookid']}'/>"; //delete } if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=view&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}'>" . htmlentities($conf["name"], ENT_QUOTES, "UTF-8") . "</a>"; //name } else { $arrTmp[] = htmlentities($conf["name"], ENT_QUOTES, "UTF-8"); } $arrTmp[] = $conf["ext_conf"]; //roomnumber $perid = "No Set"; if (!empty($conf["startTime"]) && $conf["startTime"] != "1900-01-01 12:00:00") { $perid = $conf["startTime"] . " - " . $conf["endtime"]; } $arrTmp[] = $perid; //period $max = empty($conf["maxusers"]) ? "unlimited" : $conf["maxusers"]; $participants = "<spam class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max} </spam>"; $status = "<spam class='conf_status'></spam>"; if ($perid != "No Set") { $date = time(); if ($date >= strtotime($conf["startTime"]) && $date <= strtotime($conf["endtime"])) { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } $status = "<spam class='conf_status' style='color:green'/>" . _tr("In Progress") . "</spam>"; } else { if ($date < strtotime($conf["startTime"])) { $status = "<spam class='conf_status'>" . _tr("Future") . "</spam>"; } else { $status = "<spam class='conf_status'>" . _tr("Past") . "</spam>"; } } } else { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } } $arrTmp[] = $participants; $arrTmp[] = $status; $arrData[] = $arrTmp; //se usa para comprobar si ha habido cambios en el estado de las conferencias $session['conference']["conf_list"][$conf['bookid']] = array($participants, $status); } } //se escribe en session el estado actual de las conferencias putSession($session); //filters $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if ($create) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Conference"), array_slice($arrOrgz, 1), $selected = null, "create_conference", $onchange_select = null); } else { $oGrid->addNew("create_conference", _tr("ADD Conference")); } } if ($delete) { $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete")); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } //arreglo usado para formar los elementos del filtro $arrState = array("all" => _tr("All"), "past" => _tr("Past Conference"), "current" => _tr("Current Conference"), "future" => _tr("Future Conference")); $arrType = array("both" => _tr("Both"), "yes" => _tr("Schedule"), "no" => _tr("No Schedule")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrState[$state_conf], $state_conf, array("state_conf" => "all"), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Name") . " = " . $name_conf, $name_conf, array("name_conf" => "")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Type") . " = " . $arrType[$type_conf], $type_conf, array("type_conf" => "both"), true); $smarty->assign("SHOW", _tr("Show")); $arrFormElements = createFieldFilter($arrState, $arrType, $arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>"; $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>"; $contenidoModulo .= "<input type='hidden' name='conf_action' id='conf_action' value='report'>"; $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; 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 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 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 reportExten($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pExten = new paloSantoExtensions($pDB); $pORGZ = new paloSantoOrganization($pDB); $error = ''; $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $extension = getParameter("extension"); if (isset($extension) && $extension != '') { $pPBX = new paloAsteriskDB($pDB); $expression = $pPBX->getRegexPatternFromAsteriskPattern($extension); if ($expression === false) { $extension = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['extension'] = $extension; $total = $pExten->getNumExtensions($domain, $extension); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pExten->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Extensions List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Extension"); $arrColum[] = _tr("Caller ID"); $arrColum[] = _tr("Technology"); $arrColum[] = _tr("Device"); $arrColum[] = _tr("Context"); $arrColum[] = _tr("User"); $arrColum[] = _tr("Voicemail"); $arrColum[] = _tr("Recording In") . " / " . _tr("Recording Out"); $oGrid->setColumns($arrColum); $arrExtens = array(); $arrData = array(); if ($total != 0) { $arrExtens = $pExten->getExtensions($domain, $extension, $limit, $offset); } if ($arrExtens === false) { $error = _tr("Error to obtain extensions") . $pExten->errMsg; $arrExtens = array(); } else { foreach ($arrExtens as $exten) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$exten["organization_domain"]]; } $arrTmp[] = " <a href='?menu=extensions&action=view&id_exten=" . $exten['id'] . "&organization={$exten['organization_domain']}'>" . $exten["exten"] . "</a>"; $arrTmp[] = $exten['clid_name'] . " <{$exten['clid_number']}>"; $arrTmp[] = strtoupper($exten['tech']); $arrTmp[] = $exten['device']; $arrTmp[] = $exten['context']; $query = "Select username from acl_user where extension=? and id_group in (select g.id from acl_group g join organization o on g.id_organization=o.id where o.domain=?)"; $result = $pDB->getFirstRowQuery($query, false, array($exten["exten"], $exten["organization_domain"])); if ($result != false) { $arrTmp[] = $result[0]; } else { $arrTmp[] = _tr("Nobody"); } if (isset($exten["voicemail"])) { if ($exten["voicemail"] != "novm") { $arrTmp[] = "yes"; } else { $arrTmp[] = "no"; } } else { $arrTmp[] = "no"; } $arrTmp[] = _tr($exten["record_in"]) . " / " . _tr($exten["record_out"]); $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New Extension"), array_slice($arrOrgz, 1), $selected = null, "create_exten", $onchange_select = null); } else { $oGrid->addNew("create_exten", _tr("Create New Extension")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["extension"] = $extension; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Extension") . " = " . $extension, $_POST, array("extension" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $queue_name = getParameter("queue_name"); $pQueue = new paloQueuePBX($pDB, $domain); $queue_number = getParameter("queue_number"); if (isset($queue_number) && $queue_number != '') { $expression = $pQueue->getRegexPatternFromAsteriskPattern($queue_number); if ($expression === false) { $queue_number = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['queue_number'] = $queue_number; //queue_number $url['queue_name'] = $queue_name; //queue_name $total = $pQueue->getTotalQueues($domain, $queue_number, $queue_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pQueue->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Queues List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Queue Number"); $arrColumns[] = _tr("Queue Name"); $arrColumns[] = _tr("Password"); $arrColumns[] = _tr("Record Call"); $arrColumns[] = _tr("Strategy"); $arrColumns[] = _tr("Timeout Queue"); $arrColumns[] = _tr("Timeout Agent"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrQueues = array(); if ($total != 0) { $arrQueues = $pQueue->getQueues($domain, $queue_number, $queue_name, $limit, $offset); } if ($arrQueues === false) { $error = _tr("Error getting queue data. ") . $pQueue->errMsg; } else { foreach ($arrQueues as $queue) { $arrTmp = array(); if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = $arrOrgz[$queue['organization_domain']]; } $queunumber = $queue["queue_number"]; $arrTmp[] = " <a href='?menu=queues&action=view&qname=" . $queue['name'] . "&organization={$queue['organization_domain']}'>" . $queunumber . "</a>"; $arrTmp[] = htmlentities($queue["description"], ENT_QUOTES, "UTF-8"); $arrTmp[] = $queue["password_detail"]; $arrTmp[] = isset($queue["monitor_format"]) ? "yes" : "no"; $arrTmp[] = $queue["strategy"]; $arrTmp[] = $queue["timeout_detail"] == "0" ? "unlimited" : $queue["timeout_detail"]; $arrTmp[] = $queue["timeout"]; /*$result=getInfoQueue(); $arrTmp[6]=$result["logged"]; $arrTmp[6]=$result["free"];*/ $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New Queue"), array_slice($arrOrgz, 1), $selected = null, "create_queue", $onchange_select = null); } else { $oGrid->addNew("create_queue", _tr("Create New Queue")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["queue_number"] = $queue_number; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Number") . " = " . $queue_number, $_POST, array("queue_number" => "")); $_POST["queue_name"] = $queue_name; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Name") . " = " . $queue_name, $_POST, array("queue_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
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_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 reportOutbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $reorderRoute = false) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $error = ""; $arrOrgz = array(); $domain = getParameter("organization"); $name = getParameter("name"); // outbound name $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; if ($credentials['userlevel'] == "superadmin") { if (isset($domain) && $domain != "all") { $pOutbound = new paloSantoOutbound($pDB, $domain); } else { $pOutbound = new paloSantoOutbound($pDB, ""); } $total = $pOutbound->getNumOutbound($domain, $name); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $pOutbound = new paloSantoOutbound($pDB, $domain); $total = $pOutbound->getNumOutbound($domain, $name); } if ($total === false) { $error = $pOutbound->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $arrGrid = array("title" => _tr('Outbound Routes List'), "url" => $url, "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total); $arrColumns = array(); $arrColumns[] = _tr("Order"); $arrColumns[] = _tr("Route Name"); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Route CID"); $arrColumns[] = _tr("Route Password"); $arrColumns[] = _tr("Time Group"); $oGrid->setColumns($arrColumns); $arrOutbound = array(); $arrData = array(); if ($total != 0) { $arrOutbound = $pOutbound->getOutbounds($domain, $name, $limit, $offset); } if ($arrOutbound === false) { $error = _tr("Error to obtain outbounds") . $pOutbound->errMsg; $arrOutbound = array(); } $create = in_array('create', $arrPermission); $edit = in_array('edit', $arrPermission); foreach ($arrOutbound as $outbound) { $arrTmp = array(); if ($edit) { $arrTmp[] = fieldOrden($arrOutbound, $outbound["seq"], $outbound["id"], $outbound["organization_domain"]); } else { $arrTmp[] = $outbound["seq"]; } $arrTmp[] = " <a href='?menu=outbound_route&action=view&id_outbound=" . $outbound['id'] . "&organization={$outbound["organization_domain"]}'>" . htmlentities($outbound['routename'], ENT_QUOTES, "UTF-8") . "</a>"; if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$outbound["organization_domain"]]; } $arrTmp[] = $outbound["outcid"]; $arrTmp[] = $outbound["routepass"]; if (isset($outbound["time_group_id"])) { $query = "SELECT name from time_group where id=?"; $result = $pDB->getFirstRowQuery($query, true, array($outbound["time_group_id"])); if ($result != false) { $arrTmp[] = $result["name"]; } else { $arrTmp[] = ""; } } $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Outbound Route"), array_slice($arrOrgz, 1), $selected = null, "create_outbound", $onchange_select = null); } else { $oGrid->addNew("create_outbound", _tr("ADD Outbound Route")); } } if ($credentials['userlevel'] == "superadmin") { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; //outbound_route name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; 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 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 reportOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $other_destination_name = getParameter("other_destination_name"); $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); $url['menu'] = $module_name; $url['organization'] = $domain; $url['other_destination_name'] = $other_destination_name; $total = $pOtherDestinations->getNumOtherDestinations($domain, $other_destination_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pOtherDestinations->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Other Destinations List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Other Destination Name"); $arrColum[] = _tr("Dial Destination"); $oGrid->setColumns($arrColum); $arrOtherDestinations = array(); $arrData = array(); if ($total != 0) { $arrOtherDestinations = $pOtherDestinations->getOtherDestinations($domain, $other_destination_name, $limit, $offset); } if ($arrOtherDestinations === false) { $error = _tr("Error to obtain Other Destinations") . $pOtherDestinations->errMsg; $arrOtherDestinations = array(); } foreach ($arrOtherDestinations as $row) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$row["organization_domain"]]; } $arrTmp[] = " <a href='?menu={$module_name}&action=view&id=" . $row['id'] . "&organization={$row['organization_domain']}'>" . htmlentities($row["description"], ENT_QUOTES, "UTF-8") . "</a>"; $arrTmp[] = $row["destdial"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Other Destination"), array_slice($arrOrgz, 1), $selected = null, "create_other_destination", $onchange_select = null); } else { $oGrid->addNew("create_other_destination", _tr("ADD Other Destination")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["other_destination_name"] = $other_destination_name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Other Destination Name") . " = " . $other_destination_name, $_POST, array("other_destination_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
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 report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk) { $padress_book = new paloAdressBook($pDB); $arrBooker = $padress_book->getBookerList(); $arrPayment_type = array(0 => 'Khách lẻ không thường xuyên', 1 => 'Khách lẻ thường xuyên', 2 => 'Khách hàng công ty', 3 => 'Khách hàng đại lý'); $arrComboElements = array("customer_code" => "Mã khách hàng", "firstname" => "Tên khách hàng", "phone" => "Số điện thoại", "email" => "Email", "agent_id" => "Booker", "sale" => "Kinh Doanh", "booker" => "Kế Toán", "type" => "Loại khách hàng"); $arrFormElements = array("field" => array("LABEL" => "Tìm theo", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value')), "booker" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrBooker, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "payment" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrPayment_type, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", "Tìm"); $smarty->assign("module_name", $module_name); $field = NULL; $pattern = NULL; $namePattern = NULL; if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") { $field = $_POST['field']; $pattern = "%" . trim($_POST['pattern']) . "%"; $namePattern = trim($_POST['pattern']); //$nameField=$arrComboElements[$field]; //$agent_id = $_POST['booker']; //$payment_type = $_POST['booker']; } $arrFilter = array("field" => $field, "pattern" => $namePattern); $startDate = $endDate = date("Y-m-d H:i:s"); $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export("HNH_KhachHang"); $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter); $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE); $total_datos = $total[0]["total"]; //Paginacion if ($oGrid->isExportAction()) { $total = $total_datos; $limit = $total; $arr_cols = array(0 => array("name" => "Mã KH", "property1" => ""), 1 => array("name" => "Tên khách hàng", "property1" => ""), 2 => array("name" => "Họ/Hình thức", "property1" => ""), 3 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 4 => array("name" => "Email/Liên hệ", "property1" => ""), 5 => array("name" => "Booker", "property1" => ""), 6 => array("name" => "Kinh doanh", "property1" => ""), 7 => array("name" => "Kế toán", "property1" => ""), 8 => array("name" => "Phân loại", "property1" => ""), 9 => array("name" => "Thẻ thành viên", "property1" => ""), 10 => array("name" => "Cách thanh toán", "property1" => "")); } else { $limit = 20; $total = $total_datos; $arr_cols = array(0 => array("name" => "", "property1" => ""), 1 => array("name" => "Mã KH", "property1" => ""), 2 => array("name" => "Tên khách hàng", "property1" => ""), 3 => array("name" => "Họ/Hình thức", "property1" => ""), 4 => array("name" => "Điện thoại/Liên hệ", "property1" => ""), 5 => array("name" => "Email/Liên hệ", "property1" => ""), 6 => array("name" => "Booker", "property1" => ""), 7 => array("name" => "Kinh doanh", "property1" => ""), 8 => array("name" => "Kế toán", "property1" => ""), 9 => array("name" => "Phân loại", "property1" => ""), 10 => array("name" => "Thẻ thành viên", "property1" => ""), 11 => array("name" => "Cách thanh toán", "property1" => ""), 12 => array("name" => "Lựa chọn", "property1" => "")); } $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $end = $offset + $limit <= $total ? $offset + $limit : $total; //Fin Paginacion $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE); //var_dump($arrResult);die; $arrData = null; //echo print_r($arrResult,true); if (is_array($arrResult) && $total > 0) { if ($oGrid->isExportAction()) { foreach ($arrResult as $key => $adress_book) { $typeContact = ""; switch ($adress_book['type']) { case '0': $typeContact = "Khách hàng lẽ"; break; case '1': $typeContact = "Khách lẽ thường xuyên"; break; case '2': $typeContact = 'Khách hàng công ty'; break; case '3': $typeContact = "Khách hàng đại lý"; break; default: break; } $phone_list = ''; if (isset($adress_book['number']) && count($adress_book['number']) > 0) { foreach ($adress_book['number'] as $phone) { $phone_list .= is_null($phone) || trim($phone) == '' ? '' : $phone . '\\n'; } } //SDT column $email_list = ''; if (count($adress_book['email']) > 0) { foreach ($adress_book['email'] as $email) { $email_list .= is_null($email) || trim($email) == '' ? '' : $email . '\\n'; } } $arrTmp[] = $adress_book['customer_code']; //Ten column $arrTmp[] = $adress_book['firstname']; //Ten column $arrTmp[] = $adress_book['lastname']; //Ten column $arrTmp[] = $phone_list; $arrTmp[] = $email_list; $arrTmp[] = $adress_book['booker']; $arrTmp[] = $adress_book['sale']; $arrTmp[] = $adress_book['accountant']; $arrTmp[] = $typeContact; $arrTmp[] = $adress_book['membership']; $arrTmp[] = $adress_book['payment']; $arrData[] = $arrTmp; } } else { foreach ($arrResult as $key => $adress_book) { switch ($adress_book['type']) { case '0': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/nor-customer.png" title="Khách hàng lẽ"/>KLE'; break; case '1': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/fre-customer.png" title="Khách hàng lẽ thường xuyên"/>KLE-TX'; break; case '2': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/company.png" title="Khách hàng công ty"/>CTY'; break; case '3': $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/agency.png" title="Khách hàng đại lý"/>DLY'; break; default: break; } $phone_list = ''; if (isset($adress_book['number']) && count($adress_book['number']) > 0) { foreach ($adress_book['number'] as $phone) { $phone1 = explode('-', $phone); $call = trim($phone1[0]); $phone_list .= is_null($call) || trim($call) == '' ? '' : "<a href='?menu={$module_name}&action=call2phone&id=" . $call . "'><img border=0 src='/modules/{$module_name}/images/call.png' title='Gọi số " . $call . "'/></a> " . $phone . '<br/>'; //SDT column } } $email_list = ''; if (count($adress_book['email']) > 0) { foreach ($adress_book['email'] as $email) { $phone1 = explode('-', $email); $addr = trim($phone1[0]); $email_list .= is_null($addr) || trim($addr) == '' ? '' : '<a title="Gửi mail đến hộp mail này" href="mailto:' . $addr . '?Subject=[CallCenter]:" target="_top">' . $email . '</a><br/>'; } } $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}' />"; $arrTmp[1] = $adress_book['customer_code']; //Ten column $arrTmp[2] = $adress_book['firstname']; //Ten column $arrTmp[3] = $adress_book['lastname']; //Ten column $arrTmp[4] = $phone_list; $arrTmp[5] = $email_list; $arrTmp[6] = $adress_book['booker']; $arrTmp[7] = $adress_book['sale']; $arrTmp[8] = $adress_book['accountant']; $arrTmp[9] = $typeContact; $arrTmp[10] = $adress_book['membership']; $arrTmp[11] = $adress_book['payment']; $arrTmp[12] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/extra.png' title='Xem'></a> \n <a href='?menu={$module_name}&action=edit&id=" . $adress_book['id'] . "'><img src='modules/{$module_name}/images/edit.png' title='Sửa'></a> "; $arrData[] = $arrTmp; } } } $oGrid->deleteList("Bạn có muốn xóa khách hàng này không?", "delete", "Xóa"); $arrGrid = array("title" => "Thông tin khách hàng", "url" => array('menu' => $module_name, 'filter' => $pattern), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => $arr_cols); $oGrid->addNew("new", "Thêm khách hàng"); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function report_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang2, $arrConfig, $dsn_agi_manager, $dsnAsterisk) { global $arrLang; global $arrConf; $bSoporteWebConf = file_exists('modules/conferenceroom_list/libs/conferenceActions.lib.php'); $arrConference = array("Past_Conferences" => $arrLang["Past Conferences"], "Current_Conferences" => $arrLang["Current Conferences"], "Future_Conferences" => $arrLang["Future Conferences"]); $arrFormElements = array("conference" => array("LABEL" => $arrLang["State"], "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrConference, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no", "SIZE" => "1"), "filter" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("id" => "filter_value"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SHOW", $arrLang["Show"]); // $smarty->assign("NEW_CONFERENCE", $arrLang["New Conference"]); $startDate = $endDate = date("Y-m-d H:i:s"); $conference = getParameter("conference"); $field_pattern = getParameter("filter"); if ($conference) { $_POST['conference'] = $conference; } else { $_POST['conference'] = "Current_Conferences"; } $oGrid = new paloSantoGrid($smarty); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrConference[$_POST['conference']], $_POST, array("conference" => "Current_Conferences"), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Conference Name") . " = {$field_pattern}", $_POST, array("filter" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/conference.tpl", "", $_POST); $pConference = new paloSantoConference($pDB); $total_datos = $pConference->ObtainNumConferences($startDate, $endDate, "confDesc", $field_pattern, $conference); //Paginacion $limit = 8; $total = $total_datos[0]; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url = array('menu' => $module_name, 'conference' => $conference, 'filter' => $field_pattern); //Fin Paginacion $arrResult = $pConference->ObtainConferences($limit, $offset, $startDate, $endDate, "confDesc", $field_pattern, $conference); $pConfWeb = NULL; if ($bSoporteWebConf) { $pConfWeb = embedded_prepareWebConfLister(); } $arrData = null; if (is_array($arrResult) && $total > 0) { // En caso de haber soporte de conferencias web, se recoge el ID de // conferencia telefónica asociada a la conferencia web, y se construye // la lista de datos para las columnas adicionales $listaWebConf = array(); if (!is_null($pConfWeb)) { $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $listaWC = $pConfWeb->listarConferencias($pACL->isUserAdministratorGroup($_SESSION['elastix_user'])); foreach ($listaWC as $tuplaConf) { if (!is_null($tuplaConf['id_cbmysql_conference'])) { $listaWebConf[$tuplaConf['id_cbmysql_conference']] = $tuplaConf; } } } foreach ($arrResult as $key => $conference) { $arrTmp[0] = "<input type='checkbox' name='conference_{$conference['bookId']}' />"; $arrTmp[1] = "<a href='?menu={$module_name}&accion=view_conference&conferenceId=" . $conference['bookId'] . "'>" . htmlentities($conference['confDesc'], ENT_COMPAT, "UTF-8") . "</a>"; $arrTmp[2] = $conference['roomNo']; $arrTmp[3] = $conference['startTime'] . ' - ' . $conference['endTime']; if ($_POST['conference'] == "Current_Conferences") { $arrCallers = $pConference->ObtainCallers($dsn_agi_manager, $conference['roomNo']); $numCallers = count($arrCallers); $arrTmp[4] = "<a href='?menu={$module_name}&accion=show_callers&roomNo=" . $conference['roomNo'] . "'>{$numCallers} / {$conference['maxUser']}</a>"; } else { $arrTmp[4] = $conference['maxUser']; } if ($bSoporteWebConf) { $arrTmp[5] = ''; $arrTmp[6] = ''; $arrTmp[7] = ''; $arrTmp[8] = ''; if (isset($listaWebConf[$conference['bookId']])) { $tuplaConf = $listaWebConf[$conference['bookId']]; $arrTmp[5] = htmlentities($tuplaConf['tema'], ENT_COMPAT, "UTF-8"); $arrTmp[6] = $tuplaConf['num_invitados']; $arrTmp[7] = $tuplaConf['num_documentos']; $arrTmp[8] = "<a href=\"?menu={$module_name}&action=list_guests&id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['List guests']}]</a> " . "<a href=\"?menu={$module_name}&action=list_chatlog&id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['Chatlog']}]</a>"; } } $arrData[] = $arrTmp; } } $arrGrid = array("title" => $arrLang["Conference"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_conference.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, 'columns' => array(array('name' => ""), array("name" => $arrLang["Conference Name"]), array("name" => $arrLang["Conference #"]), array('name' => 'Period'), array('name' => $arrLang["Participants"]))); if ($bSoporteWebConf) { $arrGrid['columns'][] = array('name' => $arrLang['Topic']); $arrGrid['columns'][] = array('name' => $arrLang['# Guests']); $arrGrid['columns'][] = array('name' => $arrLang['# Docs']); $arrGrid['columns'][] = array('name' => $arrLang['Options']); } $oGrid->addNew("new_conference", _tr('New Conference')); $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete")); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function listarArchivos($module_name, $smarty, $local_templates_dir, $sDirectorio) { global $arrLang; // Función que rechaza los directorios punto y doble punto function _reject_dotdirs($s) { return !($s == '.' || $s == '..'); } $listaArchivos = file_exists($sDirectorio) && is_dir($sDirectorio) ? array_filter(scandir($sDirectorio), '_reject_dotdirs') : NULL; if (!is_array($listaArchivos)) { $smarty->assign("msj_err", _tr('This is not a valid directory')); } // Filtrar por la cadena indicada en el filtro $sSubStrArchivo = getParameter('file'); if ($sSubStrArchivo != '') { $t = array(); foreach ($listaArchivos as $sArchivo) { if (strpos($sArchivo, $sSubStrArchivo) !== FALSE) { $t[] = $sArchivo; } } $listaArchivos = $t; } // Mapear de la lista de archivos al listado completo con URLs $arrData = array(); foreach ($listaArchivos as $sArchivo) { $arrData[] = array(sprintf('<a href="%s">%s</a>', construirURL(array('menu' => $module_name, 'action' => 'edit', 'file' => $sArchivo, 'search' => $sSubStrArchivo, 'nav' => getParameter('nav'), 'page' => getParameter('page'))), htmlentities($sArchivo, ENT_COMPAT, 'UTF-8')), filesize($sDirectorio . $sArchivo)); } ////PARA EL PAGINEO $total = count($arrData); $limit = 25; $offset = 0; $oForm = new paloForm($smarty, array("file" => array("LABEL" => _tr("File"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""))); $smarty->assign("Filter", _tr('Filter')); $smarty->assign("NEW_FILE", _tr("New File")); $smarty->assign('url_new', construirURL(array('menu' => $module_name, 'action' => 'new'))); $oGrid = new paloSantoGrid($smarty); $arr = array("file" => getParameter("file"), "filter" => "Filter"); if (empty($_POST)) { $_POST = $arr; } $oGrid->addFilterControl(_tr("Filter applied ") . _tr("File") . " = " . $sSubStrArchivo, $_POST, array("file" => "")); $htmlFilter = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("File Editor"), $_POST); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $inicio = $total == 0 ? 0 : $offset + 1; $fin = $offset + $limit <= $total ? $offset + $limit : $total; $leng = $fin - $inicio; $arrDatosGrid = array_slice($arrData, $inicio - 1, $leng + 1); $arrGrid = array("title" => _tr("File Editor"), "url" => array('menu' => $module_name, 'file' => $sSubStrArchivo), "icon" => "/modules/{$module_name}/images/pbx_tools_asterisk_file_editor.png", "width" => "99%", "start" => $inicio, "end" => $fin, "total" => $total, "columns" => array(0 => array("name" => _tr("File List"), "property1" => ""), 1 => array("name" => _tr("File Size"), "property1" => ""))); $oGrid->addNew("?menu={$module_name}&action=new", _tr("New File"), true); $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid($arrGrid, $arrDatosGrid, $arrLang); }
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; }