function _moduleContent(&$smarty, $module_name) { load_language_module($module_name); //include module files include_once "modules/{$module_name}/configs/default.conf.php"; global $arrConf; require_once "modules/{$module_name}/libs/paloSantoHoldTime.class.php"; //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $relative_dir_rich_text = "modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $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"; $oDB = new paloDB($dsn); // se conecta a la base $pDB = new paloDB($arrConf["cadena_dsn"]); $htmlFilter = ""; if (!is_object($pDB->conn) || $pDB->errMsg != "") { $smarty->assign("mb_message", _tr("Error when connecting to database") . " " . $pDB->errMsg); } $oGrid = new paloSantoGrid($smarty); $arrGrid = array(); $arrData = array(); //llamamos a funcion que construye la vista $contenidoModulo = listadoHoldTime($pDB, $smarty, $module_name, $local_templates_dir, $oGrid, $arrGrid, $arrData); $oGrid->showFilter($htmlFilter); return $contenidoModulo; }
function _moduleContent(&$smarty, $module_name) { //global variables global $arrConf; //conexion resource $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsnAsteriskCdr = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asteriskcdrdb"; $pDB_cdr = new paloDB($dsnAsteriskCdr); //asteriskcdrdb -> CDR $pDB_billing = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/rate.db"); //sqlite3 -> rate.db //actions $accion = getAction(); $content = ""; switch ($accion) { case 'graph': $content = graphLinks($smarty, $module_name, $local_templates_dir); break; case 'imageTop10Salientes': case 'imageTop10Entrantes': // The following outputs image data directly and depends on rawmode=yes executeImage($module_name, $accion); $content = ''; break; default: $content = reportReportCall($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_billing, $arrConf, $arrLang); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoReportedeTroncalesusadasporHoraeneldia.class.php"; include_once "libs/paloSantoConfig.class.php"; $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); load_language_module($module_name); //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); //folder path for custom templates $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsnAsteriskCdr = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB = new paloDB($arrConf['dsn_conn_database']); $pDB_asterisk = new paloDB($dsnAsteriskCdr); //actions $accion = getAction(); $content = ""; switch ($accion) { default: $content = reportReportedeTroncalesusadasporHoraeneldia($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $pDB_asterisk); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantobilling_report.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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 $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $pDBSet = new paloDB($arrConf['elastix_dsn']['settings']); $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'] . "/asteriskcdrdb"; $pDB = new paloDB($dsn); $pDBTrunk = new paloDB($arrConf['dsn_conn_database_1']); $total = 0; $oCDR = new paloSantoCDR($pDB); $smarty->assign("menu", "billing_report"); $pDBSQLite = new paloDB($arrConf['dsn_conn_database_2']); //rate if (!empty($pDBSQLite->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $pRate = new paloRate($pDBSQLite); if (!empty($pRate->errMsg)) { echo "ERROR DE RATE: {$pRate->errMsg} <br>"; } $smarty->assign("module", $module_name); $smarty->assign("horas", $arrLang['horas']); $smarty->assign("minutos", $arrLang['minutos']); $smarty->assign("segundos", $arrLang['segundos']); //actions $action = getAction(); $content = ""; switch ($action) { default: $content = reportbilling_report($smarty, $module_name, $local_templates_dir, $pDBSet, $pDB, $pRate, $pDBTrunk, $pDBSQLite, $oCDR, $arrConf, $arrLang, $arrConfig); break; } return $content; }
function getDNSAGIManager() { $pConfig = new paloConfig("/var/www/elastixdir/asteriskconf", "/elastix_pbx.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn_agi_manager['password'] = $arrConfig['MGPASSWORD']['valor']; $dsn_agi_manager['user'] = $arrConfig['MGUSER']['valor']; $dsn_agi_manager['host'] = $arrConfig['DBHOST']['valor']; return $dsn_agi_manager; }
/** * Constructor * */ public function core_CDR() { $this->_dbCache = array(); $this->_pACL = NULL; $this->_id_user = NULL; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $ampConf = $pConfig->leer_configuracion(false); $this->_astcdrDSN = $ampConf['AMPDBENGINE']['valor'] . "://" . $ampConf['AMPDBUSER']['valor'] . ":" . $ampConf['AMPDBPASS']['valor'] . "@" . $ampConf['AMPDBHOST']['valor'] . "/asteriskcdrdb"; $this->errMsg = NULL; }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoReportCall.class.php"; include_once "libs/paloSantoConfig.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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 $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsnAsteriskCdr = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asteriskcdrdb"; $pDB_cdr = new paloDB($dsnAsteriskCdr); //asteriskcdrdb -> CDR $pDB_billing = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/rate.db"); //sqlite3 -> rate.db //actions $accion = getAction(); $content = ""; switch ($accion) { case 'graph': $content = graphLinks($smarty, $module_name, $local_templates_dir); break; case 'imageTop10Salientes': case 'imageTop10Entrantes': // The following outputs image data directly and depends on rawmode=yes executeImage($module_name, $accion); $content = ''; break; default: $content = reportReportCall($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_billing, $arrConf, $arrLang); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoConfig.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoRecordings.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); /* $lang=get_language(); $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"; */ load_language_module($module_name); //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 $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn_agi_manager['password'] = $arrConfig['AMPMGRPASS']['valor']; $dsn_agi_manager['host'] = $arrConfig['AMPDBHOST']['valor']; $dsn_agi_manager['user'] = '******'; $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']); $accion = getAction(); $content = ""; switch ($accion) { case "record": $content = new_recording($smarty, $module_name, $local_templates_dir, $arrLang, $dsn_agi_manager, $arrConf, $pDBACL); break; case "save": $content = save_recording($smarty, $module_name, $local_templates_dir, $arrLang, $arrConf, $pDBACL); break; default: $content = form_Recordings($smarty, $module_name, $local_templates_dir, $arrLang, $pDBACL); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoWeakKeys.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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 $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $dsn_asterisk = generarDSNSistema("asteriskuser", "asterisk"); $pDB = new paloDB($dsn_asterisk); $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAMP = $pConfig->leer_configuracion(false); $pConfig = new paloConfig($arrAMP['ASTETCDIR']['valor'], "asterisk.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAST = $pConfig->leer_configuracion(false); //actions $action = getAction(); $content = ""; switch ($action) { case "change": $content = editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB); break; case "save": $content = saveNewKey($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrAST, $arrAMP); break; default: $content = reportWeakKeys($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }
function leerColasEntrantesValidas() { //conexion resource $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsnAsteriskCdr = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB_asterisk = new paloDB($dsnAsteriskCdr); $oQueue = new paloQueue($pDB_asterisk); $PBXQueues = $oQueue->getQueue(); $arrQueue = array(); if (is_array($PBXQueues)) { foreach ($PBXQueues as $key => $value) { $result = $this->_DB->getFirstRowQuery('SELECT id, queue from queue_call_entry where queue = ?', TRUE, array($value[0])); if (is_array($result) && count($result) > 0) { // La clave debe ser cadena para que in_array en paloForm funcione $arrQueue[$result['id']] = $result['queue']; } } } return $arrQueue; }
function call2phone() { include_once "libs/paloSantoConfig.class.php"; require_once '/var/www/html/modules/address_book/libs/paloSantoAdressBook.class.php'; global $arrConf; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn_agi_manager['password'] = $arrConfig['AMPMGRPASS']['valor']; $dsn_agi_manager['host'] = $arrConfig['AMPDBHOST']['valor']; $dsn_agi_manager['user'] = '******'; $pDB = new paloDB($arrConf['dsn_conn_database']); // address_book $padress_book = new paloAdressBook($pDB); $sNumber = getParameter('call_number'); if (strpos($sNumber, '|') !== false) { $arrExt = explode(" | ", $sNumber); $sNumber = trim($arrExt[1]); } $response = array('action' => 'call2phone', 'message' => $sNumber); $extension = $_SESSION['callcenter']['agente']; $name = $sNumber; //$_SESSION['callcenter']['agente_nombre']; //var_dump($arrConf); if (is_null($sNumber) || !ctype_digit($sNumber)) { $response['action'] = 'error'; $response['message'] = 'Invalid or missing number to call'; } else { $prefix = prefixNumber($sNumber); $phone2call = $prefix . $sNumber; $result = $padress_book->Call2Phone($dsn_agi_manager, $extension, $phone2call, $extension, $name); if (!$result) { $response['action'] = 'error'; $response['message'] = 'Cuộc gọi không thực hiện được. Kiểm tra máy nhánh ' + $extension; } } $json = new Services_JSON(); Header('Content-Type: application/json'); return $json->encode($response); }
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"; require_once "libs/misc.lib.php"; //Incluir librería de lenguaje load_language_module($module_name); //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoCallPerAgent.class.php"; global $arrConf; global $arrLang; $arrCallsAgentTmp = 0; //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $pDB = new paloDB($cadena_dsn); $arrData = array(); $oCallsAgent = new paloSantoCallsAgent($pDB); $urlVars = array('menu' => $module_name); $smarty->assign("menu", "calls_per_agent"); $smarty->assign("Filter", _tr('Query')); $arrFormElements = createFieldFilter(); $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"; $arrFilterExtraVars = null; $fieldPat = array(); if (isset($_POST['filter'])) { 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"; if (!empty($_POST['field_pattern'])) { $fieldPat[$_POST['field_name']][] = $_POST['field_pattern']; } if (!empty($_POST['field_pattern_1'])) { $fieldPat[$_POST['field_name_1']][] = $_POST['field_pattern_1']; } $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end'], "field_name" => $_POST['field_name'], "field_pattern" => $_POST['field_pattern'], "field_name_1" => $_POST['field_name_1'], "field_pattern_1" => $_POST['field_pattern_1']); } else { // Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); } else { if (isset($_GET['date_start']) and isset($_GET['date_end'])) { $date_start = translateDate($_GET['date_start']) . " 00:00:00"; $date_end = translateDate($_GET['date_end']) . " 23:59:59"; if (!empty($_GET['field_pattern'])) { $fieldPat[$_GET['field_name']][] = $_GET['field_pattern']; } if (!empty($_GET['field_pattern_1'])) { $fieldPat[$_GET['field_name_1']][] = $_GET['field_pattern_1']; } $arrFilterExtraVars = array("date_start" => $_GET['date_start'], "date_end" => $_GET['date_end']); $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET); } else { $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'agent', 'field_pattern' => '', 'field_name_1' => 'agent', 'field_pattern_1' => '')); } } $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->showFilter($htmlFilter); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes'; $offset = 0; $limit = 20; if (isset($fieldPat['type'])) { $fieldPat['type'] = array_map('strtoupper', $fieldPat['type']); } $arrCallsAgentTmp = $oCallsAgent->obtenerCallsAgent($date_start, $date_end, $fieldPat); if (!is_array($arrCallsAgentTmp)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCallsAgent->errMsg)); $arrCallsAgentTmp = array(); } $totalCallsAgents = count($arrCallsAgentTmp); // Si se quiere avanzar a la sgte. pagina if ($bElastixNuevo) { $oGrid->setLimit($limit); $oGrid->setTotal($totalCallsAgents + 1); $offset = $oGrid->calculateOffset(); } else { if (isset($_GET['nav']) && $_GET['nav'] == "end") { // Mejorar el sgte. bloque. if ($totalCallsAgents % $limit == 0) { $offset = $totalCallsAgents - $limit; } else { $offset = $totalCallsAgents - $totalCallsAgents % $limit; } } // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "next") { $offset = $_GET['start'] + $limit - 1; } // Si se quiere retroceder if (isset($_GET['nav']) && $_GET['nav'] == "previous") { $offset = $_GET['start'] - $limit - 1; } } // Bloque comun $arrCallsAgent = array_slice($arrCallsAgentTmp, $offset, $limit); $arrData = array(); $sumCallAnswered = $sumDuration = $timeMayor = 0; foreach ($arrCallsAgent as $cdr) { $arrData[] = array($cdr['agent_number'], htmlentities($cdr['agent_name'], ENT_COMPAT, 'UTF-8'), $cdr['type'], $cdr['queue'], $cdr['num_answered'], formatoSegundos($cdr['sum_duration']), formatoSegundos($cdr['avg_duration']), formatoSegundos($cdr['max_duration'])); $sumCallAnswered += $cdr['num_answered']; // Total de llamadas contestadas $sumDuration += $cdr['sum_duration']; // Total de segundos en llamadas $timeMayor = $timeMayor < $cdr['max_duration'] ? $cdr['max_duration'] : $timeMayor; } $sTagInicio = !$bExportando ? '<b>' : ''; $sTagFinal = $sTagInicio != '' ? '</b>' : ''; $arrData[] = array($sTagInicio . _tr('Total') . $sTagFinal, '', '', '', $sTagInicio . $sumCallAnswered . $sTagFinal, $sTagInicio . formatoSegundos($sumDuration) . $sTagFinal, $sTagInicio . formatoSegundos($sumCallAnswered > 0 ? $sumDuration / $sumCallAnswered : 0) . $sTagFinal, $sTagInicio . formatoSegundos($timeMayor) . $sTagFinal); // Construyo el URL base if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) && count($arrFilterExtraVars) > 0) { $urlVars = array_merge($urlVars, $arrFilterExtraVars); } if ($bElastixNuevo) { $oGrid->setURL(construirURL($urlVars, array("nav", "start"))); $oGrid->setData($arrData); $arrColumnas = array(_tr("No.Agent"), _tr("Agent"), _tr("Type"), _tr("Queue"), _tr("Calls answered"), _tr("Duration"), _tr("Average"), _tr("Call longest")); $oGrid->setColumns($arrColumnas); $oGrid->setTitle(_tr("Calls per Agent")); $oGrid->pagingShow(true); $oGrid->setNameFile_Export(_tr("Calls per Agent")); $smarty->assign("SHOW", _tr("Show")); return $oGrid->fetchGrid(); } else { $url = construirURL($urlVars, array("nav", "start")); $offset = 0; $total = count($arrData); $limit = $total; $arrGrid = array("title" => _tr("Calls per Agent"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array(0 => array("name" => _tr("No.Agent"), "property" => ""), 1 => array("name" => _tr("Agent"), "property" => ""), 2 => array("name" => _tr("Type"), "property" => ""), 3 => array("name" => _tr("Queue"), "property" => ""), 4 => array("name" => _tr("Calls answered"), "property" => ""), 5 => array("name" => _tr("Duration"), "property" => ""), 6 => array("name" => _tr("Average"), "property" => ""), 7 => array("name" => _tr("Call longest"), "property" => ""))); if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) { return $oGrid->fetchGridPDF($arrGrid, $arrData); } if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) { return $oGrid->fetchGridXLS($arrGrid, $arrData); } if ($bExportando) { header("Cache-Control: private"); header("Pragma: cache"); header('Content-Type: application/octet-stream'); header('Content-disposition: inline; filename="calls_per_agent.csv"'); header('Content-Type: application/force-download'); } if ($bExportando) { return $oGrid->fetchGridCSV($arrGrid, $arrData); } $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; } }
function createDialPlanFeaturesCode(&$arrFromInt) { if (!$this->validateFeatureCodePBX()) { return false; } $pConfig = new paloConfig("/var/www/elastixdir/asteriskconf", "elastix_pbx.conf", "=", "[[:space:]]*=[[:space:]]*"); $confAsterisk = $pConfig->leer_configuracion(false); $arrContexts = array(); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionBlacklist($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionCF($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionCW($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionDICT($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionDND($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionInfo($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionSpeedDial($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionVM($arrFromInt)); $arrContexts = array_merge($arrContexts, $this->createDialPlanFuntionCore($arrFromInt)); return $arrContexts; }
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 _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoACL.class.php"; include_once "modules/{$module_name}/configs/default.conf.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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); //conexion acl.db $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']; $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"; $pDBa = new paloDB($dsn); //////////////////// if (!empty($pDB->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $arrData = array(); $arrData[""] = $arrLang["no extension"]; $pACL = new paloACL($pDB); if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } /*******/ $typeUser = ""; $userLevel1 = ""; $extOther = ""; $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $idUserAccount = $pACL->isUserAdministratorGroup($userAccount); $idUserInt = $pACL->getIdUser($userAccount); if ($idUserAccount) { $userLevel1 = "admin"; } else { $userLevel1 = "other"; } $smarty->assign("userLevel1", $userLevel1); /*******/ $sQuery = "select extension from users order by extension;"; $arrayResult = $pDBa->fetchTable($sQuery, true); if (!$arrayResult) { $error = $pDBa->errMsg; } else { if (is_array($arrayResult) && count($arrayResult) > 0) { //$arrData[$item["null"]] = "No extension"; if ($idUserAccount) { foreach ($arrayResult as $item) { $arrData[$item["extension"]] = $item["extension"]; } } else { $idOther = $pACL->getIdUser($userAccount); $arrUserOther = $pACL->getUsers($idOther); $extOther = $arrUserOther[0][3]; $arrData[$extOther] = $extOther; } } } $arrGruposACL = $pACL->getGroups(); for ($i = 0; $i < count($arrGruposACL); $i++) { if ($arrGruposACL[$i][1] == 'administrator') { $arrGruposACL[$i][1] = $arrLang['administrator']; } else { if ($arrGruposACL[$i][1] == 'operator') { $arrGruposACL[$i][1] = $arrLang['operator']; } else { if ($arrGruposACL[$i][1] == 'extension') { $arrGruposACL[$i][1] = $arrLang['extension']; } } } if ($idUserAccount) { $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1]; } else { $arrUserPer = $pACL->getMembership($idUserInt); foreach ($arrUserPer as $key => $value) { if ($arrGruposACL[$i][1] == $key) { $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1]; } } } } $arrFormElements = array("description" => array("LABEL" => "{$arrLang['Name']} {$arrLang['(Ex. John Doe)']}", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "name" => array("LABEL" => $arrLang["Login"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no"), "password1" => array("LABEL" => $arrLang["Password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "password2" => array("LABEL" => $arrLang["Retype password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => $arrLang["Group"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrGrupos, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "extension" => array("LABEL" => $arrLang["Extension"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrData, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailpassword1" => array("LABEL" => $arrLang["Webmail Password"], "REQUIRED" => "no", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailuser" => array("LABEL" => $arrLang["Webmail User"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmaildomain" => array("LABEL" => $arrLang["Webmail Domain"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $contenidoModulo = ""; $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("APPLY_CHANGES", $arrLang["Apply changes"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("DELETE", $arrLang["Delete"]); $smarty->assign("CONFIRM_CONTINUE", $arrLang["Are you sure you wish to continue?"]); $smarty->assign("icon", "images/user.png"); $smarty->assign("title_webmail", $arrLang["Mail Profile"]); if (isset($_POST['submit_create_user'])) { // Implementar include_once "libs/paloSantoForm.class.php"; $arrFillUser['description'] = ''; $arrFillUser['name'] = ''; $arrFillUser['group'] = ''; $arrFillUser['extension'] = ''; $arrFillUser['password1'] = ''; $arrFillUser['password2'] = ''; $oForm = new paloForm($smarty, $arrFormElements); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $arrFillUser); } else { if (!is_null(getParameter("edit"))) { $contenidoModulo = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1); } else { if (isset($_POST['submit_save_user'])) { 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); if (empty($_POST['password1']) or $_POST['password1'] != $_POST['password2']) { // Error claves $smarty->assign("mb_message", $arrLang["The passwords are empty or don't match"]); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST); } else { if ($userLevel1 == "admin") { // Creo al usuario $md5_password = md5($_POST['password1']); $pACL->createUser($_POST['name'], $_POST['description'], $md5_password, $_POST['extension']); $idUser = $pACL->getIdUser($_POST['name']); // Versiones viejas del archivo acl.db tienen una fila con una // tupla que asocia al usuario inexistente con ID 2, con el // grupo 2 (Operadores). Se limpia cualquier membresía extraña. $listaMembresia = $pACL->getMembership($idUser); if (is_array($listaMembresia) && count($listaMembresia) > 0) { foreach ($listaMembresia as $idGrupo) { $pACL->delFromGroup($idUser, $idGrupo); } } // Creo la membresia $pACL->addToGroup($idUser, $_POST['group']); $bExito = TRUE; if (empty($pACL->errMsg)) { $nuevasPropiedades = array(); if (!empty($_POST['webmailuser'])) { $nuevasPropiedades['login'] = $_POST['webmailuser']; } if (!empty($_POST['webmailpassword1'])) { $nuevasPropiedades['password'] = $_POST['webmailpassword1']; } if (!empty($_POST['webmaildomain'])) { $nuevasPropiedades['domain'] = $_POST['webmaildomain']; } $bExito = actualizarPropiedades($pDB, $smarty, $idUser, 'webmail', 'default', $nuevasPropiedades); } if (!empty($pACL->errMsg)) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST); } else { if ($bExito) { header("Location: ?menu=userlist"); } } } else { $smarty->assign("mb_message", $arrLang["userNoAllowed"]); } } } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['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}/new.tpl", $arrLang["New User"], $_POST); } } else { if (isset($_POST['submit_apply_changes'])) { $arrayContent = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther); if (isset($arrayContent["mb_title"]) && isset($arrayContent["mb_message"])) { $smarty->assign("mb_title", $arrayContent["mb_title"]); $smarty->assign("mb_message", $arrayContent["mb_message"]); } if ($arrayContent["success"]) { header("Location: ?menu=userlist"); } else { if (isset($arrayContent["id_user"])) { $smarty->assign("id_user", $_POST['id_user']); } if (isset($arrayContent["fill_user"])) { $contenidoModulo = $arrayContent["form"]->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Edit User"], $arrayContent["fill_user"]); } else { $contenidoModulo = $arrayContent["content"]; } } } else { if (isset($_GET['action']) && $_GET['action'] == "view") { if (!$pACL->isUserAdministratorGroup($userAccount)) { if ($pACL->getIdUser($userAccount) != $_GET['id']) { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["You are not authorized to access to information of that user"]); return reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount); } } 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" $arrUser = $pACL->getUsers($_GET['id']); // Conversion de formato $arrTmp['name'] = $arrUser[0][1]; $arrTmp['description'] = $arrUser[0][2]; $arrTmp['password1'] = "****"; $arrTmp['password2'] = "****"; $arrTmp['extension'] = $arrUser[0][3]; //- TODO: Falta llenar el grupo $arrMembership = $pACL->getMembership($_GET['id']); $id_group = ""; if (is_array($arrMembership)) { foreach ($arrMembership as $groupName => $groupId) { $id_group = $groupId; // Asumo que cada usuario solo puede pertenecer a un grupo break; } } $arrTmp['group'] = $id_group; $listaPropiedades = leerPropiedadesWebmail($pDB, $smarty, $_GET['id']); if (isset($listaPropiedades['login'])) { $arrTmp['webmailuser'] = $listaPropiedades['login']; } if (isset($listaPropiedades['domain'])) { $arrTmp['webmaildomain'] = $listaPropiedades['domain']; } if (isset($listaPropiedades['password'])) { $arrTmp['webmailpassword1'] = '****'; } //if (isset($listaPropiedades['imapsvr'])) $arrTmp['webmailimapsvr'] = $listaPropiedades['imapsvr']; $smarty->assign("id_user", $_GET['id']); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["View User"], $arrTmp); // hay que pasar el arreglo } else { if (getParameter('action') == "edit_userExtension") { $smarty->assign("editUserExtension", "yes"); $html = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1); $smarty->assign("CONTENT", $html); $smarty->assign("THEMENAME", $arrConf['mainTheme']); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("path", ""); $contenidoModulo = $smarty->display("{$local_templates_dir}/edit_userExtension.tpl"); } else { if (getParameter('action') == "apply_changes_UserExtension") { include_once "libs/paloSantoJSON.class.php"; $jsonObject = new PaloSantoJSON(); $result = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther); $arrMessage["mb_title"] = isset($result["mb_title"]) ? $result["mb_title"] : null; $arrMessage["mb_message"] = isset($result["mb_message"]) ? $result["mb_message"] : null; $arrMessage["success"] = $result["success"]; $jsonObject->set_message($arrMessage); $contenidoModulo = $jsonObject->createJSON(); } else { $contenidoModulo = reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount); } } } } } } } return $contenidoModulo; }
function formEditCampaign($pDB, $smarty, $module_name, $local_templates_dir, $id_campaign = NULL) { include_once "libs/paloSantoQueue.class.php"; include_once "modules/form_designer/libs/paloSantoDataForm.class.php"; // Si se ha indicado cancelar, volver a listado sin hacer nada más if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); // Leer los datos de la campaña, si es necesario $arrCampaign = NULL; $oCamp = new paloSantoCampaignCC($pDB); if (!is_null($id_campaign)) { $arrCampaign = $oCamp->getCampaigns(null, null, $id_campaign); if (!is_array($arrCampaign) || count($arrCampaign) == 0) { $smarty->assign("mb_title", 'Unable to read campaign'); $smarty->assign("mb_message", 'Cannot read campaign - ' . $oCamp->errMsg); return ''; } } // Obtener y conectarse a base de datos de FreePBX $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"; $oDB = new paloDB($dsn); // Leer las troncales que se han definido en FreePBX $arrDataTrunks = array('' => '(' . _tr('By Dialplan') . ')'); $arrTrunks = getTrunks($oDB); //obtener la lista de trunks if (is_array($arrTrunks)) { foreach ($arrTrunks as $trunk) { $arrDataTrunks[$trunk[1]] = $trunk[1]; } } // Leer las colas que se han definido en FreePBX, y quitar las usadas // en campañas entrantes. $arrDataQueues = array(); $oQueue = new paloQueue($oDB); $arrQueues = $oQueue->getQueue(); // Todas las colas, entrantes y salientes if (is_array($arrQueues)) { $query_call_entry = "SELECT queue FROM queue_call_entry WHERE estatus = 'A'"; $arr_call_entry = $pDB->fetchTable($query_call_entry); // Las colas entrantes $colasEntrantes = array(); foreach ($arr_call_entry as $row) { $colasEntrantes[] = $row[0]; } foreach ($arrQueues as $rowQueue) { if (!in_array($rowQueue[0], $colasEntrantes)) { $arrDataQueues[$rowQueue[0]] = $rowQueue[1]; } } } $arrUrlsExternos = array('' => _tr('(No external URL)')) + $oCamp->getExternalUrls(); // Cargar la información de todos los formularios creados y activos $oDataForm = new paloSantoDataForm($pDB); $arrDataForm = $oDataForm->getFormularios(NULL, 'A'); // Impedir mostrar el formulario si no se han definido colas o no // quedan colas libres para usar en campañas salientes. if (count($arrQueues) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_queues', 1); } elseif (count($arrDataQueues) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_outgoing_queues', 1); } elseif (count($arrDataForm) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_forms', 1); } else { $smarty->assign('label_manage_trunks', _tr('Manage Trunks')); $smarty->assign('label_manage_queues', _tr('Manage Queues')); $smarty->assign('label_manage_forms', _tr('Manage Forms')); $smarty->assign('label_manage_external_url', _tr('Manage External URLs')); // Definición del formulario de nueva campaña $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign('LABEL_CALL_FILE', _tr('Call File')); // Valores por omisión para primera carga $arrNoElegidos = array(); // Lista de selección de formularios elegibles $arrElegidos = array(); // Lista de selección de formularios ya elegidos $values_form = NULL; // Selección hecha en el formulario if (is_null($id_campaign)) { if (!isset($_POST['nombre'])) { $_POST['nombre'] = ''; } if (!isset($_POST["context"]) || $_POST["context"] == "") { $_POST["context"] = "from-internal"; } if (!isset($_POST['max_canales']) || $_POST['max_canales'] == '') { $_POST['max_canales'] = 23; } if (!isset($_POST['reintentos']) || $_POST['reintentos'] == '') { $_POST['reintentos'] = 5; } if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = ''; } if (!isset($_POST['values_form'])) { $_POST['values_form'] = ''; } //$_POST['formulario']= explode(",", $_POST['values_form']); $values_form = explode(",", $_POST['values_form']); } else { if (!isset($_POST['nombre'])) { $_POST['nombre'] = $arrCampaign[0]['name']; } if (!isset($_POST['fecha_ini'])) { $_POST['fecha_ini'] = date('d M Y', strtotime($arrCampaign[0]['datetime_init'])); } if (!isset($_POST['fecha_fin'])) { $_POST['fecha_fin'] = date('d M Y', strtotime($arrCampaign[0]['datetime_end'])); } $arrDateTimeInit = explode(":", $arrCampaign[0]['daytime_init']); $arrDateTimeEnd = explode(":", $arrCampaign[0]['daytime_end']); if (!isset($_POST['hora_ini_HH'])) { $_POST['hora_ini_HH'] = isset($arrDateTimeInit[0]) ? $arrDateTimeInit[0] : "00"; } if (!isset($_POST['hora_ini_MM'])) { $_POST['hora_ini_MM'] = isset($arrDateTimeInit[1]) ? $arrDateTimeInit[1] : "00"; } if (!isset($_POST['hora_fin_HH'])) { $_POST['hora_fin_HH'] = isset($arrDateTimeEnd[0]) ? $arrDateTimeEnd[0] : "00"; } if (!isset($_POST['hora_fin_MM'])) { $_POST['hora_fin_MM'] = isset($arrDateTimeEnd[1]) ? $arrDateTimeEnd[1] : "00"; } if (!isset($_POST['reintentos'])) { $_POST['reintentos'] = $arrCampaign[0]['retries']; } if (!isset($_POST['trunk'])) { $_POST['trunk'] = $arrCampaign[0]['trunk']; } if (!isset($_POST['queue'])) { $_POST['queue'] = $arrCampaign[0]['queue']; } if (!isset($_POST['context'])) { $_POST['context'] = $arrCampaign[0]['context']; } if (!isset($_POST['max_canales'])) { $_POST['max_canales'] = $arrCampaign[0]['max_canales']; } //$_POST['script'] = ""; if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = $arrCampaign[0]['script']; } //if (!isset($_POST['formulario'])) $_POST['formulario'] = ""; //if (!isset($_POST['formularios_elegidos'])) $_POST['formularios_elegidos'] = ""; if (!isset($_POST['values_form'])) { $values_form = $oCamp->obtenerCampaignForm($id_campaign); } else { $values_form = explode(",", $_POST['values_form']); } if (!isset($_POST['external_url'])) { $_POST['external_url'] = $arrCampaign[0]['id_url']; } } // rte_script es un HTML complejo que debe de construirse con Javascript. $smarty->assign("rte_script", adaptar_formato_rte($_POST['rte_script'])); // Clasificar los formularios elegidos y no elegidos foreach ($arrDataForm as $key => $form) { if (in_array($form['id'], $values_form)) { $arrElegidos[$form['id']] = $form['nombre']; } else { $arrNoElegidos[$form['id']] = $form['nombre']; } } // Generación del objeto de formulario $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, $arrNoElegidos, $arrElegidos, $arrUrlsExternos); $oForm = new paloForm($smarty, $formCampos); if (!is_null($id_campaign)) { $oForm->setEditMode(); $smarty->assign('id_campaign', $id_campaign); } // En esta implementación el formulario trabaja exclusivamente en modo 'input' // y por lo tanto proporciona el botón 'save' $bDoCreate = isset($_POST['save']); $bDoUpdate = isset($_POST['apply_changes']); if ($bDoCreate || $bDoUpdate) { if (!$oForm->validateForm($_POST) || (!isset($_POST['rte_script']) || $_POST['rte_script'] == '')) { // Falla la validación básica del formulario $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } if (!isset($_POST['rte_script']) || $_POST['rte_script'] == '') { $strErrorMsg .= _tr("Script"); } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } elseif ($_POST['max_canales'] <= 0) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('At least 1 used channel must be allowed.')); } elseif ((int) $_POST['reintentos'] <= 0) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Campaign must allow at least one call retry')); } elseif ($bDoCreate && !in_array($_POST['encoding'], mb_list_encodings())) { $smarty->assign("mb_title", _tr('Validation Error')); $smarty->assign("mb_message", _tr('Invalid character encoding')); } elseif ($bDoCreate && empty($_FILES['phonefile']['tmp_name'])) { $smarty->assign("mb_title", _tr('Validation Error')); $smarty->assign("mb_message", _tr('Call file not specified or failed to be uploaded')); } else { $time_ini = $_POST['hora_ini_HH'] . ":" . $_POST['hora_ini_MM']; $time_fin = $_POST['hora_fin_HH'] . ":" . $_POST['hora_fin_MM']; $iFechaIni = strtotime($_POST['fecha_ini']); $iFechaFin = strtotime($_POST['fecha_fin']); $iHoraIni = strtotime($time_ini); $iHoraFin = strtotime($time_fin); if ($iFechaIni == -1 || $iFechaIni === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse start date specification')); } elseif ($iFechaFin == -1 || $iFechaFin === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse end date specification')); } elseif ($iHoraIni == -1 || $iHoraIni === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse start time specification')); } elseif ($iHoraFin == -1 || $iHoraFin === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse end time specification')); } else { if (!$pDB->genQuery("SET AUTOCOMMIT=0")) { $smarty->assign("mb_message", $pDB->errMsg); } else { $bExito = TRUE; if ($bDoCreate) { $id_campaign = $oCamp->createEmptyCampaign($_POST['nombre'], $_POST['max_canales'], $_POST['reintentos'], $_POST['trunk'], $_POST['context'], $_POST['queue'], date('Y-m-d', $iFechaIni), date('Y-m-d', $iFechaFin), $time_ini, $time_fin, $_POST['rte_script'], $_POST['external_url'] == '' ? NULL : (int) $_POST['external_url']); if (is_null($id_campaign)) { $bExito = FALSE; } } elseif ($bDoUpdate) { $bExito = $oCamp->updateCampaign($id_campaign, $_POST['nombre'], $_POST['max_canales'], $_POST['reintentos'], $_POST['trunk'], $_POST['context'], $_POST['queue'], date('Y-m-d', $iFechaIni), date('Y-m-d', $iFechaFin), $time_ini, $time_fin, $_POST['rte_script'], $_POST['external_url'] == '' ? NULL : (int) $_POST['external_url']); } // Introducir o actualizar formularios if ($bExito && isset($_POST['values_form'])) { if ($bDoCreate) { $bExito = $oCamp->addCampaignForm($id_campaign, $_POST['values_form']); } elseif ($bDoUpdate) { $bExito = $oCamp->updateCampaignForm($id_campaign, $_POST['values_form']); } } // Para creación, se introduce lista de valores CSV if ($bExito && !empty($_FILES['phonefile']['tmp_name'])) { // Se puede tardar mucho tiempo en la inserción ini_set('max_execution_time', 3600); $sEncoding = $_POST['encoding']; $bExito = $oCamp->addCampaignNumbersFromFile($id_campaign, $_FILES['phonefile']['tmp_name'], $sEncoding); if ($bExito && $bDoUpdate && $arrCampaign[0]['estatus'] == 'T') { // Agregar números a una campaña terminada debe volverla a activar $oCamp->activar_campaign($id_campaign, 'A'); } } // Confirmar o deshacer la transacción según sea apropiado if ($bExito) { $pDB->genQuery("COMMIT"); header("Location: ?menu={$module_name}"); } else { $pDB->genQuery("ROLLBACK"); $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $oCamp->errMsg); } } $pDB->genQuery("SET AUTOCOMMIT=1"); } } } } $smarty->assign('icon', 'images/kfaxview.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_campaign) ? _tr("New Campaign") : _tr("Edit Campaign") . ' "' . $_POST['nombre'] . '"', $_POST); return $contenidoModulo; }
/** * Función para construir un DSN para conectarse a varias bases de datos * frecuentemente utilizadas en Elastix. Para cada base de datos reconocida, se * busca la clave en /etc/elastix.conf o en /etc/amportal.conf según corresponda. * * @param string $sNombreUsuario Nombre de usuario para interrogar * @param string $sNombreDB Nombre de base de datos para DNS * @param string $ruta_base Ruta base para inclusión de librerías * * @return mixed NULL si no se reconoce usuario, o el DNS con clave resuelta */ function generarDSNSistema($sNombreUsuario, $sNombreDB, $ruta_base = '') { require_once $ruta_base . 'libs/paloSantoConfig.class.php'; switch ($sNombreUsuario) { case 'root': $sClave = obtenerClaveConocidaMySQL($sNombreUsuario, $ruta_base); if (is_null($sClave)) { return NULL; } return 'mysql://*****:*****@localhost/' . $sNombreDB; case 'asteriskuser': $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $listaParam = $pConfig->leer_configuracion(FALSE); return $listaParam['AMPDBENGINE']['valor'] . "://" . $listaParam['AMPDBUSER']['valor'] . ":" . $listaParam['AMPDBPASS']['valor'] . "@" . $listaParam['AMPDBHOST']['valor'] . "/" . $sNombreDB; } return NULL; }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoValidar.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/misc.lib.php"; include_once "libs/paloSantoForm.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoConference.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']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsnMeetme = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/meetme"; $dsn_agi_manager['password'] = $arrConfig['AMPMGRPASS']['valor']; $dsn_agi_manager['host'] = $arrConfig['AMPDBHOST']['valor']; $dsn_agi_manager['user'] = '******'; //solo para obtener los devices (extensiones) creadas. $dsnAsterisk = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB = new paloDB($dsnMeetme); if (isset($_POST["new_conference"])) { $accion = "new_conference"; } else { if (isset($_POST["add_conference"])) { $accion = "add_conference"; } else { if (isset($_POST["cancel"])) { $accion = "cancel"; } else { if (isset($_POST["new_open"])) { $accion = "new_conference"; } else { if (isset($_POST["delete_conference"])) { $accion = "delete_conference"; } else { if (isset($_POST["caller_invite"])) { $accion = "caller_invite"; } else { if (isset($_POST["callers_mute"])) { $accion = "callers_mute"; } else { if (isset($_POST["callers_kick"])) { $accion = "callers_kick"; } else { if (isset($_POST["callers_kick_all"])) { $accion = "callers_kick_all"; } else { if (isset($_POST["update_show_callers"])) { $accion = "update_show_callers"; } else { if (isset($_GET["accion"]) && $_GET["accion"] == "show_callers") { $accion = "show_callers"; } else { if (isset($_GET["accion"]) && $_GET["accion"] == "view_conference") { $accion = "view_conference"; } else { if (isset($_GET["action"]) && $_GET["action"] == "list_guests") { $accion = "list_guests"; } else { if (isset($_GET["action"]) && $_GET["action"] == "list_chatlog") { $accion = "list_chatlog"; } else { $accion = "report_conference"; } } } } } } } } } } } } } } $content = ""; switch ($accion) { case "new_conference": $content = new_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsnAsterisk); break; case "add_conference": $content = add_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsnAsterisk); break; case "cancel": header("Location: ?menu={$module_name}"); break; case "delete_conference": $content = delete_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "show_callers": $content = show_callers($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "callers_mute": $content = callers_mute($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "callers_kick": $content = callers_kick($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "view_conference": $content = view_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsnAsterisk); break; case "callers_kick_all": $content = callers_kick_all($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "caller_invite": $content = caller_invite($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case "update_show_callers": $room = getParameter('roomNo'); header("location: ?menu={$module_name}&accion=show_callers&roomNo={$room}"); break; case 'list_guests': // Para caso de conferencias web $content = embedded_webConf_mostrarListaInvitados($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; case 'list_chatlog': // Para caso de conferencias web $content = embedded_webConf_mostrarChatlog($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; default: $content = report_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang, $arrConfig, $dsn_agi_manager, $dsnAsterisk); break; } return $content; }
/** Funcion que devuelve un arreglo que contiene los lenguages soportados en el servidor por asterisk @return array */ function getLanguagePBX() { $arrLang = array(); $pConfig = new paloConfig("/var/www/elastixdir/asteriskconf", "elastix_pbx.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $astlibsound = $arrConfig['ASTVARLIBDIR']['valor'] . "/sounds"; $listDir = scandir($astlibsound); if ($listDir !== false) { foreach ($listDir as $value) { if ($value != "." && $value != "..") { if (is_dir($astlibsound . "/" . $value)) { if (preg_match("/^[a-z]{2}(-[A-Z]{2})*\$/", $value) == true) { $list = scandir($astlibsound . "/" . $value); if ($list !== false && count($list) > 2) { $arrLang[$value] = $value; } } } } } } else { return false; } return $arrLang; }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoValidar.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/misc.lib.php"; include_once "libs/paloSantoForm.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoExtensionsBatch.class.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']; $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 = new paloDB($dsnAsterisk); if (!empty($pDB->errMsg)) { $smarty->assign("mb_message", _tr('Error when connecting to database') . "<br/>" . $pDB->errMsg); } $pConfig = new paloConfig($arrAMP['ASTETCDIR']['valor'], "asterisk.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAST = $pConfig->leer_configuracion(false); $content = ""; $accion = getAction(); //Sirve para todos los casos $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("icon", "modules/{$module_name}/images/pbx_batch_of_extensions.png"); $smarty->assign("SAVE", _tr('Save')); $smarty->assign("DOWNLOAD", _tr("Download Extensions")); $smarty->assign("label_file", _tr("File")); $smarty->assign("title", _tr("Extensions Batch")); $smarty->assign("title_module", _tr("Batch of Extensions")); $smarty->assign("HeaderFile", _tr("Header File Extensions Batch")); $smarty->assign("AboutUpdate", _tr("About Update Extensions Batch")); $html_input = "<input class='button' type='submit' name='delete_all' value='" . _tr('Delete All Extensions') . "' onClick=\" return confirmSubmit('" . _tr("Are you really sure you want to delete all the extensions in this server?") . "');\" />"; $smarty->assign("DELETE_ALL", $html_input); switch ($accion) { case 'delete_all': delete_all_extention($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrAST, $arrAMP); $content = report_extension($smarty, $module_name, $local_templates_dir, $arrConf); break; case 'load_extension': $content = load_extension($smarty, $module_name, $local_templates_dir, $arrConf, $base_dir, $pDB, $arrAST, $arrAMP); break; case 'download_csv': download_extensions($pDB); break; default: $content = report_extension($smarty, $module_name, $local_templates_dir, $arrConf); break; } return $content; }
function leerDatosGrafico($type_graph, $date_start, $date_end) { global $arrConf; global $arrConfModule; global $arrLang; $MAX_SLICES = 10; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $pDBSQLite = new paloDB($arrConfModule['dsn_conn_database_2']); if (!empty($pDBSQLite->errMsg)) { echo "{$arrLang['ERROR']}: {$pDBSQLite->errMsg} <br>"; } $pRate = new paloRate($pDBSQLite); if (!empty($pRate->errMsg)) { echo "{$arrLang['ERROR']}: {$pRate->errMsg} <br>"; } $pDBSet = new paloDB($arrConf['elastix_dsn']['settings']); $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']); $oTrunk = new paloTrunk($pDBTrunk); $grupos = NULL; $troncales = $oTrunk->getExtendedTrunksBill($grupos, $arrConfig['ASTETCDIR']['valor'] . '/chan_dahdi.conf'); //ej array("DAHDI/1","DAHDI/2"); $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asteriskcdrdb"; $pDB = new paloDB($dsn); $oCDR = new paloSantoCDR($pDB); $arrCDR = $oCDR->obtenerCDRs("", 0, $date_start, $date_end, "", "", "ANSWERED", "outgoing", $troncales); $total = $arrCDR['NumRecords'][0]; $num_calls = array(); $minutos = array(); $val_charge = array(); $nombre_rate = array(); $title_sumary = NULL; if ($total > 0) { foreach ($arrCDR['Data'] as $cdr) { if (eregi("^DAHDI/([[:digit:]]+)", $cdr[4], $regs3)) { $trunk = 'DAHDI/g' . $grupos[$regs3[1]]; } else { $trunk = str_replace(strstr($cdr[4], '-'), '', $cdr[4]); } //tengo que buscar la tarifa para el numero de telefono $numero = $cdr[2]; $tarifa = array(); $rate_name = ""; $charge = 0; $bExito = $pRate->buscarTarifa($numero, $tarifa, $trunk); if (!count($tarifa) > 0 && $bExito) { $bExito = $pRate->buscarTarifa($numero, $tarifa, 'None'); } if (!$bExito) { echo "{$arrLang['ERROR']}: {$pRate->errMsg} <br>"; } else { //verificar si tiene tarifa if (count($tarifa) > 0) { foreach ($tarifa as $id_tarifa => $datos_tarifa) { $rate_name = $datos_tarifa['name']; $id_rate = $datos_tarifa['id']; $charge = $cdr[8] / 60 * $datos_tarifa['rate'] + $datos_tarifa['offset']; } } else { $rate_name = $arrLang["default"]; $id_rate = 0; //no tiene tarifa buscar tarifa por omision //por ahora para probar $1 el minuto $rate = get_key_settings($pDBSet, "default_rate"); $rate_offset = get_key_settings($pDBSet, "default_rate_offset"); $charge = $cdr[8] / 60 * $rate + $rate_offset; } $nombre_rate[$id_rate] = $rate_name; if (!isset($minutos[$id_rate])) { $minutos[$id_rate] = 0; } if (!isset($num_calls[$id_rate])) { $num_calls[$id_rate] = 0; } if (!isset($val_charge[$id_rate])) { $val_charge[$id_rate] = 0; } $minutos[$id_rate] += $cdr[8] / 60; $num_calls[$id_rate]++; $val_charge[$id_rate] += $charge; } } //ordenar los valores a mostrar arsort($num_calls); arsort($minutos); arsort($val_charge); //verificar que los valores no excedan el numero de slices del pie //numero de llamadas if (count($num_calls) > $MAX_SLICES) { $i = 1; foreach ($num_calls as $id_rate => $valor) { if ($i > $MAX_SLICES - 1) { if (!isset($valores_num_calls['otros'])) { $valores_num_calls['otros'] = 0; } $valores_num_calls['otros'] += $valor; } else { $valores_num_calls[$id_rate] = $valor; } $i++; } } else { $valores_num_calls = $num_calls; } //minutos if (count($minutos) > $MAX_SLICES) { $i = 1; foreach ($minutos as $id_rate => $valor) { if ($i > $MAX_SLICES - 1) { if (!isset($valores_minutos['otros'])) { $valores_minutos['otros'] = 0; } $valores_minutos['otros'] += $valor; } else { $valores_minutos[$id_rate] = $valor; } $i++; } } else { $valores_minutos = $minutos; } //charge if (count($val_charge) > $MAX_SLICES) { $i = 1; foreach ($val_charge as $id_rate => $valor) { if ($i > $MAX_SLICES - 1) { if (!isset($valores_charge['otros'])) { $valores_charge['otros'] = 0; } $valores_charge['otros'] += $valor; } else { $valores_charge[$id_rate] = $valor; } $i++; } } else { $valores_charge = $val_charge; } if ($type_graph == "minutes") { $titulo = $arrLang["Distribution by Time"]; $valores_grafico = $valores_minutos; $title_sumary = $arrLang["Minutes"]; } elseif ($type_graph == "charge") { $titulo = $arrLang["Distribution by Cost"]; $valores_grafico = $valores_charge; $title_sumary = $arrLang["Cost"]; } else { $titulo = $arrLang["Distribution by Number of Calls"]; $valores_grafico = $valores_num_calls; $title_sumary = $arrLang["Number of Calls"]; } //nombres de tarifas para leyenda foreach ($valores_grafico as $id => $valor) { $nombres_tarifas[] = isset($nombre_rate[$id]) ? $nombre_rate[$id] : $arrLang["others"]; } $data = array_values($valores_grafico); } else { if ($type_graph == "minutes") { $titulo = $arrLang["Distribution by Time"]; } elseif ($type_graph == "charge") { $titulo = $arrLang["Distribution by Cost"]; } else { $titulo = $arrLang["Distribution by Number of Calls"]; } $nombres_tarifas = $data = array(); } //formar la estructura a pasar al pie $data_graph = array("values" => $data, "legend" => $nombres_tarifas, "title" => $titulo, "title_sumary" => $title_sumary); return $data_graph; }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoConfig.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoExtention.class.php"; load_language_module($module_name); //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); //solo para obtener los devices (extensiones) creadas. $dsnAsteriskCdr = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asteriskcdrdb"; $pDB_cdr = new paloDB($dsnAsteriskCdr); //asteriskcdrdb -> CDR $dsnAsteriskDev = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB_ext = new paloDB($dsnAsteriskDev); //asterisk -> devices $accion = getAction(); $content = ""; switch ($accion) { case "show": $_POST['nav'] = null; $_POST['start'] = null; $content = report_Extention($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_ext); break; case 'grafic': $du = $_GET['du']; $totIn = $_GET['in']; $totOut = $_GET['out']; $tot = $_GET['tot']; $ext = $_GET['ext']; if (preg_match("/^[1-9]{1}[[:digit:]]*\$/", $ext)) { grafic($du, $totIn, $totOut, $tot, $ext); } else { $content = report_Extention($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_ext); } break; case 'grafic_queue': $queue = ""; //isset($_GET['queue'])?$_GET['queue']:"";//queue $dti = isset($_GET['dti']) ? $_GET['dti'] : ""; //fecha inicio $dtf = isset($_GET['dtf']) ? $_GET['dtf'] : ""; //fecha fin grafic_queue($pDB_cdr, $pDB_ext, $queue, $dti, $dtf); break; case 'grafic_trunk': $trunk = isset($_GET['trunk']) ? $_GET['trunk'] : ""; $dti = isset($_GET['dti']) ? $_GET['dti'] : ""; $dtf = isset($_GET['dtf']) ? $_GET['dtf'] : ""; grafic_trunk($pDB_cdr, $pDB_ext, $module_name, $trunk, $dti, $dtf); break; case 'grafic_trunk2': $trunk = isset($_GET['trunk']) ? $_GET['trunk'] : ""; $dti = isset($_GET['dti']) ? $_GET['dti'] : ""; $dtf = isset($_GET['dtf']) ? $_GET['dtf'] : ""; grafic_trunk2($pDB_cdr, $pDB_ext, $module_name, $trunk, $dti, $dtf); break; default: $content = report_Extention($smarty, $module_name, $local_templates_dir, $pDB_cdr, $pDB_ext); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoValidar.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/misc.lib.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoACL.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoAdressBook.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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); $smarty->assign('MODULE_NAME', $module_name); //folder path for custom templates $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn_agi_manager['password'] = $arrConfig['AMPMGRPASS']['valor']; $dsn_agi_manager['host'] = $arrConfig['AMPDBHOST']['valor']; $dsn_agi_manager['user'] = '******'; //solo para obtener los devices (extensiones) creadas. $dsnAsterisk = generarDSNSistema('asteriskuser', 'call_center'); $pDB = new paloDB($arrConf['dsn_conn_database']); // address_book $pDB_2 = new paloDB($arrConf['dsn_conn_database2']); // acl $pDB_customer = new paloDB($arrConf['cadena_dsn']); // address_book $action = getAction(); $content = ""; switch ($action) { case "new": $content = new_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; case "cancel": header("Location: ?menu={$module_name}"); break; case "commit": $content = save_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, true); break; case "edit": $content = view_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, true); break; case "show": $content = view_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; case "save": $content = save_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; case "delete": $content = deleteContact($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; case "call2phone": $content = call2phone($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; case "transfer_call": $content = transferCALL($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; default: $content = report_adress_book($smarty, $module_name, $local_templates_dir, $pDB_customer, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); break; } return $content; }
/** * Procedimiento para listar todos los grupos de troncales DAHDI que han sido * definidos. Este procedimiento requiere que Asterisk esté en ejecución en el * sistema y que soporte el comando "dahdi show channels group N". * * @return mixed Arreglo de la siguiente forma: * array(0 => array("DAHDI/1", "DAHDI/2", "DAHDI/3"), 1 => array("DAHDI/4", "DAHDI/5", "DAHDI/6")) */ function getTrunkGroupsDAHDI() { require_once '/var/lib/asterisk/agi-bin/phpagi-asmanager.php'; require_once 'libs/paloSantoConfig.class.php'; // Obtener las credenciales y abrir la conexión Asterisk $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $astman = new AGI_AsteriskManager(); if (!$astman->connect('localhost', $arrConfig['AMPMGRUSER']['valor'], $arrConfig['AMPMGRPASS']['valor'])) { // No se puede conectar a AMI, se intenta parsear configuración return $grupos = getTrunkGroupsDAHDI_config(); } else { /* Chan Extension Context Language MOH Interpret Blocked State 1 from-pstn default In Service 2 from-pstn default In Service 3 from-pstn default In Service 4 from-pstn default In Service */ // Se conoce que los números de grupo van de 0 a 63 $grupos = array(); $bSoportado = TRUE; // Se asume que el comando soporta listar por grupos for ($iGrupo = 0; $iGrupo < 64 && $bSoportado; $iGrupo++) { $r = $astman->Command("dahdi show channels group {$iGrupo}"); if (isset($r['data'])) { $lineas = explode("\n", $r['data']); foreach ($lineas as $sLinea) { /* Si una línea empieza con Usage, entonces la versión de Asterisk no soporta la extensión "group N" del comando "dahdi show channels" */ if (strpos($sLinea, 'Usage') === 0) { $bSoportado = FALSE; break; } if (preg_match('/^\\s+(\\d+)/', $sLinea, $regs)) { $grupos[$iGrupo][] = 'DAHDI/' . $regs[1]; } } } } $astman->disconnect(); if (!$bSoportado) { // Comando AMI no soportado, se intenta parsear configuración $grupos = getTrunkGroupsDAHDI_config(); } return $grupos; } }
function build_extensionsBatch($smarty) { require_once "libs/paloSantoConfig.class.php"; $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 = new paloDB($dsnAsterisk); if (!empty($pDB->errMsg)) { $smarty->assign("mb_message", _tr('Error when connecting to database') . "<br/>" . $pDB->errMsg); return NULL; } $pConfig = new paloConfig($arrAMP['ASTETCDIR']['valor'], "asterisk.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAST = $pConfig->leer_configuracion(false); return new paloSantoExtensionsBatch($pDB, $arrAST, $arrAMP); }
/** * Functional point that returns an array with the voicemail list for the extension of the authenticated user * * @param date $startdate lowest date which could be created the voicemail * @param date $enddate highest date which could be created the voicemail * @return array Array with the list of all voicemails in the specified range, or false if an error exists */ public function listVoicemail($startdate, $enddate) { if (!isset($startdate) || !isset($enddate)) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Required Parameter'; $this->errMsg["fd"] = "The Parameters 'startdate' and 'enddate' are required"; $this->errMsg["cn"] = get_class($this); return false; } $archivos = array(); $extension = $this->_leerExtension(); if (is_null($extension)) { return false; } $sFechaInicio = $this->_checkDateFormat(isset($startdate) ? $startdate : NULL); $sFechaFinal = $this->_checkDateFormat(isset($enddate) ? $enddate : NULL); if (is_null($sFechaInicio) || is_null($sFechaFinal)) { return false; } if ($sFechaFinal < $sFechaInicio) { $t = $sFechaFinal; $sFechaFinal = $sFechaInicio; $sFechaInicio = $t; } $path = "/var/spool/asterisk/voicemail/default"; $folder = "INBOX"; $directorios[] = $extension; $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($sFechaFinal) && strtotime("{$fecha} {$hora}") >= strtotime($sFechaInicio)) { $arrTmp["date"] = $fecha; $arrTmp["time"] = $hora; $arrTmp["callerid"] = $arrVoiceMailDes['callerid']['valor']; $arrTmp["extension"] = $arrVoiceMailDes['origmailbox']['valor']; $arrTmp["duration"] = $arrVoiceMailDes['duration']['valor'] . ' sec.'; $arrData[] = $arrTmp; } } } } closedir($handle); } } else { $this->errMsg["fc"] = 'ERROR'; $this->errMsg["fm"] = 'File does not exist'; $this->errMsg["fd"] = "The file {$voicemailPath} does not exist"; $this->errMsg["cn"] = get_class($this); return false; } } return array("totalVoicemail" => count($arrData), "voicemail" => $arrData); }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoCallsDetail.class.php"; include_once "modules/agent_console/getinfo.php"; global $arrConf; load_language_module($module_name); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConfig['templates_dir']) ? $arrConfig['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; // added by Tri Do $sAction = getParameter('action'); switch ($sAction) { case 'viewNote': return viewNote(); break; case 'viewDelivery': return view_delivery(); break; default: break; } // Cadenas estáticas de Smarty $smarty->assign(array("Filter" => _tr('Filter'), "SHOW" => _tr("Show"))); $bElastixNuevo = method_exists('paloSantoGrid', 'setURL'); // Variables iniciales para posición de grid $offset = 0; $limit = 50; $total = 0; // Para poder consultar las colas activas $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $ampconfig = $pConfig->leer_configuracion(false); $ampdsn = $ampconfig['AMPDBENGINE']['valor'] . "://" . $ampconfig['AMPDBUSER']['valor'] . ":" . $ampconfig['AMPDBPASS']['valor'] . "@" . $ampconfig['AMPDBHOST']['valor'] . "/asterisk"; $oQueue = new paloQueue($ampdsn); $listaColas = $oQueue->getQueue(); if (!is_array($listaColas)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oQueue->errMsg); } // Para poder consultar los agentes de campañas $pDB = new paloDB($cadena_dsn); $oCallsDetail = new paloSantoCallsDetail($pDB); $listaAgentes = $oCallsDetail->getAgents(); // Para llenar el select de agentes $urlVars = array('menu' => $module_name); $arrFormElements = createFieldFilter($listaAgentes, $listaColas); $oFilterForm = new paloForm($smarty, $arrFormElements); // Validar y aplicar las variables de filtro $paramLista = NULL; $paramFiltro = array(); foreach (array('date_start', 'date_end', 'calltype', 'agent', 'queue', 'phone') as $k) { $paramFiltro[$k] = getParameter($k); } if (!isset($paramFiltro['date_start'])) { $paramFiltro['date_start'] = date("d M Y"); } if (!isset($paramFiltro['date_end'])) { $paramFiltro['date_end'] = date("d M Y"); } if (!$oFilterForm->validateForm($paramFiltro)) { // Hay un error al validar las variables del filtro $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oFilterForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; $strErrorMsg = implode(', ', array_keys($arrErrores)); $smarty->assign("mb_message", $strErrorMsg); } else { $urlVars = array_merge($urlVars, $paramFiltro); $paramLista = $paramFiltro; $paramLista['date_start'] = translateDate($paramFiltro['date_start']) . " 00:00:00"; $paramLista['date_end'] = translateDate($paramFiltro['date_end']) . " 23:59:59"; } $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); // Inicio de objeto grilla y asignación de filtro $oGrid = new paloSantoGrid($smarty); $oGrid->enableExport(); // enable export. $oGrid->showFilter($htmlFilter); $bExportando = $bElastixNuevo ? $oGrid->isExportAction() : isset($_GET['exportcsv']) && $_GET['exportcsv'] == 'yes' || isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' || isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes'; // Ejecutar la consulta con las variables ya validadas $arrData = array(); $total = 0; if (is_array($paramLista)) { $total = $oCallsDetail->contarDetalleLlamadas($paramLista); if (is_null($total)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oCallsDetail->errMsg); $total = 0; } else { // Habilitar la exportación de todo el contenido consultado if ($bExportando) { $limit = $total; } // Calcular el offset de la petición de registros if ($bElastixNuevo) { $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); } else { // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "end") { // Mejorar el sgte. bloque. if ($total % $limit == 0) { $offset = $total - $limit; } else { $offset = $total - $total % $limit; } } // Si se quiere avanzar a la sgte. pagina if (isset($_GET['nav']) && $_GET['nav'] == "next") { $offset = $_GET['start'] + $limit - 1; } // Si se quiere retroceder if (isset($_GET['nav']) && $_GET['nav'] == "previous") { $offset = $_GET['start'] - $limit - 1; } } // Ejecutar la consulta de los datos en el offset indicado $recordset = $oCallsDetail->leerDetalleLlamadas($paramLista, $limit, $offset); // add STT for ($i = 0; $i < count($recordset); $i++) { $recordset[$i]['stt'] = $i + 1; } if (!is_array($recordset)) { $smarty->assign("mb_title", _tr("Error when connecting to database")); $smarty->assign("mb_message", $oCallsDetail->errMsg); $total = 0; } else { function _calls_detail_map_recordset($cdr) { $mapaEstados = array('abandonada' => 'Bỏ nhỡ', 'Abandoned' => 'Bỏ nhỡ', 'terminada' => 'Đã nghe', 'Success' => 'Đã nghe', 'fin-monitoreo' => _tr('End Monitor'), 'Failure' => _tr('Failure'), 'NoAnswer' => _tr('NoAnswer'), 'OnQueue' => _tr('OnQueue'), 'Placing' => _tr('Placing'), 'Ringing' => _tr('Ringing'), 'ShortCall' => _tr('ShortCall'), 'activa' => 'Đang gọi'); return array($cdr['stt'], $cdr[0], htmlentities($cdr[1], ENT_COMPAT, "UTF-8"), substr($cdr[2], 0, 10), substr($cdr[2], 11, 8), substr($cdr[3], 0, 10), substr($cdr[3], 11, 8), is_null($cdr[4]) ? '-' : formatoSegundos($cdr[4]), is_null($cdr[5]) ? '-' : formatoSegundos($cdr[5]), $cdr[6], $cdr[8], $cdr[9], isset($mapaEstados[$cdr[10]]) ? $mapaEstados[$cdr[10]] : _tr($cdr[10]), is_null($cdr[12]) || trim($cdr[12] == '') ? '' : '<a href="javascript:void(0)" onclick="view_note(\'' . $cdr[11] . '\')">Xem</a>'); } $arrData = array_map('_calls_detail_map_recordset', $recordset); } } } $arrColumnas = array('STT', 'Số Agent', 'Nhân viên', _tr("Start Date"), _tr("Start Time"), _tr("End Date"), _tr("End Time"), "Thời lượng", _tr("Thời gian chờ"), _tr("Queue"), _tr("Số điện thoại"), _tr("Chuyển máy"), _tr("Status"), 'Nội dung'); if ($bElastixNuevo) { $oGrid->setURL(construirURL($urlVars, array("nav", "start"))); $oGrid->setData($arrData); $oGrid->setColumns($arrColumnas); $oGrid->setTitle('Chi tiết cuộc gọi Call Center'); $oGrid->pagingShow(true); $oGrid->setNameFile_Export(_tr("Calls Detail")); return $oGrid->fetchGrid(); } else { global $arrLang; $url = construirURL($urlVars, array("nav", "start")); function _map_name($s) { return array('name' => $s); } $arrGrid = array("title" => _tr("Calls Detail"), "url" => $url, "icon" => "images/user.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $offset + $limit <= $total ? $offset + $limit : $total, "total" => $total, "columns" => array_map('_map_name', $arrColumnas)); if (isset($_GET['exportpdf']) && $_GET['exportpdf'] == 'yes' && method_exists($oGrid, 'fetchGridPDF')) { return $oGrid->fetchGridPDF($arrGrid, $arrData); } if (isset($_GET['exportspreadsheet']) && $_GET['exportspreadsheet'] == 'yes' && method_exists($oGrid, 'fetchGridXLS')) { return $oGrid->fetchGridXLS($arrGrid, $arrData); } if ($bExportando) { header("Cache-Control: private"); header("Pragma: cache"); // Se requiere para HTTPS bajo IE6 header('Content-disposition: inline; filename="calls_detail.csv"'); header("Content-Type: text/csv; charset=UTF-8"); } if ($bExportando) { return $oGrid->fetchGridCSV($arrGrid, $arrData); } $sContenido = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($sContenido, '<form') === FALSE) { $sContenido = "<form method=\"POST\" style=\"margin-bottom:0;\" action=\"{$url}\">{$sContenido}</form>"; } return $sContenido; } }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/endpoint_configurator/libs/paloSantoEndPoint.class.php"; include_once "modules/endpoint_configurator/libs/paloSantoFileEndPoint.class.php"; include_once "modules/{$module_name}/libs/paloSantoEndPointDownload.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $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']; //conexion resource $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']; $dsnSqlite = $arrConf['dsn_conn_database']; //Sirve para todos los casos $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("label_file", _tr("File")); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("HeaderFile", _tr("Header File Batch Endpoint")); $smarty->assign("DOWNLOAD", _tr("Download Endpoints")); $smarty->assign("AboutUpdate", _tr("About Update Batch Endpoint")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("label_endpoint", _tr("Discover Endpoints in this Network")); $smarty->assign("title", _tr("Endpoint Batch")); $smarty->assign("title_module", _tr("Endpoint Batch")); //actions $action = getAction(); $content = ""; switch ($action) { case "load_endpoint": $content = load_endpoint($smarty, $module_name, $local_templates_dir, $arrLang, $arrConf, $base_dir, $dsnAsterisk, $dsnSqlite); break; case "download_csv": download_endpoints($dsnAsterisk, $dsnSqlite); break; default: // view_form $content = viewFormBatchofEndpoint($smarty, $module_name, $local_templates_dir, $arrConf); break; } return $content; }
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 _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoValidar.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoJSON.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/misc.lib.php"; include_once "libs/paloSantoNetwork.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoEndPoint.class.php"; include_once "modules/{$module_name}/libs/paloSantoFileEndPoint.class.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']; $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']; $dsnSqlite = $arrConfModule['dsn_conn_database_1']; $accion = getAction(); $content = ""; // Asegurarse de que el arreglo siempre exista, aunque esté vacío if (!isset($_SESSION['elastix_endpoints'])) { $_SESSION['elastix_endpoints'] = array(); } switch ($accion) { case "endpoint_scan": $content = endpointScan($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "endpoint_set": $content = endpointConfiguratedSet($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "endpoint_unset": $content = endpointConfiguratedUnset($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "getDevices": $content = getDevices($dsnAsterisk, $dsnSqlite); break; case "patton_data": $content = getPattonData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "vega_data": $content = getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "next_1": $content = getExtensionsForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_1_vega": $content = getExtensionsVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_2": $content = getLinesForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_2_vega": $content = getLinesVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "save": $content = savePatton($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "save_vega": $content = saveVega($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "return2": $content = getExtensionsForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true); break; case "return2_vega": $content = getExtensionsVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true); break; default: // endpoint_show $content = buildReport($_SESSION['elastix_endpoints'], $smarty, $module_name, network()); break; } return $content; }