Changeset 7168
- Timestamp:
- 10/28/08 03:54:57 (5 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/cidroute/agi-bin/cidoverride.agi
r7167 r7168 40 40 /* 41 41 Overview of the CIDoverride AGI 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)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 45 45 * Say "The previous call from (number) was not found/was found in (tts->localarea) 46 46 * Say "This call would be sent to (tts->cidroute_matches.name)/would be ignored" 47 * Say "To update this, press 1." 47 * Say "To update this, press 1." (Changed this.. I'll get user feedback on what they prefer) 48 48 * If 1, then: 49 * If found in an existing group, 49 * If found in an existing group, 50 50 * prompt to send all numbers in that group to the destination selected 51 51 * If yes, say number range … … 62 62 * Say Update Complete, Thank you, goodbye 63 63 64 * All complete! 65 66 64 67 */ 65 68 … … 79 82 debug("Searching for previous call to Exten '$cidnum' in lookup tables",2); 80 83 $cidnum = $AGI->database_get("CALLTRACE", $mynum); 81 $cidnum['data'] = 295461936;82 84 83 85 debug("Previous call was from '".$cidnum['data']."'",3); … … 112 114 if (is_array($res) && isset($res['state'])) { 113 115 debug("Found State:".$res['state'].", Region:".$res['region']." LocalArea:".$res['localarea'], 3); 114 $saystr = "This number is in the state: "; 115 $dest = select_destination(); 116 $saystr = "This number is in the state of: "; 116 117 $tmp = str_split($res['state']); 117 118 foreach ($tmp as $char) { $saystr .= strtolower($char." "); } … … 127 128 exit; 128 129 } 130 // select_destination() returns: 131 // Array(name => 'text name', id => cidroute_matches.destid) 129 132 $dest = select_destination(); 130 133 $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"); 131 134 if ($check == "1") { 132 // This function exits; when finished.133 135 add_override($dest,$cidnum['data']); 134 136 } elseif ($check == "2") { 135 // This function exits; when finished.136 137 modify_range($dest,$cidnum['data']); 137 138 } 138 139 139 } else { 140 // It's not in a previously known range, so warn and add the number.141 } 142 143 say("OK, we're off and running then."); 144 145 140 // A CallerID number NOT in the database. This means there's stuff missing from there. 141 say("The Caller ID number selected is not in the database. You can only add an override. Contact Support"); 142 add_override($dest,$cidnum['data']); 143 } 144 145 say ("Goodbye"); 146 146 exit; 147 147 148 148 149 // Various Functions below here.. 150 151 // Add an override for one specific number.. 152 // $dest = Arryay('id' => db.destid, 'name' => descriptive name of the match) 153 // $cid = caller id of call you want to change 154 function add_override($dest,$cid) { 155 global $AGI; 156 157 say("To confirm that you want to send only the caller ID number"); 158 $AGI->say_digits($cid); 159 $saystr = "to ".$dest['name'].", you must push 5. Any other button will abort. Changes will happen immediately"; 160 $res = say_and_get($saystr); 161 if ($res == "5") { 162 $q = "delete from cidroute_override where number='".$cid."'", "query"); 163 sql("insert into cidroute_override (name, number, dest) values ('Via Phone', $cid, ".$dest['id'].")", "query"); 164 } 165 say("Update complete. Goodbye."); 166 } 167 168 // Add an override for a range of numbers 169 // $dest = Arryay('id' => db.destid, 'name' => descriptive name of the match) 170 // $cid = caller id of call you want to change 171 function modify_range($dest,$cid) { 172 global $db; 173 global $AGI; 174 // We already check to make sure that this is part of a range, so we just need to grab the range 175 $q = "select localarea,min_numb,max_numb from cidroute_cidlist where '$cid' >= min_numb and '$cid' <= max_numb"; 176 $res = sql($q, "getRow",DB_FETCHMODE_ASSOC); 177 if (!isset($res['min_numb'])) { 178 // The database said one thing 50msec ago, and something else now. Panic. 179 say("Severe Error Occured. Attemped to add a range that does not exist. Goodbye."); 180 exit; 181 } 182 $min_numb = $res['min_numb']; 183 $max_numb = $res['max_numb']; 184 $localarea = $res['localarea']; 185 186 // Check to make sure it's not already assigned to some place else. 187 $q = "select min_numb,dest from cidroute_matches where min_numb='$min_numb'"; 188 $check = sql($q, "getRow", DB_FETCHMODE_ASSOC); 189 190 if (isset($check['min_numb'])) { 191 // It _IS_ assigned to someone else. 192 $prevdest = sql("select name,destid from cidroute_dests where destid='".$check['dest']."'", "getRow"); 193 $confirm = say_and_get("This range is already assigned to: ".$prevdest[0].": If you are sure you wish to alter this, press 2 now"); 194 if ($confirm != "2") { 195 say("Change Aborted. Goodbye."); 196 exit; 197 } 198 } 199 say("To confirm that you want to send the caller ID range from"); 200 $AGI->say_digits($min_numb); 201 say("to"); 202 $AGI->say_digits($max_numb); 203 $saystr = "which is part of the area: ".$localarea.", to: ".$dest['name'].": you must push 5. Any other button will abort. "; 204 $saystr .= "Changes will happen immediately."; 205 $res = say($saystr); 206 if ($res == "5") { 207 sql("delete from cidroute_matches where min_numb='$min_numb' and max_numb='$max_numb'", "query"); 208 $q = "insert into cidroute_matches (name, country, areacode, min_numb, max_numb, dest) values "; 209 $q .= "('Via Phone', 'au', 99, '$min_numb', '$max_numb', '".$dest['id']."')"; 210 sql($q, "query"); 211 say("Update complete. Goodbye."); 212 exit; 213 } else { 214 say("Change Aborted. Goodbye."); 215 exit; 216 } 217 } 218 149 219 150 220 function select_destination() { … … 165 235 } 166 236 167 $saystr="Please select the destination . ".count($data);237 $saystr="Please select the destination for this number. ".count($data); 168 238 if (!$multiple) { 169 239 while (1) { … … 178 248 break; 179 249 } 180 say("You selected $res, which is ".$data[$res][1]);181 250 } else { 182 251 //Multiple. Need to care about pointers! … … 218 287 } 219 288 } 220 say("You selected ".$data[$res+$pointer][1]); 221 } 222 } 223 224 225 226 289 } 290 return(Array('name' => $data[$res+$pointer][1], 'id' => $res+$pointer)); 291 } 292 227 293 function say_regions($state, $region, $area) { 228 294 global $AGI; … … 237 303 $AGI->say_phonetic($area, "#"); 238 304 $check = say_and_get("Press 1 to repeat, or hash to continue"); 239 print_r($check);240 305 if ($check != "#") { 241 306 $repeat = true; … … 243 308 } 244 309 } 245 246 310 247 311 … … 252 316 $repeat = false; 253 317 $res = say($str); 254 print_r($res);255 318 if ($res == null) { 256 319 $readkey=$AGI->wait_for_digit(5000); … … 266 329 } 267 330 } 268 269 331 270 332 // 'say' takes a string and says it! If you push '*' it will repeat. If you push anything else, … … 334 396 function sql($sql,$type="query",$fetchmode=null) { 335 397 global $db; 398 399 debug("CIDoverride db: $sql", 4); 336 400 $results = $db->$type($sql,$fetchmode); 337 401 if(DB::IsError($results)) {
