<?php
    require 'common.php';
    $r = new response();
    if(check_call_end($r) === false)
    {
        if ($_REQUEST['event'] == 'GotDTMF')
        {
            $option = '0';
            if(isset($_REQUEST['data']))
            {
                $option = $_REQUEST['data'];
            }
            error_log("option-exit_menu:".$option);
            if(array_key_exists($option, $exit_menu_codes))
            {
                process_exit_menu($r, $option);
            }
            else
            {
                handle_step_repeat($r, 'exit_menu_error_count', $MAX_REPEAT_COUNT, 'exit_menu.php', 'hangup.php', array(), array());
            }
        }
        $r->send();
    }

    function process_exit_menu($r,$option)
    {
        global $APP_BASE_URL;
        global $exit_menu_codes;

        $_SESSION["selected_exit_menu"]=$exit_menu_codes[$option];
        unset($_SESSION['exit_menu_error_count']);
        //add_step($exit_menu_codes[$option]);
        $r->addGoto($APP_BASE_URL."/process_exit_menu.php");
    }
?>