function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoTrunk.class.php"; require_once "libs/misc.lib.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $contenido = ''; $msgError = ''; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB = new paloDB($dsn); $pDBSetting = new paloDB($arrConf['elastix_dsn']['settings']); $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']); $arrForm = array("default_rate" => array("LABEL" => $arrLang["Default Rate"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""), "default_rate_offset" => array("LABEL" => $arrLang["Default Rate Offset"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $arrForm); $oForm->setViewMode(); //obtener el valor de la tarifa por defecto $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); if (isset($_POST['edit_default'])) { $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } else { if (isset($_POST['save_default'])) { $oForm = new paloForm($smarty, $arrForm); $arrDefaultRate['default_rate'] = $_POST['default_rate']; $arrDefaultRate['default_rate_offset'] = $_POST['default_rate_offset']; if ($oForm->validateForm($_POST)) { $bValido = set_key_settings($pDBSetting, 'default_rate', $arrDefaultRate['default_rate']); $bValido = set_key_settings($pDBSetting, 'default_rate_offset', $arrDefaultRate['default_rate_offset']); if (!$bValido) { echo $arrLang["Error when saving default rate"]; } else { header("Location: index.php?menu=billing_setup"); } } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Value for rate is not valid"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } } } $arrTrunks = array(); $arrData = array(); $arrTrunksBill = array(); //obtener todos los trunks $oTrunk = new paloTrunk($pDBTrunk); //obtener todos los trunks que son para billing //$arrTrunksBill=array("DAHDI/g0","DAHDI/g1"); getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); if (isset($_POST['submit_bill_trunks'])) { //obtengo las que estan guardadas y las que ahora no estan $selectedTrunks = isset($_POST['trunksBills']) ? array_keys($_POST['trunksBills']) : array(); if (count($selectedTrunks) > 0) { foreach ($selectedTrunks as $selectedTrunk) { $nuevaListaTrunks[] = base64_decode($selectedTrunk); } } else { $nuevaListaTrunks = array(); } $listaTrunksNuevos = array_diff($nuevaListaTrunks, $arrTrunksBill); $listaTrunksAusentes = array_diff($arrTrunksBill, $nuevaListaTrunks); //tengo que borrar los trunks ausentes //tengo que agregar los trunks nuevos // print_r($listaTrunksNuevos); //print_r($listaTrunksAusentes); if (count($listaTrunksAusentes) > 0) { $bExito = $oTrunk->deleteTrunksBill($listaTrunksAusentes); if (!$bExito) { $msgError = $oTrunk->errMsg; } } if (count($listaTrunksNuevos) > 0) { $bExito = $oTrunk->saveTrunksBill($listaTrunksNuevos); if (!$bExito) { $msgError .= $oTrunk->errMsg; } } if (!empty($msgError)) { $smarty->assign("mb_message", $msgError); } } getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); $end = count($arrTrunks); if (is_array($arrTrunks)) { foreach ($arrTrunks as $trunk) { $arrTmp = array(); $checked = in_array($trunk[1], $arrTrunksBill) ? "checked" : ""; $arrTmp[0] = "<input type='checkbox' name='trunksBills[" . base64_encode($trunk[1]) . "]' {$checked}>"; $arrTmp[1] = $trunk[1]; $arrData[] = $arrTmp; } } $arrGrid = array("title" => $arrLang["Trunk Bill Configuration"], "icon" => "/modules/{$module_name}/images/reports_billing_setup.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Trunk"], "property1" => ""))); $oGrid = new paloSantoGrid($smarty); $oGrid->pagingShow(false); $oGrid->customAction('submit_bill_trunks', _tr('Billing Capable')); $trunk_config = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($trunk_config, '<form') === FALSE) { $trunk_config = "<form style='margin-bottom:0;' method='POST' action='?menu=billing_setup'>{$trunk_config}</form>"; } //mostrar los dos formularios $contenido .= $strReturn . $trunk_config; return $contenido; }
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 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 listRepositories($smarty, $module_name, $local_templates_dir, $arrConf) { global $arrLang; $oRepositories = new PaloSantoRepositories(); $arrReposActivos = array(); $typeRepository = getParameter("typeRepository"); if (isset($_POST['submit_aceptar'])) { foreach ($_POST as $key => $value) { if (substr($key, 0, 5) == 'repo-') { $arrReposActivos[] = substr($key, 5); } } $oRepositories->setRepositorios($arrConf['ruta_repos'], $arrReposActivos, $typeRepository, $arrConf["main_repos"]); } $option["main"] = ""; $option["others"] = ""; $option["all"] = ""; $arrRepositorios = $oRepositories->getRepositorios($arrConf['ruta_repos'], $typeRepository, $arrConf["main_repos"]); $limit = 40; $total = count($arrRepositorios); $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $arrData = array(); $version = $oRepositories->obtenerVersionDistro(); $arch = $oRepositories->obtenerArquitectura(); // print($arch); if (is_array($arrRepositorios)) { for ($i = $offset; $i < $end; $i++) { $activo = ""; if ($arrRepositorios[$i]['activo']) { $activo = "checked='checked'"; } $arrData[] = array("<input {$activo} name='repo-" . $arrRepositorios[$i]['id'] . "' type='checkbox' id='repo-{$i}' />", $valor = str_replace(array("\$releasever", "\$basearch"), array($version, $arch), $arrRepositorios[$i]['name'])); } } if (isset($typeRepository)) { $oGrid->setURL("?menu={$module_name}&typeRepository={$typeRepository}"); $_POST["typeRepository"] = $typeRepository; } else { $oGrid->setURL("?menu={$module_name}"); $_POST["typeRepository"] = "main"; } $arrGrid = array("title" => $arrLang["Repositories"], "icon" => "modules/repositories/images/system_updates_repositories.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $arrLang["Active"], "property1" => ""), 1 => array("name" => $arrLang["Name"], "property1" => ""))); $oGrid->customAction('submit_aceptar', _tr('Save/Update')); $oGrid->addButtonAction("default", _tr('Default'), null, "defaultValues({$total},'{$version}','{$arch}')"); $FilterForm = new paloForm($smarty, createFilter()); $arrOpt = array("main" => _tr('Main'), "others" => _tr('Others'), "all" => _tr('All')); if (isset($arrOpt[$typeRepository])) { $valorfiltro = $arrOpt[$typeRepository]; } else { $valorfiltro = _tr('Main'); } $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Repo") . " = " . $valorfiltro, $_POST, array("typeRepository" => "main"), true); $htmlFilter = $FilterForm->fetchForm("{$local_templates_dir}/new.tpl", "", $_POST); $oGrid->showFilter($htmlFilter); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoACL.class.php"; include_once "libs/paloSantoForm.class.php"; require_once "libs/misc.lib.php"; include_once "lib/paloSantoVoiceMail.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //segun el usuario que esta logoneado consulto si tiene asignada extension para buscar los voicemails $pDB = new paloDB($arrConf['elastix_dsn']['acl']); $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAMP = $pConfig->leer_configuracion(false); $dsnAsterisk = $arrAMP['AMPDBENGINE']['valor'] . "://" . $arrAMP['AMPDBUSER']['valor'] . ":" . $arrAMP['AMPDBPASS']['valor'] . "@" . $arrAMP['AMPDBHOST']['valor'] . "/asterisk"; $pDB_ast = new paloDB($dsnAsterisk); 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>"; } $arrVoiceData = array(); $inicio = $fin = $total = 0; $extension = $pACL->getUserExtension($_SESSION['elastix_user']); $ext = $extension; $esAdministrador = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']); $bandCustom = true; if (is_null($ext) || $ext == "") { $bandCustom = false; if (!$esAdministrador) { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); return ""; } } if ($esAdministrador) { $extension = "[[:digit:]]+"; } $smarty->assign("menu", "voicemail"); $smarty->assign("Filter", $arrLang['Show']); //formulario para el filtro $arrFormElements = createFieldFormVoiceList($arrLang); $oFilterForm = new paloForm($smarty, $arrFormElements); // Por omision las fechas toman el sgte. valor (la fecha de hoy) $date_start = date("Y-m-d") . " 00:00:00"; $date_end = date("Y-m-d") . " 23:59:59"; $dateStartFilter = getParameter('date_start'); $dateEndFilter = getParameter('date_end'); $report = false; if (getParameter('filter')) { if ($oFilterForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $date_start = translateDate($dateStartFilter) . " 00:00:00"; $date_end = translateDate($dateEndFilter) . " 23:59:59"; $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter); } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } if ($dateStartFilter == "") { $dateStartFilter = " "; } if ($dateEndFilter == "") { $dateEndFilter = " "; } //se añade control a los filtros $report = true; $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); } else { if (isset($dateStartFilter) and isset($dateEndFilter)) { $report = true; $date_start = translateDate($dateStartFilter) . " 00:00:00"; $date_end = translateDate($dateEndFilter) . " 23:59:59"; $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter); $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter); $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET); } else { $report = true; //se añade control a los filtros $arrDate = array('date_start' => date("d M Y"), 'date_end' => date("d M Y")); $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y"))); } } $oGrid = new paloSantoGrid($smarty); if ($report) { $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrDate['date_start'] . ", " . _tr("End Date") . " = " . $arrDate['date_end'], $arrDate, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); } if (getParameter('submit_eliminar')) { borrarVoicemails(); if ($oFilterForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $date_start = translateDate($_POST['date_start']) . " 00:00:00"; $date_end = translateDate($_POST['date_end']) . " 23:59:59"; $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end']); } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); } if (getParameter('config')) { if (!(is_null($ext) || $ext == "")) { return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast); } } if (getParameter('save')) { if (!save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast)) { return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast); } } if (getParameter('action') == "display_record") { $file = getParameter("name"); $ext = getParameter("ext"); $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $extension = $pACL->getUserExtension($user); $esAdministrador = $pACL->isUserAdministratorGroup($user); $path = "/var/spool/asterisk/voicemail/default"; $voicemailPath = "{$path}/{$ext}/INBOX/" . base64_decode($file); $tmpfile = basename($voicemailPath); $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}"; if (!is_file($filetmp)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } if (!$esAdministrador) { if ($extension != $ext) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } $voicemailPath = "{$path}/{$extension}/INBOX/" . base64_decode($file); } if (isset($file) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", base64_decode($file))) { if (!is_file($voicemailPath)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } $sContenido = ""; $name = basename($voicemailPath); $format = substr(strtolower($name), -3); // This will set the Content-Type to the appropriate setting for the file $ctype = ''; switch ($format) { case "mp3": $ctype = "audio/mpeg"; break; case "wav": $ctype = "audio/x-wav"; break; case "Wav": $ctype = "audio/x-wav"; break; case "WAV": $ctype = "audio/x-wav"; break; case "gsm": $ctype = "audio/x-gsm"; break; // not downloadable // not downloadable default: die("<b>404 " . $arrLang["no_file"] . "</b>"); break; } if ($sContenido == "") { $session_id = session_id(); } $sContenido = <<<contenido <embed src='index.php?menu={$module_name}&action=download&ext={$ext}&name={$file}&rawmode=yes&elastixSession={$session_id}' width=300, height=20 autoplay=true loop=false type="{$ctype}"></embed><br> contenido; $smarty->assign("CONTENT", $sContenido); $smarty->display("_common/popup.tpl"); } else { die("<b>404 " . $arrLang["no_file"] . "</b>"); } return; } if (getParameter('action') == "download") { $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $extension = $pACL->getUserExtension($user); $esAdministrador = $pACL->isUserAdministratorGroup($user); $record = getParameter("name"); $ext = getParameter("ext"); if (!preg_match("/^[[:digit:]]+\$/", $ext)) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } $record = base64_decode($record); $path = "/var/spool/asterisk/voicemail/default"; $voicemailPath = "{$path}/{$ext}/INBOX/" . $record; //"$path/$record"; $tmpfile = basename($voicemailPath); $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}"; if (!is_file($filetmp)) { die("<b>404 " . $arrLang["no_file"] . "</b>"); } if (!$esAdministrador) { if ($extension != $ext) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_extension"] . "</b>"); } $voicemailPath = "{$path}/{$extension}/INBOX/" . $record; } if (isset($record) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", $record)) { // See if the file exists if (!is_file($voicemailPath)) { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } // Gather relevent info about file $size = filesize($voicemailPath); $name = basename($voicemailPath); //$extension = strtolower(substr(strrchr($name,"."),1)); $extension = substr(strtolower($name), -3); // This will set the Content-Type to the appropriate setting for the file $ctype = ''; switch ($extension) { case "mp3": $ctype = "audio/mpeg"; break; case "wav": $ctype = "audio/x-wav"; break; case "Wav": $ctype = "audio/x-wav"; break; case "WAV": $ctype = "audio/x-wav"; break; case "gsm": $ctype = "audio/x-gsm"; break; // not downloadable // not downloadable default: die("<b>404 " . $arrLang["no_file"] . "</b>"); break; } // need to check if file is mislabeled or a liar. $fp = fopen($voicemailPath, "rb"); if ($size && $ctype && $fp) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: wav file"); header("Content-Type: " . $ctype); header("Content-Disposition: attachment; filename=" . $name); header("Content-Transfer-Encoding: binary"); header("Content-length: " . $size); fpassthru($fp); } } else { Header("HTTP/1.1 404 Not Found"); die("<b>404 " . $arrLang["no_file"] . "</b>"); } return; } $end = 0; $url = array('menu' => $module_name); //si tiene extension consulto sino, muestro un mensaje de que no tiene asociada extension $archivos = array(); if (!(is_null($ext) || $ext == "") || $esAdministrador) { if (is_null($ext) || $ext == "") { $smarty->assign("mb_message", "<b>" . $arrLang["no_extension_assigned"] . "</b>"); } $path = "/var/spool/asterisk/voicemail/default"; $folder = "INBOX"; if ($esAdministrador) { if ($handle = opendir($path)) { while (false !== ($dir = readdir($handle))) { if ($dir != "." && $dir != ".." && ereg($extension, $dir, $regs) && is_dir($path . "/" . $dir)) { $directorios[] = $dir; } } } } else { $directorios[] = $extension; } //if($esAdministrador) $arrData = array(); foreach ($directorios as $directorio) { $voicemailPath = "{$path}/{$directorio}/{$folder}"; if (file_exists($voicemailPath)) { if ($handle = opendir($voicemailPath)) { $bExito = true; while (false !== ($file = readdir($handle))) { //no tomar en cuenta . y .. //buscar los archivos de texto (txt) que son los que contienen los datos de las llamadas if ($file != "." && $file != ".." && ereg("(.+)\\.[txt|TXT]", $file, $regs)) { //leer la info del archivo $pConfig = new paloConfig($voicemailPath, $file, "=", "[[:space:]]*=[[:space:]]*"); $arrVoiceMailDes = array(); $arrVoiceMailDes = $pConfig->leer_configuracion(false); //verifico que tenga datos if (is_array($arrVoiceMailDes) && count($arrVoiceMailDes) > 0 && isset($arrVoiceMailDes['origtime']['valor'])) { //uso las fechas del filtro //si la fecha de llamada esta dentro del rango, la muestro $fecha = date("Y-m-d", $arrVoiceMailDes['origtime']['valor']); $hora = date("H:i:s", $arrVoiceMailDes['origtime']['valor']); if (strtotime("{$fecha} {$hora}") <= strtotime($date_end) && strtotime("{$fecha} {$hora}") >= strtotime($date_start)) { $arrTmp[0] = "<input type='checkbox' name='" . utf8_encode("voc-" . $file) . ",{$directorio}' />"; $arrTmp[1] = $fecha; $arrTmp[2] = $hora; $arrTmp[3] = $arrVoiceMailDes['callerid']['valor']; $arrTmp[4] = $arrVoiceMailDes['origmailbox']['valor']; $arrTmp[5] = $arrVoiceMailDes['duration']['valor'] . ' sec.'; $pathRecordFile = base64_encode($regs[1] . '.wav'); $recordingLink = "<a href='#' onClick=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&ext={$directorio}&name={$pathRecordFile}&rawmode=yes',350,100); return false;\">{$arrLang['Listen']}</a> "; $recordingLink .= "<a href='?menu={$module_name}&action=download&ext={$directorio}&name={$pathRecordFile}&rawmode=yes'>{$arrLang['Download']}</a>"; $arrTmp[6] = $recordingLink; $arrData[] = $arrTmp; } } } } closedir($handle); } } else { // No vale la ruta } } /* function sort_voicemails_hora_desc($a, $b) { return ($a[2] == $b[2]) ? 0 : (($a[2] < $b[2]) ? 1 : -1); } function sort_voicemails_fecha_desc($a, $b) { return ($a[1] == $b[1]) ? 0 : (($a[1] < $b[1]) ? 1 : -1); } usort($arrData, 'sort_voicemails_hora_desc'); usort($arrData, 'sort_voicemails_fecha_desc'); */ $fechas = array(); $horas = array(); foreach ($arrData as $llave => $fila) { $fechas[$llave] = $fila[1]; $horas[$llave] = $fila[2]; } array_multisort($fechas, SORT_DESC, $horas, SORT_DESC, $arrData); //Paginacion $limit = 15; $total = count($arrData); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; // Construyo el URL base if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) and count($arrFilterExtraVars) > 0) { $url = array_merge($url, $arrFilterExtraVars); } //Fin Paginacion $arrVoiceData = array_slice($arrData, $offset, $limit); } else { $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>"); } $arrGrid = array("title" => $arrLang["Voicemail List"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_voicemail.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Date"], "property1" => ""), 2 => array("name" => $arrLang["Time"], "property1" => ""), 3 => array("name" => $arrLang["CallerID"], "property1" => ""), 4 => array("name" => $arrLang["Extension"], "property1" => ""), 5 => array("name" => $arrLang["Duration"], "property1" => ""), 6 => array("name" => $arrLang["Message"], "property1" => ""))); if ($bandCustom == true) { $oGrid->customAction("config", _tr("Configuration")); } $oGrid->deleteList(_tr("Are you sure you wish to delete voicemails?"), "submit_eliminar", _tr("Delete")); $oGrid->showFilter($htmlFilter); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrVoiceData, $arrLang); if (strpos($contenidoModulo, '<form') === FALSE) { $contenidoModulo = "<form style='margin-bottom:0;' method='POST' action='?menu={$module_name}'>{$contenidoModulo}</form>"; } 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 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 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 viewMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEmailList = new paloSantoEmailList($pDB); $id_list = getParameter("id"); if (!$pEmailList->listExistsbyId($id_list)) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The List entered does not exist")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); $smarty->assign("IDEMAILLIST", $id_list); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("RETURN", _tr("Return")); $smarty->assign("LINK", "?menu={$module_name}&action=export&id={$id_list}&rawmode=yes"); $smarty->assign("EXPORT", _tr("Export Members")); $totalMembers = $pEmailList->getTotalMembers($id_list); $oGrid = new paloSantoGrid($smarty); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($totalMembers); $oGrid->setTitle(_tr("List Members of") . " " . $pEmailList->getListName($id_list)); $oGrid->setIcon("/modules/{$module_name}/images/email.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url = array('menu' => $module_name, 'action' => 'view_memberlist', 'id' => $id_list, 'filter_type' => $field_type, 'filter_txt' => $field_pattern); $oGrid->setURL($url); $arrColumns = array(_tr("Member name"), _tr("Member email")); $oGrid->setColumns($arrColumns); $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern); $arrData = null; if (is_array($arrResult) && $totalMembers > 0) { foreach ($arrResult as $key => $value) { $arrTmp[0] = $value["namemember"]; $arrTmp[1] = $value["mailmember"]; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); $arrFormFilterMembers = createFieldFilterViewMembers(); $oFilterForm = new paloForm($smarty, $arrFormFilterMembers); $arrType = array("name" => _tr("Name"), "email" => _tr("Email")); if (!is_null($field_type)) { $nameField = $arrType[$field_type]; } else { $nameField = ""; } $oGrid->customAction("return", _tr("Return")); $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true); //$arrFiltro = array("filter_type"=>$field_type,"filter_txt"=>$field_pattern); $oGrid->addFilterControl(_tr("Filter applied: ") . $nameField . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/view_members.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); if (strpos($content, '<form') === FALSE) { $content = "<form method='POST' style='margin-bottom:0;' action=" . construirURL($url) . ">{$content}</form>"; } return $content; }