Changeset 7164

Show
Ignore:
Timestamp:
10/27/08 23:19:15 (5 years ago)
Author:
xrobau
Message:

Commit to show phillipel..

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/cidroute/agi-bin/cidoverride.agi

    r7163 r7164  
    4040/*  
    4141  Overview of the CIDoverride AGI 
    42     * Grab the ID of this call. 
    43     * Get the previous calls CallerID (DB->Exten/CallTrace) 
    44     * Check to make sure it's not an internal call  
     42    * Grab the ID of this call. (Done) 
     43    * Get the previous calls CallerID (DB->Exten/CallTrace) (Done) 
     44    * Check to make sure it's not an internal call (Done) 
    4545    * Say "The previous call from (number) was not found/was found in (tts->localarea) 
    4646    * Say "This call would be sent to (tts->cidroute_matches.name)/would be ignored" 
     
    9797  } 
    9898} 
     99 
     100// Begin! 
    99101$res = sql("select count(*) from users,devices where users.extension=".$cidnum['data']." or devices.id=".$cidnum['data'], "getRow"); 
    100102if ($res[0] != 0) { 
     
    107109$q = "select state,region,localarea from cidroute_cidlist where '{$cidnum['data']}' >= min_numb and '{$cidnum['data']}' <= max_numb"; 
    108110$res = sql($q, "getRow",DB_FETCHMODE_ASSOC); 
     111// If it is.. 
    109112if (is_array($res) && isset($res['state'])) { 
    110113  debug("Found State:".$res['state'].", Region:".$res['region']." LocalArea:".$res['localarea'], 3); 
    111   $saystr = "<prosody rate='medium'> This number is in the state of "; 
     114  $saystr = "This number is in the state: "; 
    112115  $tmp = str_split($res['state']); 
    113   foreach ($tmp as $char) { $saystr .= $char." "; } 
    114   $saystr .= ". The region is ".$res['region'].".  The local area is called "; 
    115   $saystr .= $res['localarea']."</prosody>"; 
    116   $saystr .= ". If you would like me to repeat that, press star. If you would like me to spell that, press 1. "; 
     116  foreach ($tmp as $char) { $saystr .= strtolower($char." "); } 
     117  $saystr .= ". The region is: ".$res['region'].".  The local area is called: ".$res['localarea']; 
     118  $saystr .= ": If you would like me to repeat that, press star. If you would like me to spell that, press 1. "; 
    117119  $saystr .= "To continue, press hash. Press any other key to hang up."; 
    118   $check = say($saystr); 
    119   if ($check == null) { 
    120     $readkey=$AGI->wait_for_digit(5000); 
    121     if ($readkey['result'] == 0) { 
    122       $check = null; 
    123     } else { 
    124       $check = chr($readkey['result']); 
    125     } 
    126   }  
     120  $check = say_and_get($saystr); 
    127121  if ($check == "1") { 
    128122    say_regions($res['state'], $res['region'], $res['localarea']); 
     
    132126    exit; 
    133127  } 
     128  $dest = select_destination(); 
     129  $check = say_and_get("If you would like to alter just this number, press 1. If you would like to alter the entire range, press 2"); 
     130  if ($check == "1") { 
     131    // This function exits; when finished. 
     132    add_override($dest,$cidnum['data']); 
     133  } elseif ($check == "2") { 
     134    // This function exits; when finished. 
     135    modify_range($dest,$cidnum['data']); 
     136  } 
    134137   
    135   say("OK, we're off and running then."); 
    136 
     138} else { 
     139  // It's not in a previously known range, so warn and add the number. 
     140
     141 
     142say("OK, we're off and running then."); 
    137143 
    138144 
    139145exit; 
    140146 
    141  
    142  
    143  
    144  
    145  
    146 $q = "select distinct(localarea) from cidroute_cidlist order by RAND() limit 10"; 
    147 $res = sql($q, "getAll"); 
    148 $str = "Begin. "; 
    149 foreach ($res as $r) { 
    150   $str .= ", ".$r[0]; 
    151   } 
    152 $AGI->exec("swift", '"'.$str.'"'); 
    153 exit; 
     147// Various Functions below here.. 
     148 
     149function add_override($ 
     150 
     151function select_destination() { 
     152  global $db; 
     153  global $AGI; 
     154 
     155  // 8 or less destinations.. 
     156  $multiple = false; 
     157 
     158  // Get the list of destinations from cidroute_dests 
     159  $count = sql("select count(name) from cidroute_dests","getRow"); 
     160  if ($count[0] == 0) { 
     161    say("Sorry, there doesn't seem to be any desinations created. Please add these via the web page."); 
     162    exit; 
     163  } 
     164  if ($count[0] > 8) { 
     165    say("More than 8 destinations have been selected. Use 7 and 9 to move backwards and forwards."); 
     166    $multiple = true; 
     167  } 
     168 
     169  // Grab the list of the destinations 
     170  $data = sql("select destid, name from cidroute_dests", "getAll"); 
     171  $saystr="Please select the destination. "; 
     172  if (!$multiple) { 
     173    for ($i=0; $i <= count($data); $i++) { 
     174      $saystr .= "Press $i for site ".$data[$i][1].". "; 
     175    } 
     176    $res = say_and_get($saystr); 
     177    say("You selected $res, which is ".$data[$res][1]); 
     178  } else { 
     179     //Multiple. Need to care about pointers! 
     180    // Start at zero. 
     181    $pointer = 0; 
     182    // Yes, PHP's lack of gotos DOES INDEED suck. 
     183    $loop = true; 
     184    while ($loop == true) { 
     185      $loop = false; 
     186      $saystr="Please select the destination. "; 
     187      for ($i=$pointer; $i <= count($data) && $i <= $pointer+8; $i++) { 
     188        $saystr .= "Press $i for site ".$data[$i][1].". "; 
     189      } 
     190      if ($pointer >= 8 && isset($) 
     191        $saystr .= "Press   
     192       
     193
     194     
     195 
    154196   
    155  
    156 // Various Functions below here.. 
     197   
    157198function say_regions($state, $region, $area) { 
    158199  global $AGI; 
     
    166207    say("The area is..."); 
    167208    $AGI->say_phonetic($area, "#"); 
    168     $check = say("Press 1 to repeat, or hash to continue"); 
    169     if ($check == null) { 
     209    $check = say_and_get("Press 1 to repeat, or hash to continue"); 
     210    print_r($check); 
     211    if ($check != "#") { 
     212      $repeat = true; 
     213    } 
     214  } 
     215
     216     
     217 
     218 
     219function say_and_get($str) { 
     220  global $AGI; 
     221  $repeat = true; 
     222  while ($repeat == true) { 
     223    $repeat = false; 
     224    $res = say($str); 
     225    print_r($res); 
     226    if ($res == null) { 
    170227      $readkey=$AGI->wait_for_digit(5000); 
    171228      if ($readkey['result'] == 0) { 
    172229        $repeat = true; 
    173230      } else { 
    174         $check = chr($readkey['result']); 
     231        $val = chr($readkey['result']); 
    175232      } 
    176     }  
    177     if ($check != "#") { 
    178     $repeat = true; 
    179   } 
     233    } else { 
     234    $val = $res; 
     235    } 
     236  return $val; 
    180237  } 
    181238} 
    182239     
    183  
    184240 
    185241// 'say' takes a string and says it! If you push '*' it will repeat. If you push anything else, 
     
    195251  while ($repeat == true) { 
    196252    $repeat = false; 
     253    // For some reason, phpagi is sending back the character I pushed.  Putting a Noop here 
     254    // fixes it, but there is a bug somewhere.  FIXME 
     255    // AGI Rx << WAIT FOR DIGIT 5000 
     256    // AGI Tx >> 200 result=35 
     257    // AGI Rx << #NOOP    <-- Here, there is # before NOOP. 
     258    // AGI Tx >> 510 Invalid or unknown command 
     259 
     260    $AGI->noop("Null"); 
    197261    $AGI->set_variable("SWIFT_DTMF", "unset"); 
    198262    $AGI->exec("swift", '"'.$str.'"');