Example #1
0
function preview_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm, $arrConf, $arrValoresGestionAnterior)
{
    require_once "/var/lib/asterisk/agi-bin/phpagi-asmanager.php";
    $oForm->setViewMode();
    // Esto es para activar el modo "preview"
    $pInterfazdeAgente = new paloSantoInterfazdeAgente($pDB);
    $iNumForm = $pInterfazdeAgente->getForm($_SESSION['id_campania']);
    $pDBsqlite = new paloDB("sqlite3:////var/www/db/acl.db");
    $pInterfazdeAgenteSqlite = new paloSantoInterfazdeAgente($pDBsqlite);
    $extensionAgente = $pInterfazdeAgenteSqlite->getExtensionAgente($_SESSION['elastix_user']);
    if (isset($_GET['telefono'])) {
        // si el telefono viene en la barra de direccion
        $destinatario = $_GET['telefono'];
    }
    if (!isset($iNumForm) || !is_numeric($iNumForm)) {
        return false;
    }
    $oDataForm = new paloSantoDataForm($pDB);
    $arrDataForm = $oDataForm->getFormularios($iNumForm);
    if (is_array($arrValoresGestionAnterior)) {
        $arrFieldForm = $oDataForm->obtener_campos_formulario($iNumForm, NULL, $_SESSION['telefono'], $_SESSION, $arrValoresGestionAnterior);
        // envío arreglo $_GET
    } else {
        $arrFieldForm = $oDataForm->obtener_campos_formulario($iNumForm, NULL, $_SESSION['telefono'], $_SESSION);
    }
    $smarty->assign("id_formulario_actual", $iNumForm);
    $smarty->assign("style_field", "style='display:none;'");
    $smarty->assign("formulario", $arrFieldForm);
    if (isset($destinatario) && $destinatario != "") {
        // si hay telefono seteado llamar al numero
        $astman = new AGI_AsteriskManager();
        if (!$astman->connect($arrConf['asterisk_host'], $arrConf['asterisk_user'], $arrConf['asterisk_pass'])) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("No es posible conectarse a la PBX."));
        } else {
            $result = $astman->Originate("Local/{$extensionAgente}@from-internal", $extensionAgente, "hispana-callcenter", 1, null, null, null, null, "DEST={$destinatario}", null);
        }
    }
    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/preview.tpl", _tr('Gestión de clientes'));
    // hay que pasar el arreglo
    return $contenidoModulo;
}