<?php
header
('Cache-Control: no-cache');
echo (
'<?xml version="1.0" encoding="UTF-8" ?>');
?>
<vxml version="2.0">
<?
    
require_once("saprfc.php");
    
    
$sap = new saprfc(array(
                        
"logindata"=>array(
                            
"ASHOST"=>"nw04shost"        // application server
                            
,"SYSNR"=>"00"                // system number
                            
,"CLIENT"=>"000"            // client
                            
,"USER"=>"bcuser"            // user
                            
,"PASSWD"=>"minisap"        // password
                            
)
                        ,
"show_errors"=>false            // let class printout errors
                        
,"debug"=>false)) ;                 // detailed debugging information

    
$result=$sap->callFunction("SO_USER_LIST_READ",
                                array(    array(
"IMPORT","USER_GENERIC_NAME","*"),
                                        array(
"TABLE","USER_DISPLAY_TAB",array())
                                ));                                 
                
    if (
$sap->getStatus() == SAPRFC_OK) {
        
$i=1;
        
$grammar_file "";

        foreach (
$result["USER_DISPLAY_TAB"] as $user) {
         
          if(
$i count($result["USER_DISPLAY_TAB"]))
            { 
              
$grammar_file.=$user["SAPNAM"]." | ";    
            } 
        else {
            
$grammar_file.=$user["SAPNAM"] ;
            }

            
$i++;
        }
    } else { 
        
$sap->printStatus();
    }
    
$sap->logoff();
?>

 <form id="main">
    <catch event="help nomatch noinput">
        I'm sorry, Could you repeat that? 
    </catch>
  <field name="sapuser">
      <grammar>
    <![CDATA[
        #JSGF V1.0;
            grammar sapuser;
            public <sapuser> = <?=$grammar_file?>;
    ]]>
    </grammar>

    <prompt>
          Welcome to Victoria University SAP Voice system.
    Please, tell us your logon name.
    </prompt>

     <filled>
     <goto nextitem="confirm"/>
     </filled>

  </field>

  <field name="confirm">
   <grammar xml:lang="en-US" root = "TOPLEVEL" mode="voice">
    <rule id="TOPLEVEL" scope="public">
        <one-of lang-list="en-US">
          <item> yes <tag> <![CDATA[  <confirm "yes"> ]]>  </tag> </item>
          <item> yeah <tag> <![CDATA[  <confirm "yes"> ]]>  </tag> </item>
          <item> yup <tag> <![CDATA[  <confirm "yes"> ]]>  </tag> </item>
          <item> no <tag> <![CDATA[  <confirm "no"> ]]>  </tag> </item>
          <item> nah <tag> <![CDATA[  <confirm "no"> ]]>  </tag> </item>
          <item> nope <tag> <![CDATA[  <confirm "no"> ]]>  </tag> </item>
        </one-of>
    </rule>
   </grammar>

   <prompt>
    You said, <value expr="sapuser$.utterance"/>.  
    Is this correct?
   </prompt>

     <filled>
       <if cond="confirm == 'yes'">
        Thank you,  <value expr="sapuser$.utterance"/>. 
        Now, You are in the Victoria University SAP Voice System.
        We will hangup the call soon.  
        <exit/>
       <elseif cond="confirm == 'no'"/>
          What! 
          What! 
          I told you to speak loudly. 
          hey, Try it again. 
       <goto nextitem="sapuser"/>
       <clear namelist="confirm sapuser"/>
       </if>
     </filled>

  </field>
 </form>

</vxml>