Example #1
0
function showExtensionSettings($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    global $arrCredentials;
    $pMyExten = new paloMyExten($pDB, $arrCredentials['idUser']);
    if (getParameter('action') == 'save') {
        $my_exten = $_POST;
    } else {
        $my_exten = $pMyExten->getMyExtension();
    }
    if ($my_exten == false) {
        $smarty->assign("MSG_ERROR_FIELD", $pMyExten->getErrorMsg());
    }
    $smarty->assign("DISPLAY_NAME_LABEL", _tr("Display Name CID:"));
    $smarty->assign("clid_name", $my_exten['clid_name']);
    $smarty->assign("DISPLAY_EXT_LABEL", _tr("Extension number:"));
    $smarty->assign("DISPLAY_DEVICE_LABEL", _tr("Device:"));
    $smarty->assign("device", $my_exten['device']);
    $smarty->assign("extension", $my_exten['extension']);
    $smarty->assign("DISPLAY_CFC_LABEL", _tr("Call Forward Configuration"));
    $smarty->assign("DISPLAY_CMS_LABEL", _tr("Call Monitor Settings"));
    $smarty->assign("DISPLAY_VOICEMAIL_LABEL", _tr("Voicemail Configuration"));
    //$smarty->assign("SAVE_CONF_BTN",_tr("Save Configuration"));
    // $smarty->assign("CANCEL_BTN",_tr("Cancel"));
    //contiene los elementos del formulario
    $arrForm = createForm();
    $oForm = new paloForm($smarty, $arrForm);
    $html = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr('extension'), $my_exten);
    $contenidoModulo = "<div><form  method='POST' style='margin-bottom:0;' name='{$module_name}' id='{$module_name}' action='?menu={$module_name}'>" . $html . "</form></div>";
    return $contenidoModulo;
}
Example #2
0
function showConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials)
{
    global $arrPermission;
    $fMaster = new paloFaxMaster($pDB);
    $arrForm = fieldFrorm();
    $oForm = new paloForm($smarty, $arrForm);
    $oForm->setEditMode();
    $smarty->assign("EDIT", in_array('edit', $arrPermission));
    if (getParameter("save_default")) {
        $arrDefault['fax_master'] = $_POST['fax_master'];
    } else {
        //obtener el valor de la tarifa por defecto
        $arrDefault['fax_master'] = $fMaster->getFaxMaster();
        if ($arrDefault['fax_master'] === false) {
            $smarty->assign("mb_title", "ERROR");
            $smarty->assign("mb_message", _tr("An error has ocurred to retrieved configuration.") . " " . $fMaster->getErrorMsg());
            $arrDefault['fax_master'] = '';
        }
    }
    $smarty->assign("FAXMASTER_MSG", _tr("Write the email address which will receive the notifications of received messages, errors and activity summary of the Fax Server"));
    $smarty->assign("icon", "web/apps/{$module_name}/images/fax_fax_master.png");
    $smarty->assign("APPLY_CHANGES", _tr("Save"));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $strReturn = $oForm->fetchForm("{$local_templates_dir}/fax_master.tpl", _tr("Fax Master Configuration"), $arrDefault);
    return $strReturn;
}
Example #3
0
function _moduleContent(&$smarty, $module_name)
{
    //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'];
    $formCampos = array();
    $txtCommand = isset($_POST['txtCommand']) ? $_POST['txtCommand'] : '';
    $oForm = new paloForm($smarty, $formCampos);
    $smarty->assign("asterisk", "Asterisk CLI");
    $smarty->assign("command", $arrLang["Command"]);
    $smarty->assign("txtCommand", htmlspecialchars($txtCommand));
    $smarty->assign("execute", $arrLang["Execute"]);
    $smarty->assign("icon", "modules/{$module_name}/images/pbx_tools_asterisk_cli.png");
    $result = "";
    if (!isBlank($txtCommand)) {
        $result = "<pre>";
        putenv("TERM=vt100");
        putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
        putenv("SCRIPT_FILENAME=" . strtok(stripslashes($txtCommand), " "));
        /* PHP scripts */
        $badchars = array("'", "`", "\\", ";", "\"");
        // Strip off any nasty chars.
        $fixedcmd = str_replace($badchars, "", $txtCommand);
        $ph = popen(stripslashes("asterisk -nrx \"{$fixedcmd}\""), "r");
        while ($line = fgets($ph)) {
            $result .= htmlspecialchars($line);
        }
        pclose($ph);
        $result .= "</pre>";
    }
    if ($result == "") {
        $result = "&nbsp;";
    }
    $smarty->assign("RESPUESTA_SHELL", $result);
    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Asterisk-Cli"], $_POST);
    return $contenidoModulo;
}
Example #4
0
function viewFormOverall_setting($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pOverall_setting = new paloSantoOverall_setting($pDB);
    $oForm = new paloForm($smarty);
    $smarty->assign("icon", "images/list.png");
    // get data
    $result = $pOverall_setting->getNotification();
    $smarty->assign("message", $result[0]['message']);
    $smarty->assign("isActive", $result[0]['isActive']);
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", "Thiết lập hệ thống");
    return $content;
}
Example #5
0
function display_form($smarty, $module_name, $local_templates_dir)
{
    require_once "libs/paloSantoForm.class.php";
    if (getParameter('csvupload') != '') {
        upload_csv($smarty, $module_name);
    }
    if (getParameter('delete_all') != '') {
        delete_extensions($smarty, $module_name);
    }
    $smarty->assign(array('MODULE_NAME' => $module_name, 'LABEL_FILE' => _tr("File"), 'LABEL_UPLOAD' => _tr('Save'), 'LABEL_DOWNLOAD' => _tr("Download Extensions"), 'LABEL_DELETE' => _tr('Delete All Extensions'), 'CONFIRM_DELETE' => _tr("Are you really sure you want to delete all the extensions in this server?"), 'HeaderFile' => _tr("Header File Extensions Batch"), 'AboutUpdate' => _tr("About Update Extensions Batch")));
    $oForm = new paloForm($smarty, array());
    return $oForm->fetchForm("{$local_templates_dir}/extension.tpl", _tr('Extensions Batch'), $_POST);
}
Example #6
0
function viewFormInstant_Messaging($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/instant_messaging.png");
    $smarty->assign("imess1_img", "modules/{$module_name}/images/spark.jpg");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("imess1_software_description", _tr("spark_software_description"));
    $smarty->assign("imess1_manufacturer_description", _tr("spark_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Instant Messaging"));
    return $content;
}
Example #7
0
function viewFormSoftphones($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/softphones.png");
    $smarty->assign("xlite_img", "modules/{$module_name}/images/x-lite-4-lrg.png");
    $smarty->assign("zoiper_img", "modules/{$module_name}/images/zoiper.png");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("xlite_software_description", _tr("xlite_software_description"));
    $smarty->assign("xlite_manufacturer_description", _tr("xlite_manufacturer_description"));
    $smarty->assign("zoiper_software_description", _tr("zoiper_software_description"));
    $smarty->assign("zoiper_manufacturer_description", _tr("zoiper_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Softphones"), array());
    return $content;
}
Example #8
0
function showApplets_Admin($module_name)
{
    global $smarty;
    global $arrLang;
    global $arrConf;
    $pAppletAdmin = new paloSantoAppletAdmin();
    $oForm = new paloForm($smarty, array());
    $arrApplets = $pAppletAdmin->getApplets_User($_SESSION["elastix_user"]);
    //Codigo para tomar en cuenta el nombre de applets para los archivos de idioma
    foreach ($arrApplets as &$applet) {
        $applet['name'] = _tr($applet['name']);
    }
    unset($applet);
    //
    $smarty->assign("applets", $arrApplets);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("Applet", $arrLang["Applet"]);
    $smarty->assign("Activated", $arrLang["Activated"]);
    $smarty->assign("checkall", $arrLang["Check All"]);
    $smarty->assign("icon", "modules/{$module_name}/images/system_dashboard_applet_admin.png");
    //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'];
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/applet_admin.tpl", $arrLang["Dashboard Applet Admin"], $_POST);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Example #9
0
function viewFormFax_Utilities($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/fax_utilities.png");
    $smarty->assign("fax1_img", "modules/{$module_name}/images/jhylafax.jpg");
    $smarty->assign("fax2_img", "modules/{$module_name}/images/winprinthylafax.jpg");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("fax1_software_description", _tr("jhylafax_software_description"));
    $smarty->assign("fax1_manufacturer_description", _tr("jhylafax_manufacturer_description"));
    $smarty->assign("fax2_software_description", _tr("winprint_software_description"));
    $smarty->assign("fax2_manufacturer_description", _tr("winprint_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Fax Utilities"), array());
    return $content;
}
Example #10
0
function viewFormFestival($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $pFestival = new paloSantoFestival();
    $arrFormFestival = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormFestival);
    $_DATA = $_POST;
    if ($pFestival->isFestivalActivated()) {
        $_DATA["status"] = "on";
    } else {
        $_DATA["status"] = "off";
    }
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("icon", "web/apps/{$module_name}/images/pbx_tools_festival.png");
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Festival"), $_DATA);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Example #11
0
function formTime($smarty, $module_name, $local_templates_dir, $sZonaActual)
{
    $smarty->assign("TIME_TITULO", _tr("Date and Time Configuration"));
    $smarty->assign("INDEX_HORA_SERVIDOR", _tr("Current Datetime"));
    $smarty->assign("TIME_NUEVA_FECHA", _tr("New Date"));
    $smarty->assign("TIME_NUEVA_HORA", _tr("New Time"));
    $smarty->assign("TIME_NUEVA_ZONA", _tr("New Timezone"));
    $smarty->assign("INDEX_ACTUALIZAR", _tr("Apply changes"));
    $smarty->assign("TIME_MSG_1", _tr("The change of date and time can concern important  system processes.") . '  ' . _tr("Are you sure you wish to continue?"));
    $arrForm = array();
    $oForm = new paloForm($smarty, $arrForm);
    /*
        Para cambiar la zona horaria:
        1)	Abrir y mostrar columna 3 de /usr/share/zoneinfo/zone.tab que muestra todas las zonas horarias.
        2)	Al elegir fila de columna 3, verificar que sea de la forma abc/def y que
            existe el directorio /usr/share/zoneinfo/abc/def . Pueden haber N elementos
            en la elección, separados por / , incluyendo uno solo (sin / alguno)
        3)	Si existe /etc/localtime, borrarlo
        4)	Copiar archivo /usr/share/zoneinfo/abc/def a /etc/localtime
        5)	Si existe /var/spool/postfix/etc/localtime , removerlo y sobreescribr
            con el mismo archivo copiado a /etc/localtime
            
        Luego de esto, ejecutar cambio de hora local
    */
    $listaZonas = leeZonas();
    // Cargar de /etc/sysconfig/clock la supuesta zona horaria configurada.
    // El resto de contenido del archivo se preserva, y la clave ZONE se
    // escribirá como la última línea en caso de actualizar
    $sZonaActual = "America/New_York";
    $infoZona = NULL;
    $hArchivo = fopen('/etc/sysconfig/clock', 'r');
    if ($hArchivo) {
        $infoZona = array();
        while (!feof($hArchivo)) {
            $s = fgets($hArchivo);
            $regs = NULL;
            if (ereg('^ZONE="(.*)"', $s, $regs)) {
                $sZonaActual = $regs[1];
            } else {
                $infoZona[] = $s;
            }
        }
        fclose($hArchivo);
    }
    $sContenido = '';
    $mes = date("m", time());
    $mes = (int) $mes - 1;
    $smarty->assign("CURRENT_DATETIME", strftime("%Y,{$mes},%d,%H,%M,%S", time()));
    $smarty->assign('LISTA_ZONAS', $listaZonas);
    $smarty->assign('ZONA_ACTUAL', $sZonaActual);
    $smarty->assign("CURRENT_DATE", strftime("%d %b %Y", time()));
    $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferences_datetime.png");
    $sContenido .= $oForm->fetchForm("{$local_templates_dir}/time.tpl", _tr('Date and Time Configuration'), $_POST);
    return $sContenido;
}
Example #12
0
function _moduleContent(&$smarty, $module_name)
{
    global $arrConf;
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    $txtCommand = isset($_POST['txtCommand']) ? trim($_POST['txtCommand']) : '';
    $oForm = new paloForm($smarty, array());
    $smarty->assign(array('asterisk' => _tr('Asterisk CLI'), 'command' => _tr('Command'), 'txtCommand' => htmlspecialchars($txtCommand), 'execute' => _tr('Execute'), 'icon' => "web/apps/{$module_name}/images/pbx_tools_asterisk_cli.png"));
    $result = "";
    if (!empty($txtCommand)) {
        $output = $retval = NULL;
        exec("/usr/sbin/asterisk -rnx " . escapeshellarg($txtCommand), $output, $retval);
        $result = '<pre>' . implode("\n", array_map('htmlspecialchars', $output)) . '</pre>';
    }
    if ($result == "") {
        $result = "&nbsp;";
    }
    $smarty->assign("RESPUESTA_SHELL", $result);
    return $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr('Asterisk-Cli'), $_POST);
}
Example #13
0
function formCurrency($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    global $arrPermission;
    $arrFormCurrency = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormCurrency);
    //CARGAR CURRENCY GUARDADO
    $curr = loadCurrentCurrency($pDB);
    if ($curr == false) {
        $curr = "\$";
    }
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferences_currency.png");
    $_POST['currency'] = $curr;
    if (in_array('edit', $arrPermission)) {
        $smarty->assign('EDIT_CURR', true);
    }
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Currency"), $_POST);
    $contenidoModulo = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $contenidoModulo;
}
Example #14
0
function formThemes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $uid)
{
    global $arrPermission;
    if (!empty($pDB->errMsg)) {
        $smarty->assign("mb_message", _tr("Error when connecting to database") . "<br/>" . $pDB->errMsg);
    }
    // Definición del formulario de nueva campaña
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CHANGE", _tr("Save"));
    $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferences_themes.png");
    $oThemes = new PaloSantoThemes($pDB);
    $arr_themes = $oThemes->getThemes("/var/www/html/admin/web/themes/");
    $formThemes = createFieldForm($arr_themes);
    $oForm = new paloForm($smarty, $formThemes);
    if (in_array('edit', $arrPermission)) {
        $smarty->assign('EDIT_THEME', true);
    }
    $tema_actual = $oThemes->getThemeActual($uid);
    $arrTmp['themes'] = $tema_actual;
    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Change Theme"), $arrTmp);
    return $contenidoModulo;
}
Example #15
0
function showApplets_Admin($module_name)
{
    global $smarty;
    global $arrLang;
    global $arrConf;
    $pAppletAdmin = new paloSantoAppletAdmin();
    $oForm = new paloForm($smarty, array());
    $arrApplets = $pAppletAdmin->getApplets_User($_SESSION["elastix_user"]);
    $smarty->assign("applets", $arrApplets);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("Applet", $arrLang["Applet"]);
    $smarty->assign("Activated", $arrLang["Activated"]);
    $smarty->assign("icon", "web/apps/{$module_name}/images/system_dashboard_applet_admin.png");
    setActionTPL();
    //folder path for custom templates
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/applet_admin.tpl", $arrLang["Dashboard Applet Admin"], $_POST);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Example #16
0
function formLanguage($smarty, $module_name, $local_templates_dir, $arrConf, $pACL, $uid)
{
    global $arrPermission;
    $lang = get_language();
    $error_msg = '';
    $archivos = array();
    $langElastix = array();
    $contenido = '';
    $msgError = '';
    $arrDefaultRate = array();
    $conexionDB = FALSE;
    include "configs/languages.conf.php";
    //este archivo crea el arreglo language que contine los idiomas soportados
    //por elastix
    leer_directorio("/usr/share/elastix/lang", $error_msg, $archivos);
    if (count($archivos) > 0) {
        foreach ($languages as $lang => $lang_name) {
            if (in_array("{$lang}.lang", $archivos)) {
                $langElastix[$lang] = $lang_name;
            }
        }
    }
    if (count($langElastix) > 0) {
        $arrFormLanguage = createFieldForm($langElastix);
        $oForm = new paloForm($smarty, $arrFormLanguage);
        if (empty($pACL->errMsg)) {
            $conexionDB = TRUE;
        } else {
            $msgError = _tr("You can't change language") . '.-' . _tr("ERROR") . ":" . $pACL->errMsg;
        }
        // $arrDefaultRate['language']="es";
        $smarty->assign("CAMBIAR", _tr("Save"));
        $smarty->assign("MSG_ERROR", $msgError);
        $smarty->assign("conectiondb", $conexionDB);
        $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferencies_language.png");
        if (in_array('edit', $arrPermission)) {
            $smarty->assign('EDIT_LANG', true);
        }
        //obtener el valor del lenguage por defecto
        $defLang = $pACL->getUserProp($uid, 'language');
        if (empty($defLang) || $defLang === false) {
            $defLang = "en";
        }
        $arrDefault['language'] = $defLang;
        $htmlForm = $oForm->fetchForm("{$local_templates_dir}/language.tpl", _tr("Language"), $arrDefault);
        $contenido = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    }
    return $contenido;
}
Example #17
0
function formCurrency($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang)
{
    $pCurrency = new paloSantoCurrency($pDB);
    $arrFormCurrency = createFieldForm($arrLang);
    $oForm = new paloForm($smarty, $arrFormCurrency);
    //CARGAR CURRENCY GUARDADO
    $curr = loadCurrentCurrency($pDB);
    if ($curr == false) {
        $curr = "\$";
    }
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    $smarty->assign("icon", "modules/{$module_name}/images/system_preferences_currency.png");
    $_POST['currency'] = $curr;
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", $arrLang["Currency"], $_POST);
    $contenidoModulo = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $contenidoModulo;
}
Example #18
0
function new_module($smarty, $module_name, $local_templates_dir, $arrLangModule, &$pDB_acl)
{
    require_once 'libs/paloSantoACL.class.php';
    global $arrConfig;
    $pACL = new paloACL($pDB_acl);
    $groups = $pACL->getGroups();
    $ip = $_SERVER["SERVER_ADDR"];
    foreach ($groups as $value) {
        $arrGroups[$value[0]] = $value[1];
    }
    $arrFormElements = array("group_permissions" => array("LABEL" => $arrLangModule["Group Permission"], "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrGroups, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no", "SIZE" => "3", "MULTIPLE" => true));
    $oForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SAVE", $arrLangModule["Save"]);
    $smarty->assign("REQUIRED_FIELD", $arrLangModule["Required field"]);
    $smarty->assign("general_information", $arrLangModule["General Information"]);
    $smarty->assign("location", $arrLangModule["Location"]);
    $smarty->assign("module_description", $arrLangModule["Module Description"]);
    $smarty->assign("option_type", $arrConfig['arr_type']);
    $smarty->assign("email", $arrLangModule["Your e-mail"]);
    $smarty->assign("module_name_label", $arrLangModule["Module Name"]);
    $smarty->assign("id_module_label", $arrLangModule["Module Id"]);
    $smarty->assign("arrGroups", $arrGroups);
    $smarty->assign("your_name_label", $arrLangModule["Your Name"]);
    $smarty->assign("module_type", $arrLangModule["Module Type"]);
    $smarty->assign("type_grid", $arrLangModule["Grid"]);
    $smarty->assign("type_form", $arrLangModule["Form"]);
    $smarty->assign("type_framed", $arrLangModule["Framed"]);
    $smarty->assign("Field_Name", $arrLangModule["Field Name"]);
    $smarty->assign("Type_Field", $arrLangModule["Type Field"]);
    $smarty->assign("Url", $arrLangModule["Url"]);
    $smarty->assign("level_2", $arrLangModule["Level 2"]);
    $smarty->assign("level_3", $arrLangModule["Level 3"]);
    $smarty->assign("parent_1_exists", $arrLangModule["Level 1 Parent Exists"]);
    $smarty->assign("parent_2_exists", $arrLangModule["Level 2 Parent Exists"]);
    $smarty->assign("peYes", $arrLangModule["Yes"]);
    $smarty->assign("peNo", $arrLangModule["No"]);
    $smarty->assign("module_level", $arrLangModule["Module Level"]);
    $smarty->assign("level_1_parent_name", $arrLangModule["Level 1 Parent Name"]);
    $smarty->assign("level_1_parent_id", $arrLangModule["Level 1 Parent Id"]);
    $smarty->assign("icon", "modules/{$module_name}/images/developer.png");
    $html = $oForm->fetchForm("{$local_templates_dir}/new_module.tpl", $arrLangModule["Build Module"], $_POST);
    //$contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu=$module_name'>".$html."</form>";
    return $html;
}
Example #19
0
function viewFormMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $pEmailList = new paloSantoEmailList($pDB);
    $id_emailList = getParameter("id");
    if ($credentials['userlevel'] == 'superadmin') {
        $emailList = $pEmailList->getEmailList($id_emailList);
    } else {
        $emailList = $pEmailList->getEmailList($id_emailList, $credentials['domain']);
    }
    if ($emailList == false) {
        $smarty->assign("mb_title", _tr("Error"));
        $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist");
        $smarty->assign("mb_message", $error);
        return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $title = _tr("New List Member");
    $smarty->assign("MEMBER", "save_newMember");
    $info = _tr("You must enter each email line by line, like the following") . ":<br /><br /><b>" . _tr("*****@*****.**") . "<br />" . _tr("*****@*****.**") . "<br />" . _tr("*****@*****.**") . "</b><br /><br />" . _tr("You can also enter a name for each email, like the following") . ":<br /><br /><b>" . _tr("Name1 Lastname1 <*****@*****.**>") . "<br />" . _tr("Name2 Lastname2 <*****@*****.**>") . "<br />" . _tr("Name3 Lastname3 <*****@*****.**>") . "</b>";
    $smarty->assign("SAVE", _tr("Add"));
    $smarty->assign("IDEMAILLIST", $id_emailList);
    $smarty->assign("ACTION", 'view_memberlist');
    $arrFormMemberlist = createFieldFormMember();
    $oForm = new paloForm($smarty, $arrFormMemberlist);
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("INFO", $info);
    $smarty->assign("icon", "web/apps/{$module_name}/images/email.png");
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form_member.tpl", $title, $_POST);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Example #20
0
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;
}
Example #21
0
function listRepositories($smarty, $module_name, $local_templates_dir, $arrConf)
{
    global $arrLang;
    $oRepositories = new PaloSantoRepositories();
    $arrReposActivos = array();
    $typeRepository = getParameter("typeRepository");
    if (isset($_POST['submit_aceptar'])) {
        foreach ($_POST as $key => $value) {
            if (substr($key, 0, 5) == 'repo-') {
                $arrReposActivos[] = substr($key, 5);
            }
        }
        $oRepositories->setRepositorios($arrConf['ruta_repos'], $arrReposActivos, $typeRepository, $arrConf["main_repos"]);
    }
    $option["main"] = "";
    $option["others"] = "";
    $option["all"] = "";
    $arrRepositorios = $oRepositories->getRepositorios($arrConf['ruta_repos'], $typeRepository, $arrConf["main_repos"]);
    $limit = 40;
    $total = count($arrRepositorios);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $arrData = array();
    $version = $oRepositories->obtenerVersionDistro();
    $arch = $oRepositories->obtenerArquitectura();
    //   print($arch);
    if (is_array($arrRepositorios)) {
        for ($i = $offset; $i < $end; $i++) {
            $activo = "";
            if ($arrRepositorios[$i]['activo']) {
                $activo = "checked='checked'";
            }
            $arrData[] = array("<input {$activo} name='repo-" . $arrRepositorios[$i]['id'] . "' type='checkbox' id='repo-{$i}' />", $valor = str_replace(array("\$releasever", "\$basearch"), array($version, $arch), $arrRepositorios[$i]['name']));
        }
    }
    if (isset($typeRepository)) {
        $oGrid->setURL("?menu={$module_name}&typeRepository={$typeRepository}");
        $_POST["typeRepository"] = $typeRepository;
    } else {
        $oGrid->setURL("?menu={$module_name}");
        $_POST["typeRepository"] = "main";
    }
    $arrGrid = array("title" => $arrLang["Repositories"], "icon" => "modules/repositories/images/system_updates_repositories.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $arrLang["Active"], "property1" => ""), 1 => array("name" => $arrLang["Name"], "property1" => "")));
    $oGrid->customAction('submit_aceptar', _tr('Save/Update'));
    $oGrid->addButtonAction("default", _tr('Default'), null, "defaultValues({$total},'{$version}','{$arch}')");
    $FilterForm = new paloForm($smarty, createFilter());
    $arrOpt = array("main" => _tr('Main'), "others" => _tr('Others'), "all" => _tr('All'));
    if (isset($arrOpt[$typeRepository])) {
        $valorfiltro = $arrOpt[$typeRepository];
    } else {
        $valorfiltro = _tr('Main');
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Repo") . " = " . $valorfiltro, $_POST, array("typeRepository" => "main"), true);
    $htmlFilter = $FilterForm->fetchForm("{$local_templates_dir}/new.tpl", "", $_POST);
    $oGrid->showFilter($htmlFilter);
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}
Example #22
0
function report_TicketDelivery($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $img_dir = "modules/{$module_name}/images/";
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Yêu cầu giao vé");
    $oGrid->setTableName("delivery_grid");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("ticket_delivery");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Vé đính kèm", "Ngày nhận tiền", "Xử lý", "Chi tiết", " ");
    $oGrid->setColumns($arrColumns);
    $total = $pTicket_Delivery->getNumTicket_Delivery($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pTicket_Delivery->getTicket_Delivery($limit, $offset, $filter);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            // show files
            $download = '';
            foreach ($value['ticket_attachment'] as $row) {
                $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
                $filename = $row['filename'];
                $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
            }
            $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
            $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '
            <a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
            $print .= '&nbsp;&nbsp;' . $enable;
            // function show base on status
            if ($value['isActive'] == '0') {
                $value['status'] = 'Đã hủy';
            }
            switch ($value['status']) {
                case 'Mới':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                case 'Đang giao':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
                    break;
                case 'Đã nhận tiền':
                    $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
                    break;
                case 'Chờ xử lý':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                default:
                    $function = '';
            }
            // show ticket code
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = '<span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span>';
            $arrTmp[4] = '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a>';
            $arrTmp[5] = $value['pay_amount'];
            $arrTmp[6] = $ticket;
            $arrTmp[7] = showStatus($value['status']);
            $arrTmp[8] = $value['delivery_name'];
            $arrTmp[9] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[10] = $download;
            $arrTmp[11] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[12] = $function;
            $arrTmp[13] = '<a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a>';
            $arrTmp[14] = $print;
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Example #23
0
function view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, $update = FALSE)
{
    $arrFormadress_book = createFieldForm($pDB);
    $padress_book = new paloAdressBook($pDB);
    $oForm = new paloForm($smarty, $arrFormadress_book);
    $id = getParameter('id');
    if (isset($_POST["edit"]) || $update == TRUE) {
        $oForm->setEditMode();
        $smarty->assign("Commit", 1);
        $smarty->assign("SAVE", "Sửa");
    } else {
        $oForm->setViewMode();
        $smarty->assign("Edit", 1);
    }
    $smarty->assign("icon", "modules/{$module_name}/images/address_book.png");
    $smarty->assign("EDIT", "Sửa");
    $smarty->assign("title", "Thông tin khách hàng");
    $smarty->assign("SAVE", "Lưu");
    $smarty->assign("CANCEL", "Đóng");
    $smarty->assign("REQUIRED_FIELD", "Bắt buộc");
    $contactData = $padress_book->contactData($id);
    if ($contactData) {
        $smarty->assign("ID", $id);
    } else {
        $smarty->assign("mb_title", "Lỗi");
        $smarty->assign("mb_message", 'Không cho phép xem');
        return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk);
    }
    if ($contactData['type'] == '0') {
        $smarty->assign("check_0", "checked");
    } elseif ($contactData['type'] == '1') {
        $smarty->assign("check_1", "checked");
    } elseif ($contactData['type'] == '2') {
        $smarty->assign("check_2", "checked");
    } else {
        $smarty->assign("check_3", "checked");
    }
    // get contact list to show in smarty
    $smarty->assign("CONTACT", $contactData['contact']);
    // get phone list
    foreach ($contactData['number'] as $v) {
        $arr_phone .= $v . "\n";
    }
    $arrData['firstname'] = $contactData['firstname'];
    $arrData['lastname'] = $contactData['lastname'];
    $arrData['company'] = $contactData['company'];
    $arrData['email'] = $contactData['email'];
    $arrData['cmnd'] = $contactData['cmnd'];
    $arrData['passport'] = $contactData['passport'];
    $arrData['birthday'] = date("d-m-Y", strtotime($contactData['birthday']));
    $arrData['birthplace'] = $contactData['birthplace'];
    $arrData['address'] = $contactData['address'];
    $arrData['membership'] = $contactData['membership'];
    $arrData['sale'] = $contactData['sale'];
    $arrData['booker'] = $contactData['agent_id'];
    $arrData['accountant'] = $contactData['accountant'];
    $arrData['payment_type'] = $contactData['payment_type'];
    $arrData['customer_code'] = $contactData['customer_code'];
    // for company customer
    $arrData['company_name'] = $contactData['firstname'];
    $arrData['company_booker'] = $contactData['agent_id'];
    $arrData['company_code'] = $contactData['customer_code'];
    $arrData['company_pay_type'] = $contactData['payment_type'];
    $arrData['company_sale'] = $contactData['sale'];
    $arrData['company_accountant'] = $contactData['accountant'];
    $arrData['company_address'] = $contactData['address'];
    $arrData['company_membership'] = $contactData['membership'];
    $arrData['phone'] = $arr_phone;
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new_adress_book.tpl", "Thông tin khách hàng", $arrData);
    $contenidoModulo = "<form  method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $contenidoModulo;
}
Example #24
0
function viewFormControlPanel($smarty, $module_name, $local_templates_dir, &$pDB1, &$pDB2, $arrConf, $arrLang)
{
    $pControlPanel = new paloSantoControlPanel($pDB1, $pDB2);
    $oForm = new paloForm($smarty, array());
    $arrDevices = $pControlPanel->getAllDevicesARRAY();
    $arrAreas = $pControlPanel->getDesignArea();
    //  $arrQueues  = $pControlPanel->getAllQueuesARRAY2();
    //$arrDAHDITrunks  = $pControlPanel->getDAHDITrunksARRAY();
    //  $arrSIPTrunks = $pControlPanel->getSIPTrunksARRAY();
    //  $arrConferences = $pControlPanel->getConferences();
    $session = getSession();
    if (isset($session['operator_panel'])) {
        unset($session['operator_panel']);
        putSession($session);
    }
    $smarty->assign("module_name", $module_name);
    $smarty->assign("icon", "/modules/{$module_name}/images/pbx_operator_panel.png");
    $smarty->assign("arrDevicesExten", isset($arrDevices[1]) ? $arrDevices[1] : null);
    $smarty->assign("arrDevicesArea1", isset($arrDevices[2]) ? $arrDevices[2] : null);
    $smarty->assign("arrDevicesArea2", isset($arrDevices[3]) ? $arrDevices[3] : null);
    $smarty->assign("arrDevicesArea3", isset($arrDevices[4]) ? $arrDevices[4] : null);
    $smarty->assign("lengthExten", isset($arrDevices[1]) ? count($arrDevices[1]) : null);
    $smarty->assign("lengthArea2", isset($arrDevices[2]) ? count($arrDevices[2]) : null);
    $smarty->assign("lengthArea3", isset($arrDevices[3]) ? count($arrDevices[3]) : null);
    $smarty->assign("lengthArea4", isset($arrDevices[4]) ? count($arrDevices[4]) : null);
    /*  $smarty->assign("arrQueues", isset($arrQueues)?$arrQueues:null);
       // $smarty->assign("arrTrunks", $arrDAHDITrunks);
        $smarty->assign("lengthQueues", isset($arrQueues)?count($arrQueues):null);
       // $smarty->assign("lengthTrunks", isset($arrDAHDITrunks)?count($arrDAHDITrunks):null);
      //  $smarty->assign("lengthTrunksSIP", isset($arrSIPTrunks)?count($arrSIPTrunks):null);
       // $smarty->assign("arrTrunksSIP", $arrSIPTrunks);
        $smarty->assign("arrConferences", $arrConferences);
        $smarty->assign("lengthConferences", isset($arrConferences)?count($arrConferences):null);*/
    $i = 1;
    foreach ($arrAreas as $key => $value) {
        $smarty->assign("nameA{$i}", $value['a.name']);
        $smarty->assign("descripArea{$i}", $value['a.description']);
        $smarty->assign("height{$i}", $value['a.height']);
        $smarty->assign("width{$i}", $value['a.width']);
        $smarty->assign("size{$i}", $value['a.no_column']);
        $i++;
    }
    //New Feauters
    $totalQueues = 0;
    $arrNumQueues = $pControlPanel->getAsterisk_QueueInfo();
    foreach ($arrNumQueues as $key => $value) {
        $totalQueues += $value;
    }
    $smarty->assign("total_queues", $totalQueues);
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", $arrLang["Control Panel"], $_POST);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Example #25
0
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;
}
Example #26
0
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);
}
Example #27
0
function listPackages($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $oPackages = new PaloSantoPackages($arrConf['ruta_yum']);
    $submitInstalado = getParameter('submitInstalado');
    $nombre_paquete = getParameter('nombre_paquete');
    $smarty->assign(array('module_name' => $module_name, 'RepositoriesUpdate' => _tr('Repositories Update'), 'Search' => _tr('Search'), 'UpdatingRepositories' => _tr('Updating Repositories'), 'InstallPackage' => _tr('Installing Package'), 'UpdatePackage' => _tr('Updating Package'), 'accionEnProceso' => _tr('There is an action in process'), 'msgConfirmDelete' => _tr('You will uninstall package along with everything what it depends on it. System can lose important functionalities or become unstable! Are you sure want to Uninstall?'), 'msgConfirmInstall' => _tr('Are you sure want to Install this package?'), 'UninstallPackage' => _tr('Uninstalling Package'), 'msgConfirmUpdate' => _tr('Are you sure want to Update this package?')));
    $arrPaquetes = $oPackages->listarPaquetes($submitInstalado == 'all' ? 'all' : 'installed', $nombre_paquete);
    if ($oPackages->bActualizar) {
        $smarty->assign("mb_title", _tr("Message"));
        $smarty->assign("mb_message", _tr("The repositories are not up to date. Click on the") . " <b>\"" . _tr('Repositories Update') . "\"</b> " . _tr("button to list all available packages."));
    }
    // Pagination
    $limit = 20;
    $total = count($arrPaquetes);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $arrPaquetes = array_slice($arrPaquetes, $offset, $limit);
    $arrData = array();
    foreach ($arrPaquetes as $paquete) {
        $packageActions = array();
        $tmpPaquete = $paquete['name'] . '.' . $paquete['arch'];
        if ($paquete['canupdate']) {
            $packageActions[] = "<a href='#'  onclick=" . "confirmUpdate('{$tmpPaquete}')" . ">[" . _tr('Update') . "]</a>";
        }
        if (is_null($paquete['version'])) {
            $packageActions[] = "<a href='#'  onclick=" . "installaPackage('{$tmpPaquete}',0)" . ">[" . _tr('Install') . "]</a>";
        } else {
            $packageActions[] = "<a href='#'  onclick=" . "confirmDelete('{$tmpPaquete}')" . ">[" . _tr('Uninstall') . "]</a>";
        }
        $rowData = array($paquete['name'], $paquete['arch'], $paquete['summary'], is_null($paquete['version']) ? _tr('(not installed)') : $paquete['version'] . '-' . $paquete['release'], is_null($paquete['latestversion']) ? _tr('(not available)') : $paquete['latestversion'] . '-' . $paquete['latestrelease'], $paquete['repo'], implode('&nbsp;', $packageActions));
        if ($paquete['canupdate']) {
            $rowData[0] = '<b>' . $rowData[0] . '</b>';
            $rowData[4] = '<b>' . $rowData[4] . '</b>';
        }
        $arrData[] = $rowData;
    }
    $url = array('menu' => $module_name, 'submitInstalado' => $submitInstalado, 'nombre_paquete' => $nombre_paquete);
    $arrGrid = array("title" => _tr('Packages'), "icon" => "web/apps/{$module_name}/images/system_updates_packages.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(array("name" => _tr("Package Name")), array("name" => _tr("Architecture")), array("name" => _tr("Package Info")), array('name' => _tr('Current Version')), array('name' => _tr('Available Version')), array("name" => _tr("Repositor Place")), array("name" => _tr("Status"))));
    /*Inicio Parte del Filtro*/
    $arrFilter = filterField();
    $oFilterForm = new paloForm($smarty, $arrFilter);
    if (getParameter('submitInstalado') == 'all') {
        $arrFilter["submitInstalado"] = 'all';
        $tipoPaquete = _tr('All Package');
    } else {
        $arrFilter["submitInstalado"] = 'installed';
        $tipoPaquete = _tr('Package Installed');
    }
    $arrFilter["nombre_paquete"] = $nombre_paquete;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Status") . " =  {$tipoPaquete}", $arrFilter, array("submitInstalado" => "installed"), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = {$nombre_paquete}", $arrFilter, array("nombre_paquete" => ""));
    $oGrid->addButtonAction('update_repositorios', _tr('Repositories Update'), null, 'mostrarReloj()');
    $oGrid->showFilter($oFilterForm->fetchForm("{$local_templates_dir}/new.tpl", '', $arrFilter));
    return $oGrid->fetchGrid($arrGrid, $arrData);
}
Example #28
0
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;
    }
}
Example #29
0
function modificarArchivo($module_name, $smarty, $local_templates_dir, $sDirectorio, $sAccion)
{
    $sNombreArchivo = '';
    $sMensajeStatus = '';
    if (isset($_POST['Reload'])) {
        $parameters = array('Command' => "module reload");
        $result = AsteriskManagerAPI("Command", $parameters, true);
        if ($result) {
            $smarty->assign("mb_title", "MESSAGE");
            $smarty->assign("mb_message", _tr("Asterisk has been reloaded"));
        } else {
            $smarty->assign("mb_title", "ERROR");
            $smarty->assign("mb_message", _tr("Error when connecting to Asterisk Manager"));
        }
    }
    if ($sAccion == 'new') {
        $smarty->assign('LABEL_COMPLETADO', '.conf');
        if (isset($_POST['Guardar'])) {
            if (!isset($_POST['basename']) || trim($_POST['basename']) == '') {
                $sMensajeStatus .= _tr('Please write the file name') . '<br/>';
            } else {
                $sNombreArchivo = basename($_POST['basename'] . '.conf');
                /* Los datos del archivo se envían desde el navegador con líneas
                     separadas por CRLF que debe ser convertido a LF para estilo Unix
                   */
                if (file_put_contents($sDirectorio . $sNombreArchivo, str_replace("\r\n", "\n", $_POST['content'])) === FALSE) {
                    $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>';
                } else {
                    $sMensajeStatus .= _tr("The changes was saved in the file") . '<br/>';
                }
            }
        }
    } elseif ($sAccion == 'edit') {
        $sNombreArchivo = basename(getParameter('file'));
        if (is_null($sNombreArchivo) || !file_exists($sDirectorio . $sNombreArchivo)) {
            Header("Location: ?menu={$module_name}");
            return '';
        }
        if (isset($_POST['Guardar'])) {
            /* Los datos del archivo se envían desde el navegador con líneas
                 separadas por CRLF que debe ser convertido a LF para estilo Unix
               */
            if (!is_writable($sDirectorio . $sNombreArchivo) || file_put_contents($sDirectorio . $sNombreArchivo, str_replace("\r\n", "\n", $_POST['content'])) === FALSE) {
                $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>';
            } else {
                $sMensajeStatus .= _tr("The changes was saved in the file") . '<br/>';
            }
        } else {
            if (!is_writable($sDirectorio . $sNombreArchivo)) {
                $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>';
            }
        }
        $sContenido = file_get_contents($sDirectorio . $sNombreArchivo);
        if ($sContenido === FALSE) {
            $sMensajeStatus .= _tr("This file doesn't have permisses to read") . '<br/>';
        }
        if (!isset($_POST['content'])) {
            $_POST['content'] = $sContenido;
        }
        $_POST['basename'] = basename($sNombreArchivo);
    }
    $oForm = new paloForm($smarty, array('basename' => array('LABEL' => _tr('File'), 'REQUIRED' => 'yes', 'INPUT_TYPE' => 'TEXT', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => '', 'EDITABLE' => $sAccion == 'new' ? 'yes' : 'no'), 'content' => array('LABEL' => _tr('Content'), 'REQUIRED' => 'no', 'INPUT_TYPE' => 'TEXTAREA', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => '', 'ROWS' => 25, 'COLS' => 100)));
    $oForm->setEditMode();
    $smarty->assign('url_edit', construirURL(array('menu' => $module_name, 'action' => $sAccion, 'file' => $sNombreArchivo)));
    $smarty->assign('url_back', construirURL(array('menu' => $module_name), array('action', 'file', 'nav' => getParameter('nav'), 'page' => getParameter('page'))));
    $smarty->assign('search', getParameter('search'));
    $smarty->assign('LABEL_SAVE', _tr('Save'));
    $smarty->assign('RELOAD_ASTERISK', _tr('Reload Asterisk'));
    $smarty->assign('LABEL_BACK', _tr('Back'));
    $smarty->assign('msg_status', $sMensajeStatus);
    $smarty->assign('icon', "images/user.png");
    return $oForm->fetchForm("{$local_templates_dir}/file_editor.tpl", _tr("File Editor"), $_POST);
}
Example #30
0
function viewFormTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $arrItems = array())
{
    global $arrPermission;
    $error = "";
    $arrTG = array();
    $action = getParameter("action");
    $idTG = getParameter("id_tg");
    if ($action == "edit" || getParameter("save_edit")) {
        if (!isset($idTG)) {
            $error = _tr("Invalid Time Group");
        } else {
            $domain = getParameter('organization');
            if ($credentials['userlevel'] != 'superadmin') {
                $domain = $credentials['domain'];
            }
            $pTG = new paloSantoTG($pDB, $domain);
            $arrTG = $pTG->getTGById($idTG);
            if ($arrTG === false) {
                $error = _tr($pTG->errMsg);
            } else {
                if (count($arrTG) == 0) {
                    $error = _tr("TG doesn't exist");
                } else {
                    $smarty->assign('j', 0);
                    if (getParameter("save_edit")) {
                        $arrTG = $_POST;
                    }
                    if ($action == "edit") {
                        $pTG->getParametersTG($idTG, $smarty);
                    }
                }
            }
        }
        if ($error != "") {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", $error);
            return reportTG($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    } else {
        if ($credentials['userlevel'] == 'superadmin') {
            if (getParameter("create_tg")) {
                $domain = getParameter('organization_add');
                //este parametro solo es selecionable cuando es el superadmin quien crea la ruta
            } else {
                $domain = getParameter('organization');
            }
        } else {
            $domain = $credentials['domain'];
        }
        $pTG = new paloSantoTG($pDB, $domain);
        $smarty->assign('j', 1);
        if (getParameter("create_tg")) {
            $smarty->assign('j', 1);
            $smarty->assign('arrItems', $arrItems);
        } else {
            $smarty->assign('j', 0);
            $arrTG = $_POST;
        }
    }
    $arrForm = createFieldForm($smarty);
    $oForm = new paloForm($smarty, $arrForm);
    if ($action == "edit" || getParameter("save_edit")) {
        $oForm->setEditMode();
    }
    //permission
    $smarty->assign("EDIT_TG", in_array('edit', $arrPermission));
    $smarty->assign("CREATE_TG", in_array('create', $arrPermission));
    $smarty->assign("DEL_TG", in_array('delete', $arrPermission));
    //$smarty->assign("ERROREXT",_tr($pTrunk->errMsg));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("OPTIONS", _tr("Options"));
    $smarty->assign("APPLY_CHANGES", _tr("Apply changes"));
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("DELETE", _tr("Delete"));
    $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?"));
    $smarty->assign("MODULE_NAME", $module_name);
    $smarty->assign("id_tg", $idTG);
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain"));
    $smarty->assign("ORGANIZATION", $domain);
    $smarty->assign("ADD_GROUP", _tr("Add Conditions"));
    $smarty->assign("DELETE_GROUP", _tr("Delete Conditions"));
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("TG Route"), $arrTG);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}