function applyChnageParameterFaxMail($smarty, $module_name, $local_templates_dir, $pDB, $credentials) { $arrFaxConfig = createForm(); $oForm = new paloForm($smarty, $arrFaxConfig); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $smarty->assign("mb_title", _tr("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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); } else { $oFax = new paloFax($pDB); if ($oFax->setConfigurationSendingFaxMailOrg($credentials['id_organization'], $_POST['fax_remite'], $_POST['fax_remitente'], $_POST['fax_subject'], $_POST['fax_content'])) { $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Changes were applied successfully.")); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Changes could not be applied.") . " " . $oFax->errMsg); } } return listParameterFaxMail($smarty, $module_name, $local_templates_dir, $pDB, $credentials); }
function generateWav($smarty, $module_name, $local_templates_dir) { $arrFormConference = createFieldForm(); $oForm = new paloForm($smarty, $arrFormConference); if (!$oForm->validateForm($_POST)) { $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = form_TexttoWav($smarty, $module_name, $local_templates_dir); } else { $smarty->assign("GENERATE", _tr("Generate")); $smarty->assign("BACK", _tr("Back")); $smarty->assign("icon", "web/apps/{$module_name}/images/pbx_tools_text_to_wav.png"); $smarty->assign("FORMATO", getParameter('format')); $smarty->assign("DOWNLOAD", _tr("Download File")); $path = "var"; $smarty->assign("PATH", $path); $format = getParameter('format'); $message = stripslashes(trim(getParameter('message'))); $message = substr($message, 0, 1024); $oTextToWap = new paloSantoTexttoWav(); $execute = $oTextToWap->outputTextWave($format, $message); if ($execute) { /* Cortar la salida en este lugar. Evita lidiar con rawmode sólo * para caso de éxito */ die; } else { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $oTextToWap->errMsg); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Text to Wav"), $_POST); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; } return $contenidoModulo; }
function formularioModificarCola($pDB, $smarty, $module_name, $local_templates_dir, $idCola) { require_once "libs/paloSantoForm.class.php"; require_once "libs/paloSantoQueue.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(array('FRAMEWORK_TIENE_TITULO_MODULO' => existeSoporteTituloFramework(), 'icon' => 'images/kfaxview.png', 'SAVE' => _tr('guardar'), 'CANCEL' => _tr('cancelar'), 'id_queue' => $idCola)); // Leer todas las colas disponibles $dsnAsterisk = generarDSNSistema('asteriskuser', 'asterisk'); $oDBAsterisk = new paloDB($dsnAsterisk); $oQueue = new paloQueue($oDBAsterisk); $arrQueues = $oQueue->getQueue(); if (!is_array($arrQueues)) { $smarty->assign("mb_title", _tr('Unable to read queues')); $smarty->assign("mb_message", _tr('Cannot read queues') . ' - ' . $oQueue->errMsg); $arrQueues = array(); } $oColas = new paloSantoColaEntrante($pDB); // Leer todos los datos de la cola entrante, si es necesario $arrColaEntrante = NULL; if (!is_null($idCola)) { $arrColaEntrante = $oColas->leerColas($idCola); if (!is_array($arrColaEntrante) || count($arrColaEntrante) == 0) { $smarty->assign("mb_title", _tr('Unable to read incoming queue')); $smarty->assign("mb_message", _tr('Cannot read incoming queue') . ' - ' . $oColas->errMsg); return ''; } } /* Para nueva cola, se deben remover las colas ya usadas. Para cola * modificada, sólo se muestra la cola que ya estaba asignada. */ if (is_null($idCola)) { // Filtrar las colas que ya han sido usadas $arrFilterQueues = $oColas->filtrarColasUsadas($arrQueues); } else { // Colocar sólo la información de la cola asignada $arrFilterQueues = array(); foreach ($arrQueues as $tuplaQueue) { if ($tuplaQueue[0] == $arrColaEntrante[0]['queue']) { $arrFilterQueues[] = $tuplaQueue; } } } $arrDataQueues = array(); foreach ($arrFilterQueues as $tuplaQueue) { $arrDataQueues[$tuplaQueue[0]] = $tuplaQueue[1]; } // Valores por omisión para primera carga if (is_null($idCola)) { if (!isset($_POST['select_queue']) && count($arrFilterQueues) > 0) { $_POST['select_queue'] = $arrFilterQueues[0][0]; } if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = ''; } } else { $_POST['select_queue'] = $arrColaEntrante[0]['queue']; if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = $arrColaEntrante[0]['script']; } } // rte_script es un HTML complejo que debe de construirse con Javascript. $smarty->assign("rte_script", adaptar_formato_rte($_POST['rte_script'])); // Generación del objeto de formulario $form_campos = array("script" => array("LABEL" => _tr('Script'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "", "VALIDATION_EXTRA_PARAM" => ""), 'select_queue' => array("REQUIRED" => "yes", "LABEL" => is_null($idCola) ? _tr('Select Queue') . ' :' : _tr('Queue'), "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrDataQueues, "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $form_campos); // Ejecutar el guardado de los cambios if (isset($_POST['save'])) { 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); } else { $bExito = $oColas->iniciarMonitoreoCola($_POST['select_queue'], $_POST['rte_script']); if (!$bExito) { $smarty->assign("mb_title", _tr('Unable to save incoming queue')); $smarty->assign("mb_message", $oColas->errMsg); } else { Header("Location: ?menu={$module_name}"); } } } return $oForm->fetchForm("{$local_templates_dir}/form.tpl", is_null($idCola) ? _tr('Select Queue') : _tr('Edit Queue'), null); }
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 saveNewOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $success = false; $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); $arrFormOrgz = createFieldForm(); $oForm = new paloForm($smarty, $arrFormOrgz); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["description"] = getParameter("description"); $arrProp["destdial"] = getParameter("destdial"); $pDB->beginTransaction(); $success = $pOtherDestinations->createNewOtherDestinations($arrProp); if ($success) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pOtherDestinations->errMsg; } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Other Destination has been created successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); $content = reportOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function deleteEliminacióndebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEliminacióndebases = new paloSantoEliminacióndebases($pDB); $arrFormEliminacióndebases = createFieldForm($pEliminacióndebases); $oForm = new paloForm($smarty, $arrFormEliminacióndebases); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormEliminacióndebases($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { $pEliminacióndebases->eliminarBase($_POST['base_de_clientes']); Header("Location: index.php?menu=hispana_base_lista"); } return $content; }
function saveNewGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $group = getParameter("group"); $description = getParameter("description"); $idOrgzSel = getParameter("organization"); if ($userLevel1 != "superadmin") { $idOrgzSel = $idOrganization; } $arrFormGroup = createFieldForm(array()); $oForm = new paloForm($smarty, $arrFormGroup); if (isset($idOrgzSel)) { if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($idOrgzSel == 0 || $idOrgzSel == 1) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("You must select a organization")); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($pACL->createGroup($group, $description, $idOrgzSel)) { $smarty->assign("mb_title", _tr("MESSSAGE")); $smarty->assign("mb_message", _tr("Group was created sucessfully")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } } } } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("You must select a organization")); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } }
function _moduleContent(&$smarty, $module_name) { require_once "modules/{$module_name}/libs/ringgroup.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; load_language_module($module_name); 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']; // DSN para consulta de cdrs $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb'); $pDB = new paloDB($dsn); $oCDR = new paloSantoCDR($pDB); $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']); if (!empty($pDBACL->errMsg)) { return "ERROR DE DB: {$pDBACL->errMsg}"; } $pACL = new paloACL($pDBACL); if (!empty($pACL->errMsg)) { return "ERROR DE ACL: {$pACL->errMsg}"; } $exten = '6868'; //$pACL->getUserExtension($_SESSION['elastix_user']); $isAdministrator = true; //$pACL->isUserAdministratorGroup($_SESSION['elastix_user']); if (is_null($exten) || $exten == "") { if (!$isAdministrator) { $smarty->assign('mb_message', "<b>" . _tr("contact_admin") . "</b>"); return ""; } else { $smarty->assign('mb_message', "<b>" . _tr("no_extension") . "</b>"); } } // Para usuarios que no son administradores, se restringe a los CDR de la // propia extensión $sExtension = $isAdministrator ? '' : $pACL->getUserExtension($_SESSION['elastix_user']); // DSN para consulta de ringgroups $dsn_asterisk = generarDSNSistema('asteriskuser', 'asterisk'); $pDB_asterisk = new paloDB($dsn_asterisk); $oRG = new RingGroup($pDB_asterisk); $dataRG = $oRG->getRingGroup(); $dataRG[''] = _tr('(Any ringgroup)'); // Cadenas estáticas en la plantilla $smarty->assign(array("Filter" => _tr("Filter"))); $arrFormElements = array("date_start" => array("LABEL" => _tr("Start Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "date_end" => array("LABEL" => _tr("End Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "field_name" => array("LABEL" => _tr("Field Name"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("dst" => _tr("Destination"), "src" => _tr("Source"), "channel" => _tr("Src. Channel"), "accountcode" => _tr("Account Code"), "dstchannel" => _tr("Dst. Channel")), "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)\$"), "field_pattern" => array("LABEL" => _tr("Field"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[\\*|[:alnum:]@_\\.,/\\-]+\$"), "status" => array("LABEL" => _tr("Status"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("ALL" => _tr("ALL"), "ANSWERED" => _tr("ANSWERED"), "BUSY" => _tr("BUSY"), "FAILED" => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "ringgroup" => array("LABEL" => _tr("Ring Group"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $dataRG, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oFilterForm = new paloForm($smarty, $arrFormElements); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'dst', 'field_pattern' => '', 'status' => 'ALL', 'ringgroup' => ''); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); if ($paramFiltro['date_start'] === "") { $paramFiltro['date_start'] = " "; } if ($paramFiltro['date_end'] === "") { $paramFiltro['date_end'] = " "; } $valueFieldName = $arrFormElements['field_name']["INPUT_EXTRA_PARAM"][$paramFiltro['field_name']]; $valueStatus = $arrFormElements['status']["INPUT_EXTRA_PARAM"][$paramFiltro['status']]; $valueRingGRoup = $arrFormElements['ringgroup']["INPUT_EXTRA_PARAM"][$paramFiltro['ringgroup']]; $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); $oGrid->addFilterControl(_tr("Filter applied: ") . $valueFieldName . " = " . $paramFiltro['field_pattern'], $paramFiltro, array('field_name' => "dst", 'field_pattern' => "")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Status") . " = " . $valueStatus, $paramFiltro, array('status' => 'ALL'), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Ring Group") . " = " . $valueRingGRoup, $paramFiltro, array('ringgroup' => '')); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); if (!$oFilterForm->validateForm($paramFiltro)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $paramFiltro = $paramFiltroBase; unset($_POST['delete']); // Se aborta el intento de borrar CDRs, si había uno. } // Tradudir fechas a formato ISO para comparación y para API de CDRs. $url = array_merge($url, $paramFiltro); $paramFiltro['date_start'] = translateDate($paramFiltro['date_start']) . ' 00:00:00'; $paramFiltro['date_end'] = translateDate($paramFiltro['date_end']) . ' 23:59:59'; // Valores de filtrado que no se seleccionan mediante filtro if ($sExtension != '') { $paramFiltro['extension'] = $sExtension; } // Ejecutar el borrado, si se ha validado. if (isset($_POST['delete'])) { if ($isAdministrator) { if ($paramFiltro['date_start'] <= $paramFiltro['date_end']) { $r = $oCDR->borrarCDRs($paramFiltro); if (!$r) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } else { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Please End Date must be greater than Start Date"))); } } else { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Only administrators can delete CDRs"))); } } $oGrid->setTitle(_tr("CDR Report")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("CDRReport")); $oGrid->setURL($url); //if($isAdministrator) //$oGrid->deleteList("Are you sure you wish to delete CDR(s) Report(s)?","delete",_tr("Delete")); $arrData = null; if (!isset($sExtension) || $sExtension == "" && !$isAdministrator) { $total = 0; } else { $total = $oCDR->contarCDRs($paramFiltro); } if ($oGrid->isExportAction()) { $limit = $total; $offset = 0; $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration")); $oGrid->setColumns($arrColumns); $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset); if (is_array($arrResult['cdrs']) && $total > 0) { foreach ($arrResult['cdrs'] as $key => $value) { $arrTmp[0] = date("d-m-Y H:i:s", strtotime($value[0])); $arrTmp[1] = $value[1]; $arrTmp[2] = $value[11]; $arrTmp[3] = $value[3]; $arrTmp[4] = $value[9]; $arrTmp[5] = $value[5]; $iDuracion = $value[8]; $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[6]}s"; if ($value[6] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[7] = $sTiempo; $arrData[] = $arrTmp; } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset); $arrColumns = array('STT', _tr("Date"), _tr("Source"), _tr("Destination"), _tr("Src. Channel"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration")); $oGrid->setColumns($arrColumns); if (is_array($arrResult['cdrs']) && $total > 0) { $index = 0; foreach ($arrResult['cdrs'] as $key => $value) { $arrTmp[0] = $index; $arrTmp[1] = date("d-m-Y H:i:s", strtotime($value[0])); $arrTmp[2] = $value[1]; $arrTmp[3] = $value[2]; $arrTmp[4] = channel_lookup($pDB_asterisk, $value[3]); $arrTmp[5] = channel_lookup($pDB_asterisk, $value[4]); $arrTmp[6] = $value[5]; $iDuracion = $value[8]; $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[8]}s"; if ($value[7] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[7] = $sTiempo; $arrData[] = $arrTmp; $index++; } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg)); } } $oGrid->setData($arrData); $smarty->assign("SHOW", _tr("Show")); $oGrid->showFilter($htmlFilter); $content = $oGrid->fetchGrid(); return $content; }
function saveRules($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $arrValues = array(); $str_error = ""; $arrFormNew = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormNew); $id = getParameter("id"); $arrValues['id'] = $id; if ($id == "") { $state = "new"; } else { $state = "edit"; } //************************************************************************************************************ //** TRAFFIC ** //************************************************************************************************************ $arrValues['traffic'] = getParameter("id_traffic"); if ($arrValues['traffic'] == "INPUT") { $arrValues['interface_in'] = getParameter("interface_in"); if (strlen($arrValues['interface_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_in" : ", interface_in"; } $arrValues['interface_out'] = null; } else { if ($arrValues['traffic'] == "OUTPUT") { $arrValues['interface_out'] = getParameter("interface_out"); if (strlen($arrValues['interface_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_out" : ", interface_out"; } $arrValues['interface_in'] = null; } else { if ($arrValues['traffic'] == "FORWARD") { $arrValues['interface_in'] = getParameter("interface_in"); if (strlen($arrValues['interface_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_in" : ", interface_in"; } $arrValues['interface_out'] = getParameter("interface_out"); if (strlen($arrValues['interface_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_out" : ", interface_out"; } } } } //************************************************************************************************************ //** SOURCE ** //************************************************************************************************************ $arrValues['ip_source'] = getParameter("ip_source"); $arrValues['mask_source'] = getParameter("mask_source"); $arrValues['ip_destin'] = getParameter("ip_destin"); $arrValues['mask_destin'] = getParameter("mask_destin"); //************************************************************************************************************ //** PROTOCOL ** //************************************************************************************************************ $arrValues['protocol'] = getParameter("id_protocol"); if ($arrValues['protocol'] == 'TCP' || $arrValues['protocol'] == 'UDP') { $arrValues['port_in'] = getParameter("port_in"); if (strlen($arrValues['port_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "port_in" : ", port_in"; } $arrValues['port_out'] = getParameter("port_out"); if (strlen($arrValues['port_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "port_out" : ", port_out"; } $arrValues['type_icmp'] = null; $arrValues['id_ip'] = null; $arrValues['state'] = ""; } else { if ($arrValues['protocol'] == 'ICMP') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['state'] = ""; $arrValues['type_icmp'] = getParameter("type_icmp"); if (strlen($arrValues['type_icmp']) == 0) { $str_error .= strlen($str_error) == 0 ? "type" : ", type"; } $arrValues['id_ip'] = null; } else { if ($arrValues['protocol'] == 'IP') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['type_icmp'] = null; $arrValues['state'] = ""; $arrValues['id_ip'] = getParameter("id_ip"); if (strlen($arrValues['id_ip']) == 0) { $str_error .= strlen($str_error) == 0 ? "id" : ", id"; } } else { if ($arrValues['protocol'] == 'STATE') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['type_icmp'] = null; $arrValues['id_ip'] = null; $established = getParameter("established"); $related = getParameter("related"); if ($established == "on") { $arrValues['state'] = "Established"; if ($related == "on") { $arrValues['state'] .= ",Related"; } } else { if ($related == "on") { $arrValues['state'] = "Related"; } else { $str_error .= strlen($str_error) == 0 ? _tr("You have to select at least one state") : ", " . _tr("You have to select at least one state"); } } } else { $arrValues['port_in'] = ""; $arrValues['port_out'] = ""; $arrValues['type_icmp'] = ""; $arrValues['id_ip'] = ""; $arrValues['state'] = ""; } } } } //************************************************************************************************************ //** TARGET ** //************************************************************************************************************ $arrValues['target'] = getParameter("target"); if (strlen($arrValues['target']) == 0) { $str_error .= strlen($str_error) == 0 ? "target" : ", target"; } $arrValues['orden'] = getParameter("orden"); //********************** //MENSSAGE ERROR //********************** if (strlen($str_error) != 0) { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $str_error); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } else { if ($arrValues['mask_source'] > 32 || $arrValues['mask_destin'] > 32) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The bit masks must be values less than 33")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } else { if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['ip_source'] != "" && $arrValues['mask_source'] == "0" || $arrValues['ip_destin'] != "0.0.0.0" && $arrValues['ip_destin'] != "" && $arrValues['mask_destin'] == "0") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Wrong Mask")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } } $arrValues['ip_source'] = $arrValues['ip_source'] == "" ? "0.0.0.0" : $arrValues['ip_source']; $arrValues['ip_destin'] = $arrValues['ip_destin'] == "" ? "0.0.0.0" : $arrValues['ip_destin']; $ipOrigen = explode(".", $arrValues['ip_source']); $ipDestino = explode(".", $arrValues['ip_destin']); if ($ipOrigen[0] > 255 || $ipOrigen[1] > 255 || $ipOrigen[2] > 255 || $ipOrigen[3] > 255 || $ipDestino[0] > 255 || $ipDestino[1] > 255 || $ipDestino[2] > 255 || $ipDestino[3] > 255) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Wrong value for ip")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } $arrValues['mask_source'] = $arrValues['ip_source'] == "0.0.0.0" ? "0" : $arrValues['mask_source']; $arrValues['mask_destin'] = $arrValues['ip_destin'] == "0.0.0.0" ? "0" : $arrValues['mask_destin']; $pNet = new paloNetwork(); $oPalo = new paloSantoRules($pDB); if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['mask_source'] != "" && $arrValues['ip_source'] != "") { $arrValues['ip_source'] = $pNet->getNetAdress($arrValues['ip_source'], $arrValues['mask_source']); } if ($arrValues['ip_destin'] != "0.0.0.0" && $arrValues['mask_destin'] != "" && $arrValues['ip_destin'] != "") { $arrValues['ip_destin'] = $pNet->getNetAdress($arrValues['ip_destin'], $arrValues['mask_destin']); } if ($id == "") { if ($oPalo->saveRule($arrValues) == true) { $smarty->assign("mb_title", "MESSAGE"); $smarty->assign("mb_message", _tr("Successful Save")); } else { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $oPalo->errMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } else { if ($oPalo->updateRule($arrValues, $id) == true) { $smarty->assign("mb_title", "MESSAGE"); $smarty->assign("mb_message", _tr("Successful Update")); } else { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $oPalo->errMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } return reportRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function mostrarFormularioModificarBreak(&$smarty, $module_name, $pDB, $local_templates_dir, $id_break) { $bNuevoBreak = is_null($id_break); $smarty->assign(array('SAVE' => $bNuevoBreak ? _tr('Save') : _tr('Apply Changes'))); if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); // Para modificación, se lee la información del break $oBreaks = new PaloSantoBreaks($pDB); if (!$bNuevoBreak) { $_POST['id_break'] = $id_break; $infoBreak = $oBreaks->getBreaks($id_break); if (!is_array($infoBreak)) { // No se puede recuperar información actual del break $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pDB->errMsg); } elseif (count($infoBreak) <= 0) { // El break no se encuentra Header("Location: ?menu={$module_name}"); return ''; } else { // Se asignan los valores a POST a menos que ya se encuentren valores if (!isset($_POST['nombre'])) { $_POST['nombre'] = $infoBreak[0]['name']; } if (!isset($_POST['descripcion'])) { $_POST['descripcion'] = $infoBreak[0]['description']; } } } $formCampos = array("nombre" => array("LABEL" => _tr("Name Break"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("size" => "40"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "descripcion" => array("LABEL" => _tr("Description Break"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "ROWS" => "2", "COLS" => "33"), 'id_break' => array('LABEL' => 'id_break', 'REQUIRED' => 'no', 'INPUT_TYPE' => 'HIDDEN', "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]+\$")); $oForm = new paloForm($smarty, $formCampos); $oForm->setEditMode(); // Procesar los cambios realizados if (isset($_POST['save'])) { if (!$oForm->validateForm($_POST)) { $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) { $strErrorMsg .= implode(', ', array_keys($arrErrores)); } $smarty->assign("mb_message", $strErrorMsg); } else { $exito = $bNuevoBreak ? $oBreaks->createBreak($_POST['nombre'], $_POST['descripcion']) : $oBreaks->updateBreak($id_break, $_POST['nombre'], $_POST['descripcion']); if ($exito) { header("Location: ?menu={$module_name}"); } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $oBreak->errMsg); } } } // Mostrar el formulario con los valores $smarty->assign('icon', 'images/kfaxview.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $bNuevoBreak ? _tr('New Break') : _tr('Edit Break'), $_POST); return $contenidoModulo; }
function saveDomain($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang) { $pEmail = new paloEmail($pDB); $arrFormElements = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST); } else { $pDB->beginTransaction(); $bExito = create_email_domain($pDB, $error); if (!$bExito) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $error); $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST); } else { $pDB->commit(); $smarty->assign("mb_message", _tr("Domain has been created")); $content = viewFormDomain($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang); } } return $content; }
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; }
function reportMissedCalls($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $pACL, $arrConf) { ini_set('max_execution_time', 3600); $pCallingReport = new paloSantoMissedCalls($pDB); $oFilterForm = new paloForm($smarty, createFieldFilter()); $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); $date_start = getParameter("date_start"); $date_end = getParameter("date_end"); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Missed Calls")); $oGrid->pagingShow(true); // show paging section. $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("Missed Calls")); $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value); $date_start = isset($date_start) ? $date_start : date("d M Y") . ' 00:00'; $date_end = isset($date_end) ? $date_end : date("d M Y") . ' 23:59'; $_POST['date_start'] = $date_start; $_POST['date_end'] = $date_end; $parmFilter = array("date_start" => $date_start, "date_end" => $date_end); if (!$oFilterForm->validateForm($parmFilter)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $date_start = date("d M Y") . ' 00:00'; $date_end = date("d M Y") . ' 23:59'; } $url = array_merge($url, array('date_start' => $date_start, 'date_end' => $date_end)); $oGrid->setURL($url); $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Destination"), _tr("Time since last call"), _tr("Number of attempts"), _tr("Status")); $oGrid->setColumns($arrColumns); $arrData = null; $date_start_format = date('Y-m-d H:i:s', strtotime($date_start . ":00")); $date_end_format = date('Y-m-d H:i:s', strtotime($date_end . ":59")); // Para usuarios que no son administradores, se restringe a los CDR de la // propia extensión $sExtension = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']) ? '' : $pACL->getUserExtension($_SESSION['elastix_user']); $total = $pCallingReport->getNumCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); if ($oGrid->isExportAction()) { $limit = $total; // max number of rows. $offset = 0; // since the start. $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); $arrData = $pCallingReport->showDataReport($arrResult, $total); $size = count($arrData); $oGrid->setData($arrData); } else { $limit = 20; $oGrid->setLimit($limit); $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension); $arrData = $pCallingReport->showDataReport($arrResult, $total); if ($pCallingReport->errMsg != '') { $smarty->assign('mb_message', $pCallingReport->errMsg); } //recalculando el total para la paginación $size = count($arrData); $oGrid->setTotal($size); $offset = $oGrid->calculateOffset(); //echo $size." : ".$offset; $arrResult = $pCallingReport->getDataByPagination($arrData, $limit, $offset); $oGrid->setData($arrResult); } //begin section filter $smarty->assign("SHOW", _tr("Show")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); //end grid parameters return $content; }
function formEditAgent($pDB, $smarty, $module_name, $local_templates_dir, $id_agent) { // 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 $arrAgente = NULL; $oAgentes = new Agentes($pDB); if (!is_null($id_agent)) { $arrAgente = $oAgentes->getAgents($id_agent); if (!is_array($arrAgente) || count($arrAgente) == 0) { $smarty->assign("mb_title", 'Unable to read agent'); $smarty->assign("mb_message", 'Cannot read agent - ' . $oAgentes->errMsg); return ''; } } require_once "libs/paloSantoForm.class.php"; $arrFormElements = getFormAgent($smarty, !is_null($id_agent)); // Valores por omisión para primera carga if (is_null($id_agent)) { // Creación de nuevo agente if (!isset($_POST['extension'])) { $_POST['extension'] = ''; } if (!isset($_POST['description'])) { $_POST['description'] = ''; } if (!isset($_POST['password1'])) { $_POST['password1'] = ''; } if (!isset($_POST['password2'])) { $_POST['password2'] = ''; } if (!isset($_POST['eccpwd1'])) { $_POST['eccpwd1'] = ''; } if (!isset($_POST['eccpwd2'])) { $_POST['eccpwd2'] = ''; } } else { // Modificación de agente existente if (!isset($_POST['extension'])) { $_POST['extension'] = $arrAgente['number']; } if (!isset($_POST['description'])) { $_POST['description'] = $arrAgente['name']; } if (!isset($_POST['password1'])) { $_POST['password1'] = $arrAgente['password']; } if (!isset($_POST['password2'])) { $_POST['password2'] = $arrAgente['password']; } if (!isset($_POST['eccpwd1'])) { $_POST['eccpwd1'] = $arrAgente['eccp_password']; } if (!isset($_POST['eccpwd2'])) { $_POST['eccpwd2'] = $arrAgente['eccp_password']; } // Volver opcional el cambio de clave de acceso $arrFormElements['password1']['REQUIRED'] = 'no'; $arrFormElements['password2']['REQUIRED'] = 'no'; } $oForm = new paloForm($smarty, $arrFormElements); if (!is_null($id_agent)) { $oForm->setEditMode(); $smarty->assign("id_agent", $id_agent); } $bDoCreate = isset($_POST['submit_save_agent']); $bDoUpdate = isset($_POST['submit_apply_changes']); if ($bDoCreate || $bDoUpdate) { if (!$oForm->validateForm($_POST)) { // 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>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } else { foreach (array('extension', 'password1', 'password2', 'description', 'eccpwd1', 'eccpwd2') as $k) { $_POST[$k] = trim($_POST[$k]); } if ($_POST['password1'] != $_POST['password2'] || $bDoCreate && $_POST['password1'] == '') { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The passwords are empty or don't match")); } elseif ($_POST['eccpwd1'] != $_POST['eccpwd2']) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("ECCP passwords don't match")); } elseif (!ereg('^[[:digit:]]+$', $_POST['password1'])) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The passwords aren't numeric values")); } elseif (!ereg('^[[:digit:]]+$', $_POST['extension'])) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Error Agent Number")); } else { $bExito = TRUE; if ($bDoUpdate && $_POST['password1'] == '') { $_POST['password1'] = $arrAgente['password']; } $agente = array(0 => $_POST['extension'], 1 => $_POST['password1'], 2 => $_POST['description'], 3 => $_POST['eccpwd1']); if ($bDoCreate) { $bExito = $oAgentes->addAgent($agente); if (!$bExito) { $smarty->assign("mb_message", "" . _tr("Error Insert Agent") . " " . $oAgentes->errMsg); } } elseif ($bDoUpdate) { $bExito = $oAgentes->editAgent($agente); if (!$bExito) { $smarty->assign("mb_message", "" . _tr("Error Update Agent") . " " . $oAgentes->errMsg); } } if ($bExito) { header("Location: ?menu={$module_name}"); } } } } $smarty->assign('icon', 'images/user.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_agent) ? _tr("New agent") : _tr('Edit agent') . ' "' . $_POST['description'] . '"', $_POST); return $contenidoModulo; }
function formEditURL($pDB, $smarty, $module_name, $local_templates_dir, $id_url) { // 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()); $urls = new externalUrl($pDB); $tuplaURL = NULL; if (!is_null($id_url)) { $tuplaURL = $urls->getURL($id_url); if (!is_array($tuplaURL) || count($tuplaURL) == 0) { $smarty->assign("mb_title", _tr('Unable to read URL')); $smarty->assign("mb_message", _tr('Cannot read URL') . ' - ' . $urls->errMsg); return ''; } } $formCampos = array('description' => array("LABEL" => _tr('URL Description'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", 'ROWS' => 6, 'COLS' => 50, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'urltemplate' => array("LABEL" => _tr('URL Template'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array('size' => 64, 'title' => _tr('TEMPLATE_DESC')), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'active' => array("LABEL" => _tr('Enable use of this template'), "REQUIRED" => "yes", "INPUT_TYPE" => "CHECKBOX", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'opentype' => array("LABEL" => _tr('Open URL in'), "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => descOpenType(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $formCampos); if (!is_null($id_url)) { $oForm->setEditMode(); $smarty->assign('id_url', $id_url); } if (!is_null($tuplaURL)) { if (!isset($_POST['description'])) { $_POST['description'] = $tuplaURL['description']; } if (!isset($_POST['urltemplate'])) { $_POST['urltemplate'] = $tuplaURL['urltemplate']; } if (!isset($_POST['opentype'])) { $_POST['opentype'] = $tuplaURL['opentype']; } if (!isset($_POST['active'])) { $_POST['active'] = $tuplaURL['active'] ? 'on' : 'off'; } } else { if (!isset($_POST['active'])) { $_POST['active'] = 'on'; } } // 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)) { // 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); } else { if ($bDoCreate) { $bExito = $urls->createURL($_POST['urltemplate'], $_POST['description'], $_POST['opentype']); } elseif ($bDoUpdate) { $urls->enableURL($id_url, $_POST['active'] != 'off'); $bExito = $urls->updateURL($id_url, $_POST['urltemplate'], $_POST['description'], $_POST['opentype']); } if ($bExito) { header("Location: ?menu={$module_name}"); } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $urls->errMsg); } } } $smarty->assign(array('SAVE' => _tr('Save'), 'CANCEL' => _tr('Cancel'), 'APPLY_CHANGES' => _tr('Apply Changes'))); return $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_url) ? _tr("New URL") : _tr("Edit URL"), $_POST); }
function saveNewCrearcampaña($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pCrearcampaña = new paloSantoCrearcampaña($pDB); $arrFormCrearcampaña = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormCrearcampaña); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormCrearcampaña($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { // si no hay error de validación, procedo a guardar la campaña $msg = $pCrearcampaña->guardarCampaña($_POST); $smarty->assign("mb_title", _tr("Mensaje:")); $smarty->assign("mb_message", $msg); $content = viewFormCrearcampaña($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } return $content; }
function saveNewAnnouncement($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $continue = true; $success = false; $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pAnnouncement = new paloSantoAnnouncement($pDB, $domain); $arrFormOrgz = createFieldForm(array(), array(), $pDB, $domain); $oForm = new paloForm($smarty, $arrFormOrgz); $description = trim(getParameter('description')); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } elseif (count(explode("\n", $description)) > 1) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid description text")); return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($pAnnouncement->validateDestine($domain, getParameter("destination")) == false) { $error = _tr("You must select a default destination."); $continue = false; } if ($continue) { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["description"] = $description; $arrProp["recording_id"] = getParameter("recording_id"); $arrProp["allow_skip"] = getParameter("allow_skip"); $arrProp["return_ivr"] = getParameter("return_ivr"); $arrProp["noanswer"] = getParameter("noanswer"); $arrProp["repeat_msg"] = getParameter("repeat_msg"); $arrProp["goto"] = getParameter("goto"); $arrProp['destination'] = getParameter("destination"); } if ($continue) { $pDB->beginTransaction(); $success = $pAnnouncement->createNewAnnouncement($arrProp); if ($success) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pAnnouncement->errMsg; } } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Announcement has been created successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); $content = reportAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function saveDHCP_Configuration($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $update = FALSE) { $pDHCP_Configuration = new paloSantoDHCP_Configuration($pDB); $arrFormDHCP_Configuration = createFieldForm(); $oForm = new paloForm($smarty, $arrFormDHCP_Configuration); if ($update) { $oForm->setEditMode(); } $smarty->assign("REQUIRED_FIELD", _tr('Required field')); $smarty->assign("SAVE", _tr('Save')); $smarty->assign("EDIT", _tr('Edit')); $smarty->assign("CANCEL", _tr('Cancel')); $smarty->assign("icon", "modules/{$module_name}/images/system_network_assign_ip_address.png"); $smarty->assign("ID", getParameter('id')); if (!$oForm->validateForm($_POST)) { // 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr('Assign IP Address to Host'), $_POST); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; } else { $arrDhcpPost = array(); $hostname = getParameter("hostname"); if (preg_match("/^([a-zA-Z]+)[[:space:]]+([a-zA-Z]+)\$/", $hostname, $arrReg)) { $arrDhcpPost['hostname'] = $arrReg[1] . "_" . $arrReg[2]; } else { $arrDhcpPost['hostname'] = getParameter("hostname"); } $arrDhcpPost['ipaddress'] = getParameter("ipaddress"); $arrDhcpPost['macaddress'] = getParameter("macaddress"); if ($update) { $id = getParameter("id"); $r = $pDHCP_Configuration->actualizarIpFija($id, $arrDhcpPost['hostname'], $arrDhcpPost['ipaddress'], $arrDhcpPost['macaddress']); } else { $r = $pDHCP_Configuration->insertarIpFija($arrDhcpPost['hostname'], $arrDhcpPost['ipaddress'], $arrDhcpPost['macaddress']); } if (!$r) { $smarty->assign("mb_message", $pDHCP_Configuration->errMsg); $smarty->assign("REQUIRED_FIELD", _tr('Required field')); $smarty->assign("SAVE", _tr('Save')); $smarty->assign("CANCEL", _tr('Cancel')); $smarty->assign("icon", "modules/{$module_name}/images/system_network_assign_ip_address.png"); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr('Assign IP Address to Host'), $_POST); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; } else { header("Location: ?menu={$module_name}&action=show"); } } }
function saveNewKey($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrAST, $arrAMP) { $arrFormNew = createFieldForm($pDB); $arrValues['id'] = getParameter("Extension"); $arrValues['key'] = getParameter("Current_Secret"); $arrValues['new_key'] = getParameter("New_Secret"); $confirmation = getParameter("Confirm_New_Secret"); $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']); $pACL = new paloACL($pDB2); $oForm = new paloForm($smarty, $arrFormNew); if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $pWeakKeys = new paloSantoWeakKeys($pDB); $device = $pWeakKeys->getWeakKeyById($arrValues['id']); if (!$pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) { if ($arrValues['key'] != $device['data']) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The Current Secret is invalid")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } } if ($arrValues['new_key'] != $confirmation) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The New Secret does not match with the Confirmation Secret")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $mensaje = getMensaje($arrValues['id'], $arrValues['new_key']); if ($mensaje != "OK") { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $mensaje); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } if (!$pWeakKeys->saveNewKey($arrValues, $device['tech'])) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pWeakKeys->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $data_connection = array('host' => $arrConf['AMI_HOST'], 'user' => $arrConf['AMI_USER'], 'password' => $arrConf['AMI_PASS']); $pLoadExtension = new paloSantoLoadExtension($pDB); if (!$pLoadExtension->do_reloadAll($data_connection, $arrAST, $arrAMP)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pLoadExtension->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Successful Secret Update")); return reportWeakKeys($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast) { $paloVoice = new paloSantoVoiceMail($pDB_ast); $arrDat = $paloVoice->loadConfiguration($ext); $arrForm = createFieldFormConfig($arrLang); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST) || $_POST['password'] != $_POST['password_confir']) { $smarty->assign("mb_title", "Validation Error"); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>'The following fields contain errors':</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } if ($_POST['password'] != $_POST['password_confir']) { $strErrorMsg .= "Confirm Password"; } $smarty->assign("mb_message", $strErrorMsg); return false; } $option = $_POST['status'] == "Enable" ? 1 : 0; $Ext = $ext; $VoiceMail_PW = $_POST['password']; $password_2 = $_POST['password_confir']; $Name = $arrDat[2]; $VM_Email_Address = $_POST['email']; $VM_Pager_Email_Addr = $_POST['pager_email']; $VM_Options = $arrDat[5]; $VM_EmailAttachment = $_POST['email_attach'] == 'Yes' ? 'yes' : 'no'; $VM_Play_CID = $_POST['play_cid'] == 'Yes' ? 'yes' : 'no'; $VM_Play_Envelope = $_POST['play_envelope'] == 'Yes' ? 'yes' : 'no'; $VM_Delete_Vmail = $_POST['delete_vmail'] == 'Yes' ? 'yes' : 'no'; $bandera = $paloVoice->writeFileVoiceMail($Ext, $Name, $VoiceMail_PW, $VM_Email_Address, $VM_Pager_Email_Addr, $VM_Options, $VM_EmailAttachment, $VM_Play_CID, $VM_Play_Envelope, $VM_Delete_Vmail, $option); if ($bandera == true) { return true; } else { $smarty->assign("mb_title", "Error"); $smarty->assign("mb_message", $paloVoice->errMsg); return false; } }
function applyChanges($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $action = ""; $pORGZ = new paloSantoOrganization($pDB); $pGP = new paloGeneralPBX($pDB); $arrForm = createFieldForm($pGP->getVoicemailTZ()); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); } else { $arrProp = getParameterGeneralSettings(); $pDB->beginTransaction(); $exito = $pGP->setGeneralSettings($arrProp); if ($exito === true) { $pDB->commit(); unset($_POST["save_edit"]); if (reloadFiles()) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Changes have been applied successfully.")); } else { $smarty->assign("mb_title", _tr("ERROR")); $msg = _tr("Changes couldn't be applied successfully. "); $msg .= $pGP->errMsg; $smarty->assign("mb_message", $msg); } } else { $pDB->rollBack(); $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Changes couldn't be applied. ") . $pGP->errMsg); } } return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function saveEditQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $exito = false; $qname = getParameter("qname"); $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } if (!isset($qname)) { $error = _tr("Queue doesn't exist"); } else { $pQueue = new paloQueuePBX($pDB, $domain); $arrTmp = $pQueue->getQueueByName($qname); if ($arrTmp === false) { $error = _tr("Error with database connection. ") . $pQueue->errMsg; } elseif (count($arrTmp) == false) { $error = _tr("Queue doesn't exist"); } else { $arrForm = createFieldForm(array(), array(), array(), array(), array()); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $password = getParameter("password_detail"); if (isset($password)) { if (!preg_match("/^[0-9]*\$/", $password)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Password must only contain digits.")); return viewQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } $arrMembers = array('dynamic_members' => getParameter("dynamic_members"), 'static_members' => getParameter("static_members")); $pDB->beginTransaction(); $arrProp = queueParams(); $arrProp["name"] = $qname; $exito = $pQueue->updateQueue($arrProp, $arrMembers); if ($exito) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pQueue->errMsg; } } } if ($exito) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Queue has been edited successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); } return reportQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); }
function save_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, $update = FALSE) { $arrForm = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrForm); $pACL = new paloACL($pDB_2); $id_user = $pACL->getIdUser($_SESSION["elastix_user"]); $bandera = true; if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } $smarty->assign("mb_message", $strErrorMsg); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("title", $arrLang["Address Book"]); $smarty->assign("new_contact", $arrLang["New Contact"]); $smarty->assign("address_from_csv", $arrLang["Address Book from CSV"]); $smarty->assign("private_contact", $arrLang["Private Contact"]); $smarty->assign("public_contact", $arrLang["Public Contact"]); if (isset($_POST['address_book_options']) && $_POST['address_book_options'] == 'address_from_csv') { $smarty->assign("check_csv", "checked"); } else { $smarty->assign("check_new_contact", "checked"); } if (isset($_POST['address_book_status']) && $_POST['address_book_status'] == 'isPrivate') { $smarty->assign("check_isPrivate", "checked"); } else { $smarty->assign("check_isPublic", "checked"); } $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("label_file", $arrLang["File"]); $smarty->assign("DOWNLOAD", $arrLang["Download Address Book"]); $smarty->assign("HeaderFile", $arrLang["Header File Address Book"]); $smarty->assign("AboutContacts", $arrLang["About Address Book"]); if ($update) { $_POST["edit"] = 'edit'; return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } else { $smarty->assign("Show", 1); $smarty->assign("ShowImg", 1); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new_adress_book.tpl", $arrLang["Address Book"], $_POST); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; } } else { $pictureUpload = $_FILES['picture']['name']; $file_upload = ""; $ruta_destino = "/var/www/address_book_images"; $idPost = $_POST['id']; $data = array(); $padress_book = new paloAdressBook($pDB); $contactData = $padress_book->contactData($idPost, $id_user); $lastId = 0; if ($update) { $idImg = $contactData['id']; } else { $idImg = date("Ymdhis"); } //valido el tipo de archivo if (isset($pictureUpload) && $pictureUpload != "") { // \w cualquier caracter, letra o guion bajo // \s cualquier espacio en blanco if (!preg_match("/^(\\w|-|\\.|\\(|\\)|\\s)+\\.(png|PNG|JPG|jpg|JPEG|jpeg)\$/", $pictureUpload)) { $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Invalid file extension.- It must be png or jpg or jpeg"]); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } else { if (is_uploaded_file($_FILES['picture']['tmp_name'])) { $file_upload = basename($_FILES['picture']['tmp_name']); // verificando que solo tenga la ruta al archivo $file_name = basename("/tmp/" . $_FILES['picture']['name']); $ruta_archivo = "/tmp/{$file_upload}"; $arrIm = explode(".", $pictureUpload); $renameFile = "{$ruta_destino}/{$idImg}." . $arrIm[count($arrIm) - 1]; $file_upload = $idImg . "." . $arrIm[count($arrIm) - 1]; $filesize = $_FILES['picture']['size']; $filetype = $_FILES['picture']['type']; $sizeImgUp = getimagesize($ruta_archivo); if (!$sizeImgUp) { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["Possible file upload attack. Filename"] . " : " . $pictureUpload); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } //realizar acciones if (!rename($ruta_archivo, $renameFile)) { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["Error to Upload"] . " : " . $pictureUpload); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } else { //redimensiono la imagen $ancho_thumbnail = 48; $alto_thumbnail = 48; $thumbnail_path = $ruta_destino . "/{$idImg}" . "_Thumbnail." . $arrIm[count($arrIm) - 1]; if (is_file($renameFile)) { if (!redimensionarImagen($renameFile, $thumbnail_path, $ancho_thumbnail, $alto_thumbnail)) { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["Possible file upload attack. Filename"] . " : " . $pictureUpload); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } } $ancho = 280; $alto = 200; if (is_file($renameFile)) { if (!redimensionarImagen($renameFile, $renameFile, $ancho, $alto)) { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["Possible file upload attack. Filename"] . " : " . $pictureUpload); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } } } } else { $smarty->assign("mb_title", $arrLang["ERROR"]); $smarty->assign("mb_message", $arrLang["Possible file upload attack. Filename"] . " : " . $pictureUpload); if ($update) { return view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, TRUE); } else { return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } } } $namedb = isset($_POST['name']) ? $_POST['name'] : ""; $last_namedb = isset($_POST['last_name']) ? $_POST['last_name'] : ""; $telefonodb = isset($_POST['telefono']) ? $_POST['telefono'] : ""; //$extensiondb = isset($_POST['extension'])?$_POST['extension']:""; $emaildb = isset($_POST['email']) ? $_POST['email'] : ""; $iduserdb = isset($id_user) ? "{$id_user}" : ""; $picturedb = isset($file_upload) ? "{$file_upload}" : ""; $addressdb = isset($_POST['address']) ? $_POST['address'] : ""; $companydb = isset($_POST['company']) ? $_POST['company'] : ""; $notesdb = isset($_POST['notes']) ? $_POST['notes'] : ""; $statusdb = isset($_POST['address_book_status']) ? $_POST['address_book_status'] : ""; $data = array($namedb, $last_namedb, $telefonodb, $emaildb, $iduserdb, $picturedb, $addressdb, $companydb, $notesdb, $statusdb); if ($update) { // actualizacion del contacto if ($contactData) { if ($file_upload == "") { $data[5] = $contactData['picture']; } $result = $padress_book->updateContact($data, $_POST['id']); if (!$result) { $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Internal Error"]); return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } else { $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Internal Error"]); return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } } else { //// creacion de contacto $result = $padress_book->addContact($data); if (!$result) { $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Internal Error"]); return new_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } $lastId = $pDB->getLastInsertId(); $contactData2 = $padress_book->contactData($lastId, $id_user); if ($contactData2['picture'] != "" && isset($contactData2['picture'])) { $arrIm = explode(".", $contactData2['picture']); $renameFile = "{$ruta_destino}/" . $lastId . "." . $arrIm[count($arrIm) - 1]; $file_upload = $lastId . "." . $arrIm[count($arrIm) - 1]; rename($ruta_destino . "/" . $contactData2['picture'], $renameFile); rename($ruta_destino . "/" . $idImg . "_Thumbnail." . $arrIm[count($arrIm) - 1], $ruta_destino . "/" . $lastId . "_Thumbnail." . $arrIm[count($arrIm) - 1]); $data[5] = $file_upload; $padress_book->updateContact($data, $lastId); } } if (!$result) { return $pDB->errMsg; } //'?menu=$module_name&action=show&id=".$adress_book['id']."' if ($_POST['id']) { header("Location: ?menu={$module_name}&action=show&id=" . $_POST['id']); } else { header("Location: ?menu={$module_name}"); } } }
function saveEditBaseDeClientes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pIngresodeBasedeClientes = new paloSantoIngresodeBasedeClientes($pDB); $arrFormIngresodeBasedeClientes = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormIngresodeBasedeClientes); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormIngresodeBasedeClientes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { $arrResult = $pIngresodeBasedeClientes->actualizarCampaniaRecarga($_POST); header("location: ?menu=hispana_listado_recarga"); } 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/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 saveNewMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $continue = true; $success = false; if ($credentials['userlevel'] == 'superadmin') { $pMoH = new paloSantoMoH($pDB, ""); } else { $domain = $credentials['domain']; $pMoH = new paloSantoMoH($pDB, $domain); } $arrFormOrgz = createFieldForm(array(), $credentials['userlevel'] == 'superadmin'); $oForm = new paloForm($smarty, $arrFormOrgz); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $name = getParameter("name"); if ($name == "") { $error = _tr("Field 'Name' can't be empty."); $continue = false; } elseif (getParameter("mode_moh") == 'custom' && $credentials['userlevel'] != 'superadmin') { $error = _tr('Creation of custom MOH restricted to superadmin'); $continue = FALSE; } if ($continue) { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["name"] = getParameter("name"); $arrProp["mode"] = getParameter("mode_moh"); $arrProp["application"] = getParameter("application"); $arrProp["sort"] = getParameter("sort"); $arrProp["format"] = getParameter("format"); } if ($continue) { $pDB->beginTransaction(); $success = $pMoH->createNewMoH($arrProp); if ($success) { $pDB->commit(); if ($arrProp["mode"] == "files") { $pMoH->uploadFile($arrProp["name"]); } } else { $pDB->rollBack(); } $error .= $pMoH->errMsg; } } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("New MoH Class has been created successfully") . " " . $error); $content = reportMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function saveNewList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pEmailList = new paloSantoEmailList($pDB); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('domain'); } else { $domain = $credentials['domain']; } $namelist = getParameter("namelist"); $namelist = strtolower($namelist); $password = getParameter("password"); $passwordconfirm = getParameter("passwordconfirm"); $emailadmin = getParameter("emailadmin"); $arrForm = createFieldForm(array()); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } //validaciones if ($password != $passwordconfirm) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The Password List and Confirm Password List do not match")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $pDB->beginTransaction(); if (!$pEmailList->createEmailList($domain, $namelist, $password, $emailadmin)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("List could not be created.") . " " . $pEmailList->getError()); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $pDB->commit(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("The List was created successfully ")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } }
function saveNewFTPBackup($smarty, $module_name, $local_templates_dir, &$pDB) { $pFTPBackup = new paloSantoFTPBackup($pDB); $oForm = new paloForm($smarty, createFieldForm()); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $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) { $strErrorMsg .= implode(', ', array_keys($arrErrores)); } $smarty->assign("mb_message", $strErrorMsg); } else { $server = getParameter("server"); $port = getParameter("port"); $user = getParameter("user"); $password = getParameter("password"); $path = getParameter("pathServer"); //deben estar llenos todos los campos if ($server && $port && $user && $password && $path) { $r = $pFTPBackup->asignarCredencialesFTP($server, $port, $user, $password, $path); if (!$r) { $smarty->assign("mb_message", $pFTPBackup->errMsg); } } else { $smarty->assign("mb_message", _tr('Error to save')); } } return viewFormFTPBackup($smarty, $module_name, $local_templates_dir, $pDB); }
function saveNewEmailRelay($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $arrFormEmailRelay = createFieldForm(); $oForm = new paloForm($smarty, $arrFormEmailRelay); if (!$oForm->validateForm($_POST)) { $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} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); } else { $pEmailRelay = new paloSantoEmailRelay($pDB); $arrData['relayhost'] = rtrim(getParameter('relayhost')); $arrData['port'] = rtrim(getParameter('port')); $arrData['user'] = rtrim(getParameter('user')); $arrData['password'] = rtrim(getParameter('password')); $arrData['status'] = rtrim(getParameter('status')); $arrData['autentification'] = getParameter('autentification'); if ($arrData['status'] != 'on') { $arrData['status'] = 'off'; } $SMTP_Server = rtrim(getParameter('SMTP_Server')); if ($SMTP_Server != "custom") { if ($arrData['user'] == "" || $arrData['password'] == "") { $varErrors = ""; if ($arrData['user'] == "") { $varErrors = _tr("Username") . ", "; } if ($arrData['password'] == "") { $varErrors .= " " . _tr("Password"); } $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>" . $varErrors; $smarty->assign("mb_message", $strErrorMsg); $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; } } $tls_enabled = $arrData['autentification'] == "on" ? true : false; $auth_enabled = $arrData['user'] != "" && $arrData['password'] != ""; $isOK = $arrData['status'] == 'on' ? $pEmailRelay->checkSMTP($arrData['relayhost'], $arrData['port'], $arrData['user'], $arrData['password'], $auth_enabled, $tls_enabled) : true; if (is_array($isOK)) { //hay errores al tratar de verificar datos $errors = $isOK["ERROR"]; $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($errors)); $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; } $pEmailRelay->setStatus($arrData['status']); $ok = $pEmailRelay->processUpdateConfiguration($arrData); if ($ok) { $smarty->assign("mb_title", _tr("Result transaction")); $smarty->assign("mb_message", _tr("Configured successful")); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pEmailRelay->errMsg); } } $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir) { $smarty->assign(array('SEARCH' => _tr('Search'))); $oFax = new paloFaxVisor(); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements()); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All'); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out')); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL)); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); if (!$oFilterForm->validateForm($paramFiltro)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $paramFiltro = $paramFiltroBase; unset($_POST['faxes_delete']); // Se aborta el intento de borrar faxes, si había uno. } $url = array_merge($url, $paramFiltro); // Ejecutar el borrado, si se ha validado. if (isset($_POST['faxes_delete']) && isset($_POST['faxes']) && is_array($_POST['faxes']) && count($_POST['faxes']) > 0) { $msgError = NULL; foreach ($_POST['faxes'] as $idFax) { if (!$oFax->deleteInfoFax($idFax)) { if ($oFax->errMsg = '') { $msgError = _tr('Unable to eliminate pdf file from the path.'); } else { $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg; } } } if (!is_null($msgError)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } } $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("modules/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; $total = $oFax->obtener_cantidad_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $oFax->obtener_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); $oGrid->setColumns(array("", _tr('Type'), _tr('File'), _tr('Company Name'), _tr('Company Fax'), _tr('Fax Destiny'), _tr('Fax Date'), _tr('Status'), _tr('Options'))); if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax', 'errormsg') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } if (empty($fax['status']) && !empty($fax['errormsg'])) { $fax['status'] = 'failed'; } $arrData[] = array('<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />', _tr($fax['type']), strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file'], $fax['company_name'], $fax['company_fax'], $fax['destiny_name'] . " - " . $fax['destiny_fax'], $fax['date'], _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']), "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"); } } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $oGrid->setData($arrData); $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }