Changeset 12260

Show
Ignore:
Timestamp:
06/22/11 12:18:19 (2 years ago)
Author:
mbrevda
Message:

re #5170 - work in progress

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.10/ivr/assets/js/ivr.js

    r12259 r12260  
    11$(document).ready(function(){ 
     2  //add "add row" button 
     3  var new_entrie = '<tr>' + $('#ivr_entries > tbody:last').find('tr:last').html() + '</tr>'; 
     4  $('#add_entrie').click(function(){ 
     5    id = new Date().getTime(); 
     6    $('#ivr_entries > tbody:last').find('tr:last').after(new_entrie.replace(/DESTID/g, id)); 
     7    bind_dests_double_selects(); 
     8  }); 
     9   
    210  $('[name=frm_ivr]').submit(function(){ 
    311    //set timeout/invalid destination 
     
    715    $(this).append('<input type="hidden" name="timeout_destination" value="' + timeout + '">'); 
    816     
    9     //set goto's for entire
     17    //set goto fileds for destination
    1018    $('[name^=goto]').each(function(){ 
    11       num = $(this).attr('name').replace('goto', '') - 1
     19      num = $(this).attr('name').replace('goto', '')
    1220      dest = $('[name=' + $(this).val() + num + ']').val(); 
    13       $('input[name="entires[goto][]"]').eq(num).val(dest) 
     21      $(this).parent().find('input[name="entries[goto][]"]').val(dest) 
     22      //console.log(num, dest, $(this).parent().find('input[name="entries[goto][]"]').val()) 
     23    }) 
     24     
     25    //set ret_ivr checkboxes to SOMETHING so that they get sent back 
     26    $('[name="entries[ivr_ret][]"]').not(':checked').each(function(){ 
     27      $(this).attr('checked','checked').val('uncheked') 
    1428    }) 
    1529     
    1630    //disable dests so that they dont get posted 
    17     $('.destdropdown, .destdropdown2').attr("disabled", "disabled") 
     31    $('.destdropdown, .destdropdown2').attr("disabled", "disabled"); 
    1832  }) 
    1933   
    2034  //reenable dests in case there was an error on the page and it didnt get postedj 
    2135  $('[name=frm_ivr]').submit(function(){ 
    22     setTimeout("$('.destdropdown, .destdropdown2').removeAttr('disabled')", 100); 
     36    setTimeout(restore_form_elemens, 100); 
    2337  }) 
     38   
     39  //delete rows on click 
     40  $('.delete_entrie').live('click', function(){ 
     41    $(this).closest('tr').fadeOut('normal', function(){$(this).closest('tr').remove();}) 
     42  }) 
     43   
    2444}); 
     45 
     46function restore_form_elemens() { 
     47  $('.destdropdown, .destdropdown2').removeAttr('disabled') 
     48  $('[name="entries[ivr_ret][]"][value=uncheked]').each(function(){ 
     49    $(this).removeAttr('checked') 
     50  }) 
     51} 
  • modules/branches/2.10/ivr/functions.inc.php

    r12259 r12260  
    202202    $res = $db->getRow("SELECT ivr_id from ivr where displayname='$name'"); 
    203203  } 
    204   return ($res[0]); 
    205    
    206 
    207  
    208 function ivr_add_command($id, $cmd, $dest, $ivr_ret) { 
    209   global $db; 
    210   // Does it already exist? 
    211   $res = $db->getRow("SELECT * from ivr_dests where ivr_id='$id' and selection='$cmd'"); 
    212   $ivr_ret = $ivr_ret ? 1 : 0; 
    213   if (count($res) == 0) { 
    214     // Just add it. 
    215     sql("INSERT INTO ivr_dests VALUES('$id', '$cmd', '$dest', '$ivr_ret')"); 
     204  if ($db->IsError($res)){ 
     205    die_freepbx($res->getDebugInfo()); 
    216206  } else { 
    217     // Update it. 
    218     sql("UPDATE ivr_dests SET dest='$dest', ivr_ret='$ivr_ret' where ivr_id='$id' and selection='$cmd'"); 
    219   } 
    220 
    221 function ivr_do_edit($id, $post) { 
    222  
    223   $displayname = isset($post['displayname'])?$post['displayname']:''; 
    224   $timeout = isset($post['timeout'])?$post['timeout']:''; 
    225   $ena_directory = isset($post['ena_directory'])?$post['ena_directory']:''; 
    226   $ena_directdial = isset($post['ena_directdial'])?$post['ena_directdial']:''; 
    227   $annmsg_id = isset($post['annmsg_id'])?$post['annmsg_id']:''; 
    228   $dircontext = isset($post['dircontext'])?$post['dircontext']:''; 
    229   $timeout_id = isset($post['timeout_id'])?$post['timeout_id']:''; 
    230   $invalid_id = isset($post['invalid_id'])?$post['invalid_id']:''; 
    231  
    232   $loops = isset($post['loops'])?$post['loops']:'2'; 
    233   $alt_timeout = isset($post['alt_timeout'])?$post['alt_timeout']:''; 
    234   $alt_invalid = isset($post['alt_invalid'])?$post['alt_invalid']:''; 
    235   $retvm = isset($post['retvm'])?$post['retvm']:''; 
    236  
    237   if (!empty($ena_directdial) && !is_numeric($ena_directdial)) { 
    238     $ena_directdial='CHECKED'; 
    239   } 
    240   if (!empty($alt_timeout)) { 
    241     $alt_timeout='CHECKED'; 
    242   } 
    243   if (!empty($alt_invalid)) { 
    244     $alt_invalid='CHECKED'; 
    245   } 
    246   if (!empty($retvm)) { 
    247     $retvm='CHECKED'; 
    248   } 
    249    
    250   $sql = " 
    251   UPDATE ivr  
    252   SET  
    253     displayname='$displayname',  
    254     enable_directory='$ena_directory',  
    255     enable_directdial='$ena_directdial',  
    256     timeout='$timeout',  
    257     announcement_id='$annmsg_id',  
    258     timeout_id='$timeout_id',  
    259     invalid_id='$invalid_id',  
    260     dircontext='$dircontext',  
    261     alt_timeout='$alt_timeout',  
    262     alt_invalid='$alt_invalid',  
    263     retvm='$retvm',  
    264     `loops`='$loops'  
    265   WHERE ivr_id='$id' 
    266   "; 
    267   sql($sql); 
    268  
    269   // Delete all the old dests 
    270   sql("DELETE FROM ivr_dests where ivr_id='$id'"); 
    271   // Now, lets find all the goto's in the post. Destinations return gotoN => foo and get fooN for the dest. 
    272   // Is that right, or am I missing something? 
    273   foreach(array_keys($post) as $var) { 
    274     if (preg_match('/goto(\d+)/', $var, $match)) { 
    275       // This is a really horrible line of code. take N, and get value of fooN. See above. Note we 
    276       // get match[1] from the preg_match above 
    277       $dest = $post[$post[$var].$match[1]]; 
    278       $cmd = $post['option'.$match[1]]; 
    279       $ivr_ret = isset($post['ivr_ret'.$match[1]]) ? $post['ivr_ret'.$match[1]] : ''; 
    280       // Debugging if it all goes pear shaped. 
    281       // print "I think pushing $cmd does $dest<br>\n"; 
    282       if (strlen($cmd)) 
    283         ivr_add_command($id, $cmd, $dest, $ivr_ret); 
    284     } 
    285   } 
    286 
    287  
     207    return ($res[0]); 
     208  } 
     209   
     210   
     211
    288212 
    289213function ivr_list() { 
     
    298222} 
    299223 
    300 function ivr_get_details($id) { 
     224function ivr_get_details($id = '') { 
    301225  global $db; 
    302226 
    303   $sql = "SELECT * FROM ivr where ivr_id='$id'"; 
     227  $sql = "SELECT * FROM ivr_details"; 
     228  if ($id) { 
     229    $sql .= ' where  id = "' . $id . '"'; 
     230  } 
    304231  $res = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    305232  if($db->IsError($res)) { 
    306     return null; 
    307   } 
    308   return $res[0]; 
    309 
    310  
    311 function ivr_get_dests($id) { 
     233    die_freepbx($res->getDebugInfo()); 
     234  } 
     235 
     236  return $id ? $res[0] : $res; 
     237
     238 
     239function ivr_get_entires($id) { 
    312240  global $db; 
    313   $sql = "SELECT selection, dest, ivr_ret FROM ivr_dests where ivr_id='$id' ORDER BY selection"; 
    314   $res = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    315   if($db->IsError($res)) { 
    316     return null; 
     241   
     242  //+0 to convert string to an integer 
     243  $sql = "SELECT * FROM ivr_entries WHERE ivr_id = ? ORDER BY selection + 0"; 
     244  $res = $db->getAll($sql, array($id), DB_FETCHMODE_ASSOC); 
     245  if ($db->IsError($res)) { 
     246    die_freepbx($res->getDebugInfo()); 
    317247  } 
    318248  return $res; 
     
    332262  $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; 
    333263  $id   = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; 
    334   if ($id == null) { 
    335     return true; 
    336   } 
    337   if ($action  == 'add' && $id == '') { 
     264 
     265  if ($action  == 'add' && $id != '') { 
    338266     $currentcomponent->addguielem('_top', new gui_pageheading('title', _('Add Directory')), 0); 
    339267 
    340     $deet = array('name', 'directdial', 'invalid_loops', 'invalid_rety_recording',  
    341           'invalid_recording', 'invalid_destination', 'timeout_loops', 
     268    $deet = array('id', 'name', 'description', 'announcement', 'directdial',  
     269          'invalid_loops', 'invalid_rety_recording',  
     270          'invalid_recording', 'invalid_destination',  
     271          'timeout_loops', 'timeout_time', 
    342272          'timeout_rety_recording', 'timeout_recording', 'timeout_destination', 
    343           'announcement_id', 'retvm', 'enable_directdial', 'description', 'id'); 
     273          'retvm'); 
    344274      
    345275    foreach ($deet as $d) { 
    346276      switch ($d){ 
    347         case 'repeat_loops'; 
     277        case 'invalid_loops': 
     278        case 'timeout_loops'; 
    348279          $ivr[$d] = 2; 
    349280          break; 
     
    360291  } else { 
    361292    $ivr = ivr_get_details($id); 
    362     $ivr['id'] = $ivr['ivr_id']; 
    363     $ivr['name'] = $ivr['displayname']; 
    364     $ivr['description'] = 'NOT IMPLEMENTED'; 
    365     $ivr['directdial'] = $ivr['invalid_loops'] = $ivr['invalid_rety_recording'] = $ivr['invalid_recording'] = ''; 
    366     $ivr['invalid_destination'] = $ivr['timeout_loops'] = $ivr['timeout_rety_recording'] = $ivr['timeout_recording'] = '';   
    367     $ivr['timeout_destination'] = ''; 
    368     dbug('$ivr', $ivr); 
    369293 
    370294    $label = sprintf(_("Edit IVR: %s"), $ivr['name'] ? $ivr['name'] : 'ID '.$ivr['id']); 
    371  
    372295    $currentcomponent->addguielem('_top', new gui_pageheading('title', $label), 0); 
    373296     
    374297    //display usage 
    375     $usage_list     = framework_display_destination_usage(ivr_getdest($ivr['id'])); 
     298    $usage_list     = '';//framework_display_destination_usage(); 
    376299    if (!empty($usage_list)) { 
    377300      $usage_list_text  = isset($usage_list['text']) ? $usage_list['text'] : ''; 
     
    382305     
    383306    //display delete link 
    384     $label        = '<span><img width="16" height="16" border="0" title="'  
     307    $label = sprintf(_("Delete IVR: %s"), $ivr['name'] ? $ivr['name'] : 'ID '.$ivr['id']); 
     308    $del        = '<span><img width="16" height="16" border="0" title="'  
    385309              . $label . '" alt="" src="images/core_delete.png"/>&nbsp;' . $label . '</span>'; 
    386310    $currentcomponent->addguielem('_top',  
    387       new gui_link('del', $label, $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&action=delete',  
     311      new gui_link('del', $del, $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&action=delete',  
    388312        true, false), 0); 
    389313  } 
    390314   
    391   //delete link, dont show if we dont have an id (i.e. directory wasnt created yet) 
     315 
    392316  $gen_section = _('IVR General Options'); 
    393317  $currentcomponent->addguielem($gen_section,  
     
    406330  } 
    407331    $currentcomponent->setoptlistopts('recordings', 'sort', false); 
     332   
    408333  //build repeat_loops select list and defualt it to 3 
     334  //while not 100% nesesary, declaring this is the only way to prevent sorting on the list 
     335  $currentcomponent->addoptlist('ivr_repeat_loops', false);  
     336  $currentcomponent->addoptlistitem('ivr_repeat_loops', 'disabled', 'Disabled'); 
    409337  for($i=0; $i <11; $i++){ 
    410     $currentcomponent->addoptlistitem('repeat_loops', $i, $i); 
    411   } 
    412    
     338    $currentcomponent->addoptlistitem('ivr_repeat_loops', $i, $i); 
     339  } 
     340 
    413341  //generate page 
    414342  $currentcomponent->addguielem($section,  
    415     new gui_selectbox('displayname', $currentcomponent->getoptlist('recordings'),  
    416       $ivr['announcement_id'], _('Announcement'), _('Greeting to be played on entry to the Ivr.'), false)); 
     343    new gui_selectbox('announcement', $currentcomponent->getoptlist('recordings'),  
     344      $ivr['announcement'], _('Announcement'), _('Greeting to be played on entry to the Ivr.'), false)); 
    417345 
    418346 
     
    420348  //direct dial 
    421349  //TODO: hook in from directory   
    422   $currentcomponent->addoptlistitem('direct_dial', $ivr['enable_directdial'], _('Disabled')); 
    423   $currentcomponent->addoptlistitem('direct_dial', $ivr['enable_directdial'], _('Extensions')); 
     350  $currentcomponent->addoptlistitem('direct_dial', $ivr['directdial'], _('Disabled')); 
     351  $currentcomponent->addoptlistitem('direct_dial', $ivr['directdial'], _('Extensions')); 
    424352  $dd_help[] = _('completely disabled'); 
    425353  $dd_help[] = _('enabled for all extensions on a system'); 
     
    432360  //invalid  
    433361  $currentcomponent->addguielem($section,  
    434     new gui_selectbox('invalid_loops', $currentcomponent->getoptlist('repeat_loops'),  
     362    new gui_selectbox('invalid_loops', $currentcomponent->getoptlist('ivr_repeat_loops'),  
    435363    $ivr['invalid_loops'], _('Invalid Retries'), _('Number of times to retry when receiving an invalid/unmatched response from the caller'), false)); 
    436364  $currentcomponent->addguielem($section,  
     
    446374  //timeout/invalid  
    447375  $currentcomponent->addguielem($section,  
    448     new gui_selectbox('timeout_loops', $currentcomponent->getoptlist('repeat_loops'),  
     376    new gui_selectbox('timeout_loops', $currentcomponent->getoptlist('ivr_repeat_loops'),  
    449377    $ivr['timeout_loops'], _('Timeout Retries'), _('Number of times to retry when receiving an invalid/unmatched response from the caller'), false)); 
     378  $currentcomponent->addguielem($section,  
     379    new gui_textbox('timeout_time', stripslashes($ivr['timeout_time']), _('Timeout'), _('Amount of time to be concidered a timeout'))); 
    450380  $currentcomponent->addguielem($section,  
    451381    new gui_selectbox('timeout_rety_recording', $currentcomponent->getoptlist('recordings'),  
     
    466396    _('When checked, the extension number being transferred to will be announced prior to the transfer'),true));*/ 
    467397  $currentcomponent->addguielem($section, new gui_hidden('id', $ivr['id'])); 
    468   $currentcomponent->addguielem($section, new gui_hidden('action', 'edit')); 
     398  $currentcomponent->addguielem($section, new gui_hidden('action', 'save')); 
    469399 
    470400 
     
    477407function ivr_configpageinit($pagename) { 
    478408  global $currentcomponent; 
     409  $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; 
     410   
    479411  if($pagename == 'ivr'){ 
    480412    $currentcomponent->addprocessfunc('ivr_configprocess'); 
    481     $currentcomponent->addguifunc('ivr_configpageload'); 
     413     
     414    //dont show page if there is no action set 
     415    if ($action && $action != 'delete') {      
     416      $currentcomponent->addguifunc('ivr_configpageload'); 
     417    } 
     418     
    482419    return true; 
    483420  } 
     
    486423//prosses received arguments 
    487424function ivr_configprocess(){ 
    488   if($_REQUEST['display'] == 'ivr'){ 
    489     return true; 
    490     global $db,$amp_conf; 
    491     //get variables for directory_details 
    492     $requestvars = array('id','dirname','description','announcement', 
    493               'callid_prefix','alert_info','repeat_loops', 
    494               'repeat_recording','invalid_recording', 
    495               'invalid_destination','retivr','say_extension'); 
    496     foreach($requestvars as $var){ 
     425  if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'ivr'){ 
     426    global $db; 
     427    //get variables 
     428 
     429    $get_var = array('id', 'name', 'description', 'announcement', 
     430            'directdial', 'invalid_loops', 'invalid_rety_recording', 
     431            'invalid_destination', 'timeout_enabled', 'invalid_recording', 
     432            'retvm', 'invalid_enabled', 'timeout_time', 'timeout_recording', 
     433            'timeout_rety_recording', 'timeout_destination', 'timeout_loops'); 
     434    foreach($get_var as $var){ 
    497435      $vars[$var] = isset($_REQUEST[$var])  ? $_REQUEST[$var]   : ''; 
    498436    } 
     
    500438    $action   = isset($_REQUEST['action'])  ? $_REQUEST['action'] : ''; 
    501439    $entries  = isset($_REQUEST['entries']) ? $_REQUEST['entries']  : ''; 
    502     //$entries=(($entries)?array_values($entries):'');//reset keys 
    503  
    504     switch($action){ 
    505       case 'edit': 
     440 
     441    switch ($action) { 
     442    case 'save': 
     443       
    506444        //get real dest 
    507         $vars['invalid_destination'] = $_REQUEST['invalid_destination']; 
    508         $vars['id'] = directory_save_dir_details($vars); 
    509         directory_save_dir_entries($vars['id'],$entries); 
     445        $_REQUEST['id'] = $vars['id'] = ivr_save_details($vars); 
     446        ivr_save_entries($vars['id'], $entries); 
    510447        needreload(); 
    511         redirect_standard_continue('id'); 
     448        $_REQUEST['action'] = 'edit'; 
     449        redirect_standard_continue('id', 'action'); 
    512450      break; 
    513451      case 'delete': 
    514         directory_delete($vars['id']); 
     452        ivr_delete($vars['id']); 
    515453        needreload(); 
    516454        redirect_standard_continue(); 
     
    520458} 
    521459 
     460function ivr_save_details($vals){ 
     461  global $db, $amp_conf; 
     462 
     463  foreach($vals as $key => $value) { 
     464    $vals[$key] = $db->escapeSimple($value); 
     465  } 
     466 
     467  if ($vals['id']) { 
     468    $sql = 'REPLACE INTO ivr_details (id, name, description, announcement, 
     469        directdial, invalid_loops, invalid_rety_recording, 
     470        invalid_destination, timeout_enabled, invalid_recording, 
     471        retvm, invalid_enabled, timeout_time, timeout_recording, 
     472        timeout_rety_recording, timeout_destination, timeout_loops) 
     473        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; 
     474    $foo = $db->query($sql, $vals); 
     475    if($db->IsError($foo)) { 
     476      die_freepbx(print_r($vals,true).' '.$foo->getDebugInfo()); 
     477    } 
     478  } else { 
     479    unset($vals['id']); 
     480    $sql = 'INSERT INTO ivr_details (name, description, announcement, 
     481        directdial, invalid_loops, invalid_rety_recording, 
     482        invalid_destination, timeout_enabled, invalid_recording, 
     483        retvm, invalid_enabled, timeout_time, timeout_recording, 
     484        timeout_rety_recording, timeout_destination, timeout_loops) 
     485        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; 
     486         
     487    $foo = $db->query($sql, $vals); 
     488    if($db->IsError($foo)) { 
     489      die_freepbx(print_r($vals,true).' '.$foo->getDebugInfo()); 
     490    } 
     491    $sql = ( ($amp_conf["AMPDBENGINE"]=="sqlite3") ? 'SELECT last_insert_rowid()' : 'SELECT LAST_INSERT_ID()'); 
     492    $vals['id'] = $db->getOne($sql); 
     493    if ($db->IsError($foo)){ 
     494      die_freepbx($foo->getDebugInfo()); 
     495    } 
     496  } 
     497 
     498  return $vals['id']; 
     499} 
     500 
     501function ivr_save_entries($id, $entries){ 
     502  global $db; 
     503  $id = $db->escapeSimple($id); 
     504  sql('DELETE FROM ivr_entries WHERE ivr_id = "' . $id . '"'); 
     505 
     506  if ($entries) { 
     507    for ($i = 0; $i < count($entries['ext']); $i++) { 
     508      //make sure there is an extension set - otherwise SKIP IT 
     509      if ($entries['ext'][$i]) { 
     510        $d[] = array( 
     511              'ivr_id'  => $id, 
     512              'ext'     => $entries['ext'][$i], 
     513              'goto'    => $entries['goto'][$i], 
     514              'ivr_ret' => (isset($entries['ivr_ret'][$i]) ? $entries['ivr_ret'][$i] : '') 
     515            ); 
     516      } 
     517 
     518    } 
     519    $sql = $db->prepare('INSERT INTO ivr_entries VALUES (?, ?, ?, ?)'); 
     520    $res = $db->executeMultiple($sql, $d); 
     521    if ($db->IsError($res)){ 
     522      die_freepbx($res->getDebugInfo()); 
     523    } 
     524  } 
     525   
     526  return true; 
     527} 
     528 
    522529 
    523530function ivr_draw_entries_table_header_ivr() { 
     
    527534function ivr_draw_entries_ivr($id) { 
    528535  //TEST FUNCTION, DELETE ASAP 
    529   return array(form_input(array('name'  => 'entires[test1][]','value' => 'test1')), 
    530         form_input(array('name' => 'entires[test2][]','value' => 'test2')) 
     536  return array(form_input(array('name'  => 'entries[test1][]','value' => 'test1')), 
     537        form_input(array('name' => 'entries[test2][]','value' => 'test2')) 
    531538        ); 
    532539} 
     
    534541function ivr_draw_entries($id){ 
    535542  $headers    = mod_func_iterator('draw_entries_table_header_ivr'); 
    536   $ivr_entires  = ivr_get_dests($id); 
    537  
    538   foreach ($ivr_entires as $k => $e) { 
    539     $entires[$k]= $e; 
    540     $entires[$k]['hooks'] = mod_func_iterator('draw_entries_ivr', array('id' => $id, 'ext' => $e['selection'])); 
    541   } 
    542  
     543  $ivr_entries  = ivr_get_entires($id); 
     544  dbug('$ivr_entries', $ivr_entries); 
     545  if ($ivr_entries) { 
     546    foreach ($ivr_entries as $k => $e) { 
     547      $entries[$k]= $e; 
     548      $entries[$k]['hooks'] = mod_func_iterator('draw_entries_ivr', array('id' => $id, 'ext' => $e['selection'])); 
     549    } 
     550  } 
     551   
     552  $entries['blank'] = array('selection' => '', 'dest' => '', 'ivr_ret' => ''); 
     553  $entries['blank']['hooks'] = mod_func_iterator('draw_entries_ivr', array('id' => '', 'ext' => '')); 
    543554   
    544555  return load_view(dirname(__FILE__) . '/views/entries.php',  
    545556        array( 
    546557          'headers' => $headers,  
    547           'entires'  =>  $entires 
     558          'entries'  =>  $entries 
    548559        ) 
    549560      ); 
     
    556567} 
    557568 
     569function ivr_delete($id) { 
     570  global $db; 
     571  sql('DELETE FROM ivr_details WHERE id = "' . $db->escapeSimple($id) . '"'); 
     572  sql('DELETE FROM ivr_entries WHERE ivr_id = "' . $db->escapeSimple($id) . '"'); 
     573} 
    558574//---------------------------------------------------------------------------- 
    559575// Dynamic Destination Registry and Recordings Registry Functions 
     
    565581    return $destlist; 
    566582  } 
    567   $sql = "SELECT dest, displayname, selection, a.ivr_id ivr_id FROM ivr a INNER JOIN ivr_dests d ON a.ivr_id = d.ivr_id  "; 
     583  $sql = "SELECT dest, name, selection, a.id id FROM ivr_details a INNER JOIN ivr_entries d ON a.id = d.ivr_id  "; 
    568584  if ($dest !== true) { 
    569585    $sql .= "WHERE dest in ('".implode("','",$dest)."')"; 
    570586  } 
    571   $sql .= "ORDER BY displayname"; 
     587  $sql .= "ORDER BY name"; 
    572588  $results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
    573589 
  • modules/branches/2.10/ivr/install.php

    r12257 r12260  
    5252sql($sql); 
    5353 
    54 // Now, we need to check for upgrades. 
    55 // V1.0, old IVR. You shouldn't see this, but check for it anyway, and assume that it's 2.0 
    56 // V2.0, Original Release 
    57 // V2.1, added 'directorycontext' to the schema 
    58 // v2.2, announcement changed to support filenames instead of ID's from recordings table 
    59 // 
     54 
    6055 
    6156$ivr_modcurrentvers = modules_getversion('ivr'); 
    6257 
    63 if($amp_conf["AMPDBENGINE"] != "sqlite3")  { // As of 2.5 these are all in the sqlite3 schema 
    64   // Add the col 
    65   $sql = "SELECT dircontext FROM ivr"; 
    66   $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    67   if(DB::IsError($check)) { 
     58//pre-2.10 migration. Do we even still need this? -MB 
     59if (version_compare($ivr_modcurrentvers, "2.9", "<")) { 
     60  // Now, we need to check for upgrades. 
     61  // V1.0, old IVR. You shouldn't see this, but check for it anyway, and assume that it's 2.0 
     62  // V2.0, Original Release 
     63  // V2.1, added 'directorycontext' to the schema 
     64  // v2.2, announcement changed to support filenames instead of ID's from recordings table 
     65  // 
     66  if($amp_conf["AMPDBENGINE"] != "sqlite3")  { // As of 2.5 these are all in the sqlite3 schema 
     67    // Add the col 
     68    $sql = "SELECT dircontext FROM ivr"; 
     69    $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     70    if($db->IsError($check)) { 
     71      // add new field 
     72      $sql = 'ALTER TABLE ivr ADD COLUMN dircontext VARCHAR ( 50 ) DEFAULT "default"'; 
     73      $result = $db->query($sql); 
     74      if($db->IsError($result)) { 
     75        die_freepbx($result->getDebugInfo()); 
     76      } 
     77    } 
     78 
     79    if ($ivr_modcurrentvers !== null && version_compare($ivr_modcurrentvers, "2.2", "<")) { 
     80      // Change existing records 
     81      $existing = sql("SELECT DISTINCT announcement FROM ivr WHERE displayname <> '__install_done' AND announcement IS NOT NULL", "getAll"); 
     82      foreach ($existing as $item) { 
     83        $recid = $item[0]; 
     84        $sql = "SELECT filename FROM recordings WHERE id = '$recid' AND displayname <> '__invalid'"; 
     85        $recordings = sql($sql, "getRow"); 
     86        if (is_array($recordings)) { 
     87          $filename = (isset($recordings[0]) ? $recordings[0] : ''); 
     88          if ($filename != '') { 
     89            $sql = "UPDATE ivr SET announcement = '".str_replace("'", "''", $filename)."' WHERE announcement = '$recid'"; 
     90            $upcheck = $db->query($sql); 
     91            if($db->IsError($upcheck)) 
     92            die_freepbx($upcheck->getDebugInfo()); 
     93          } 
     94        } 
     95      } 
     96    } 
     97  } 
     98  // Version 2.5.7 adds auto-return to IVR 
     99  $sql = "SELECT ivr_ret FROM ivr_dests"; 
     100  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     101  if($db->IsError($check)) { 
    68102    // add new field 
    69     $sql = 'ALTER TABLE ivr ADD COLUMN dircontext VARCHAR ( 50 ) DEFAULT "default"'; 
    70     $result = $db->query($sql); 
    71     if(DB::IsError($result)) { 
     103    $sql = "ALTER TABLE ivr_dests ADD ivr_ret TINYINT(1) NOT NULL DEFAULT 0;"; 
     104    $result = $db->query($sql); 
     105    if($db->IsError($result)) { die_freepbx($result->getDebugInfo()); } 
     106  } 
     107 
     108  $results = array(); 
     109  $sql = "SELECT ivr_id, selection, dest FROM ivr_dests"; 
     110  $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     111  if (!$db->IsError($results)) { // error - table must not be there 
     112    foreach ($results as $result) { 
     113      $old_dest  = $result['dest']; 
     114      $ivr_id    = $result['ivr_id']; 
     115      $selection = $result['selection']; 
     116 
     117      $new_dest = merge_ext_followme(trim($old_dest)); 
     118      if ($new_dest != $old_dest) { 
     119        $sql = "UPDATE ivr_dests SET dest = '$new_dest' WHERE ivr_id = $ivr_id AND selection = '$selection' AND dest = '$old_dest'"; 
     120        $results = $db->query($sql); 
     121        if($db->IsError($results)) { 
     122          die_freepbx($results->getMessage()); 
     123        } 
     124      } 
     125    } 
     126  } 
     127 
     128  // Version 2.5.17 adds improved i and t destination handling 
     129  $sql = "SELECT alt_timeout FROM ivr"; 
     130  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     131  if($db->IsError($check)) { 
     132    // add new field 
     133    $sql = "ALTER TABLE ivr ADD alt_timeout VARCHAR(8);"; 
     134    $result = $db->query($sql); 
     135    if($db->IsError($result)) { die_freepbx($result->getDebugInfo()); } 
     136  } 
     137  $sql = "SELECT alt_invalid FROM ivr"; 
     138  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     139  if($db->IsError($check)) { 
     140    // add new field 
     141    $sql = "ALTER TABLE ivr ADD alt_invalid VARCHAR(8);"; 
     142    $result = $db->query($sql); 
     143    if($db->IsError($result)) { die_freepbx($result->getDebugInfo()); } 
     144  } 
     145  $sql = "SELECT `loops` FROM ivr"; 
     146  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     147  if($db->IsError($check)) { 
     148    // add new field 
     149    $sql = "ALTER TABLE ivr ADD `loops` TINYINT(1) NOT NULL DEFAULT 2;"; 
     150    $result = $db->query($sql); 
     151    if($db->IsError($result)) { die_freepbx($result->getDebugInfo()); } 
     152  } 
     153 
     154 
     155 
     156  // Version 2.5 migrate to recording ids 
     157  // 
     158  outn(_("Checking if announcements need migration..")); 
     159  $sql = "SELECT announcement_id FROM ivr"; 
     160  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     161  if($db->IsError($check)) { 
     162    //  Add announcement_id field 
     163    // 
     164    out(_("migrating")); 
     165    outn(_("adding announcement_id field..")); 
     166    $sql = "ALTER TABLE ivr ADD announcement_id INTEGER"; 
     167    $result = $db->query($sql); 
     168    if($db->IsError($result)) { 
     169      out(_("fatal error")); 
    72170      die_freepbx($result->getDebugInfo()); 
    73     } 
    74   } 
    75  
    76   if ($ivr_modcurrentvers !== null && version_compare($ivr_modcurrentvers, "2.2", "<")) { 
    77     // Change existing records 
    78     $existing = sql("SELECT DISTINCT announcement FROM ivr WHERE displayname <> '__install_done' AND announcement IS NOT NULL", "getAll"); 
    79     foreach ($existing as $item) { 
    80       $recid = $item[0]; 
    81       $sql = "SELECT filename FROM recordings WHERE id = '$recid' AND displayname <> '__invalid'"; 
    82       $recordings = sql($sql, "getRow"); 
    83       if (is_array($recordings)) { 
    84         $filename = (isset($recordings[0]) ? $recordings[0] : ''); 
    85         if ($filename != '') { 
    86           $sql = "UPDATE ivr SET announcement = '".str_replace("'", "''", $filename)."' WHERE announcement = '$recid'"; 
    87           $upcheck = $db->query($sql); 
    88           if(DB::IsError($upcheck)) 
    89           die_freepbx($upcheck->getDebugInfo()); 
    90         } 
    91       } 
    92     } 
    93   } 
     171    } else { 
     172      out(_("ok")); 
     173    } 
     174 
     175    // Get all the valudes and replace them with announcement_id 
     176    // 
     177    outn(_("migrate to recording ids..")); 
     178    $sql = "SELECT `ivr_id`, `announcement` FROM `ivr`"; 
     179    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     180    if($db->IsError($results)) { 
     181      out(_("fatal error")); 
     182      die_freepbx($results->getDebugInfo()); 
     183    } 
     184    $migrate_arr = array(); 
     185    $count = 0; 
     186    foreach ($results as $row) { 
     187      if (trim($row['announcement']) != '') { 
     188        $rec_id = recordings_get_or_create_id($row['announcement'], 'ivr'); 
     189        $migrate_arr[] = array($rec_id, $row['ivr_id']); 
     190        $count++; 
     191      } 
     192    } 
     193    if ($count) { 
     194      $compiled = $db->prepare('UPDATE `ivr` SET `announcement_id` = ? WHERE `ivr_id` = ?'); 
     195      $result = $db->executeMultiple($compiled,$migrate_arr); 
     196      if($db->IsError($result)) { 
     197        out(_("fatal error")); 
     198        die_freepbx($result->getDebugInfo()); 
     199      } 
     200    } 
     201    out(sprintf(_("migrated %s entries"),$count)); 
     202 
     203    // Now remove the old recording field replaced by new id field 
     204    // 
     205    outn(_("dropping announcement field..")); 
     206    $sql = "ALTER TABLE `ivr` DROP `announcement`"; 
     207    $result = $db->query($sql); 
     208    if($db->IsError($result)) { 
     209      out(_("no announcement field???")); 
     210    } else { 
     211      out(_("ok")); 
     212    } 
     213 
     214  } else { 
     215    out(_("already migrated")); 
     216  } 
     217 
     218  // Version 2.5.19 add invalid and timeout messages 
     219  // 
     220  outn(_("Checking for timeout_id..")); 
     221  $sql = "SELECT timeout_id FROM ivr"; 
     222  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     223  if($db->IsError($check)) { 
     224    //  Add timeout_id field 
     225    // 
     226    $sql = "ALTER TABLE ivr ADD timeout_id INTEGER DEFAULT null"; 
     227    $result = $db->query($sql); 
     228    if($db->IsError($result)) { 
     229      out(_("fatal error")); 
     230      die_freepbx($result->getDebugInfo()); 
     231    } else { 
     232      out(_("added")); 
     233    } 
     234  } else { 
     235    out(_("not needed")); 
     236  } 
     237  outn(_("Checking for invalid_id..")); 
     238  $sql = "SELECT invalid_id FROM ivr"; 
     239  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     240  if($db->IsError($check)) { 
     241    //  Add invalid_id field 
     242    // 
     243    $sql = "ALTER TABLE ivr ADD invalid_id INTEGER DEFAULT null"; 
     244    $result = $db->query($sql); 
     245    if($db->IsError($result)) { 
     246      out(_("fatal error")); 
     247      die_freepbx($result->getDebugInfo()); 
     248    } else { 
     249      out(_("added")); 
     250    } 
     251  } else { 
     252    out(_("not needed")); 
     253  } 
     254 
     255  outn(_("Checking for retvm..")); 
     256  $sql = "SELECT retvm FROM ivr"; 
     257  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     258  if($db->IsError($check)) { 
     259    //  Add retvm field 
     260    // 
     261    $sql = "ALTER TABLE ivr ADD retvm VARCHAR(8);"; 
     262    $result = $db->query($sql); 
     263    if($db->IsError($result)) { 
     264      out(_("fatal error")); 
     265      die_freepbx($result->getDebugInfo()); 
     266    } else { 
     267      out(_("added")); 
     268    } 
     269  } else { 
     270    out(_("not needed")); 
     271  } 
     272 
     273  $count = sql('SELECT COUNT(*) FROM `ivr` WHERE `enable_directory` = "CHECKED"','getOne'); 
     274  if ($count) { 
     275    global $db; 
     276    $notifications =& notifications::create($db);  
     277    $extext = sprintf(_("There are %s IVRs that have the legacy Directory dialing enabled. This has been deprecated and will be removed from future releases. You should convert your IVRs to use the Directory module for this functionality and assign an IVR destination to a desired Directory. You can install the Directory module from the Online Module Repository"),$count); 
     278    $notifications->add_notice('ivr', 'DIRECTORY_DEPRECATED', sprintf(_('Deprecated Directory used by %s IVRs'),$count), $extext, '', true, true); 
     279    out(_("posting notice about deprecated functionality")); 
     280  } 
     281   
    94282} 
    95 // Version 2.5.7 adds auto-return to IVR 
    96 $sql = "SELECT ivr_ret FROM ivr_dests"; 
    97 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    98 if(DB::IsError($check)) { 
    99   // add new field 
    100   $sql = "ALTER TABLE ivr_dests ADD ivr_ret TINYINT(1) NOT NULL DEFAULT 0;"; 
    101   $result = $db->query($sql); 
    102   if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 
     283 
     284if (version_compare($ivr_modcurrentvers, "2.9", "==")) { 
     285  //migrate to 2.10 tables 
     286  sql('RENAME TABLE ivr TO ivr_details'); 
     287  sql('RENAME TABLE ivr_dests TO ivr_entries'); 
     288  sql('ALTER TABLE ivr  
     289  CHANGE ivr_id id int(11) NOT NULL AUTO_INCREMENT,  
     290  CHANGE displayname name varchar(50),  
     291  ADD description varchar(150) AFTER name, 
     292  CHANGE announcement_id announcement int(11) AFTER description, 
     293  CHANGE enable_directdial directdial varchar(50) AFTER announcement, 
     294  CHANGE retvm retvm varchar(8) AFTER directdial, 
     295  CHANGE alt_invalid invalid_enabled varchar(50) AFTER retvm, 
     296  CHANGE loops invalid_loops varchar(10) AFTER directdial,  
     297  CHANGE invalid_id invalid_recording int(11) AFTER invalid_loops, 
     298  ADD invalid_rety_recording int(11) AFTER invalid_loops, 
     299  ADD invalid_destination varchar(50) AFTER invalid_rety_recording, 
     300  CHANGE alt_timeout timeout_enabled varchar(50) AFTER invalid_destination, 
     301  CHANGE timeout timeout_time int(11), 
     302  CHANGE timeout_id timeout_recording int(11),  
     303  ADD timeout_rety_recording int(11), 
     304  ADD timeout_destination int(11), 
     305  ADD timeout_loops int(11), 
     306  DROP deptname,  
     307  DROP enable_directory,  
     308  DROP dircontext'); 
     309  //DROP enable_directory,  
    103310} 
    104311 
    105 $results = array(); 
    106 $sql = "SELECT ivr_id, selection, dest FROM ivr_dests"; 
    107 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    108 if (!DB::IsError($results)) { // error - table must not be there 
    109   foreach ($results as $result) { 
    110     $old_dest  = $result['dest']; 
    111     $ivr_id    = $result['ivr_id']; 
    112     $selection = $result['selection']; 
    113  
    114     $new_dest = merge_ext_followme(trim($old_dest)); 
    115     if ($new_dest != $old_dest) { 
    116       $sql = "UPDATE ivr_dests SET dest = '$new_dest' WHERE ivr_id = $ivr_id AND selection = '$selection' AND dest = '$old_dest'"; 
    117       $results = $db->query($sql); 
    118       if(DB::IsError($results)) { 
    119         die_freepbx($results->getMessage()); 
    120       } 
    121     } 
    122   } 
    123 } 
    124  
    125 // Version 2.5.17 adds improved i and t destination handling 
    126 $sql = "SELECT alt_timeout FROM ivr"; 
    127 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    128 if(DB::IsError($check)) { 
    129   // add new field 
    130   $sql = "ALTER TABLE ivr ADD alt_timeout VARCHAR(8);"; 
    131   $result = $db->query($sql); 
    132   if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 
    133 } 
    134 $sql = "SELECT alt_invalid FROM ivr"; 
    135 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    136 if(DB::IsError($check)) { 
    137   // add new field 
    138   $sql = "ALTER TABLE ivr ADD alt_invalid VARCHAR(8);"; 
    139   $result = $db->query($sql); 
    140   if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 
    141 } 
    142 $sql = "SELECT `loops` FROM ivr"; 
    143 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    144 if(DB::IsError($check)) { 
    145   // add new field 
    146   $sql = "ALTER TABLE ivr ADD `loops` TINYINT(1) NOT NULL DEFAULT 2;"; 
    147   $result = $db->query($sql); 
    148   if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 
    149 } 
    150  
    151  
    152  
    153 // Version 2.5 migrate to recording ids 
    154 // 
    155 outn(_("Checking if announcements need migration..")); 
    156 $sql = "SELECT announcement_id FROM ivr"; 
    157 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    158 if(DB::IsError($check)) { 
    159   //  Add announcement_id field 
    160   // 
    161   out(_("migrating")); 
    162   outn(_("adding announcement_id field..")); 
    163   $sql = "ALTER TABLE ivr ADD announcement_id INTEGER"; 
    164   $result = $db->query($sql); 
    165   if(DB::IsError($result)) { 
    166     out(_("fatal error")); 
    167     die_freepbx($result->getDebugInfo()); 
    168   } else { 
    169     out(_("ok")); 
    170   } 
    171  
    172   // Get all the valudes and replace them with announcement_id 
    173   // 
    174   outn(_("migrate to recording ids..")); 
    175   $sql = "SELECT `ivr_id`, `announcement` FROM `ivr`"; 
    176   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    177   if(DB::IsError($results)) { 
    178     out(_("fatal error")); 
    179     die_freepbx($results->getDebugInfo()); 
    180   } 
    181   $migrate_arr = array(); 
    182   $count = 0; 
    183   foreach ($results as $row) { 
    184     if (trim($row['announcement']) != '') { 
    185       $rec_id = recordings_get_or_create_id($row['announcement'], 'ivr'); 
    186       $migrate_arr[] = array($rec_id, $row['ivr_id']); 
    187       $count++; 
    188     } 
    189   } 
    190   if ($count) { 
    191     $compiled = $db->prepare('UPDATE `ivr` SET `announcement_id` = ? WHERE `ivr_id` = ?'); 
    192     $result = $db->executeMultiple($compiled,$migrate_arr); 
    193     if(DB::IsError($result)) { 
    194       out(_("fatal error")); 
    195       die_freepbx($result->getDebugInfo()); 
    196     } 
    197   } 
    198   out(sprintf(_("migrated %s entries"),$count)); 
    199  
    200   // Now remove the old recording field replaced by new id field 
    201   // 
    202   outn(_("dropping announcement field..")); 
    203   $sql = "ALTER TABLE `ivr` DROP `announcement`"; 
    204   $result = $db->query($sql); 
    205   if(DB::IsError($result)) { 
    206     out(_("no announcement field???")); 
    207   } else { 
    208     out(_("ok")); 
    209   } 
    210  
    211 } else { 
    212   out(_("already migrated")); 
    213 } 
    214  
    215 // Version 2.5.19 add invalid and timeout messages 
    216 // 
    217 outn(_("Checking for timeout_id..")); 
    218 $sql = "SELECT timeout_id FROM ivr"; 
    219 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    220 if(DB::IsError($check)) { 
    221   //  Add timeout_id field 
    222   // 
    223   $sql = "ALTER TABLE ivr ADD timeout_id INTEGER DEFAULT null"; 
    224   $result = $db->query($sql); 
    225   if(DB::IsError($result)) { 
    226     out(_("fatal error")); 
    227     die_freepbx($result->getDebugInfo()); 
    228   } else { 
    229     out(_("added")); 
    230   } 
    231 } else { 
    232   out(_("not needed")); 
    233 } 
    234 outn(_("Checking for invalid_id..")); 
    235 $sql = "SELECT invalid_id FROM ivr"; 
    236 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    237 if(DB::IsError($check)) { 
    238   //  Add invalid_id field 
    239   // 
    240   $sql = "ALTER TABLE ivr ADD invalid_id INTEGER DEFAULT null"; 
    241   $result = $db->query($sql); 
    242   if(DB::IsError($result)) { 
    243     out(_("fatal error")); 
    244     die_freepbx($result->getDebugInfo()); 
    245   } else { 
    246     out(_("added")); 
    247   } 
    248 } else { 
    249   out(_("not needed")); 
    250 } 
    251  
    252 outn(_("Checking for retvm..")); 
    253 $sql = "SELECT retvm FROM ivr"; 
    254 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    255 if(DB::IsError($check)) { 
    256   //  Add retvm field 
    257   // 
    258   $sql = "ALTER TABLE ivr ADD retvm VARCHAR(8);"; 
    259   $result = $db->query($sql); 
    260   if(DB::IsError($result)) { 
    261     out(_("fatal error")); 
    262     die_freepbx($result->getDebugInfo()); 
    263   } else { 
    264     out(_("added")); 
    265   } 
    266 } else { 
    267   out(_("not needed")); 
    268 } 
    269  
    270 $count = sql('SELECT COUNT(*) FROM `ivr` WHERE `enable_directory` = "CHECKED"','getOne'); 
    271 if ($count) { 
    272   global $db; 
    273   $notifications =& notifications::create($db);  
    274   $extext = sprintf(_("There are %s IVRs that have the legacy Directory dialing enabled. This has been deprecated and will be removed from future releases. You should convert your IVRs to use the Directory module for this functionality and assign an IVR destination to a desired Directory. You can install the Directory module from the Online Module Repository"),$count); 
    275   $notifications->add_notice('ivr', 'DIRECTORY_DEPRECATED', sprintf(_('Deprecated Directory used by %s IVRs'),$count), $extext, '', true, true); 
    276   out(_("posting notice about deprecated functionality")); 
    277 } 
    278  
    279 // This used to be called from page.ivr.php every time, it should not be needed, it should 
    280 // be called once and be done with. 
    281 // 
    282 ivr_init(); 
    283312 
    284313?> 
  • modules/branches/2.10/ivr/page.ivr.php

    r12257 r12260  
    1818        'action'    => '', 
    1919        'id'      => '', 
    20         'nbroptions'  => '3', 
    2120        'display'   => '' 
    2221); 
     
    2524  $$k = $var[$k];//todo: legacy support, needs to GO! 
    2625} 
    27 $dircontext = 'default'; 
    28 $tabindex = 0; 
    2926 
    30 echo load_view(dirname(__FILE__) . '/views/rnav.php', array('ivr_results' => ivr_list()) + $var); 
     27echo load_view(dirname(__FILE__) . '/views/rnav.php', array('ivr_results' => ivr_get_details()) + $var); 
    3128 
    32 switch ($action) { 
    33   case "add": 
    34     $id = ivr_get_ivr_id('Unnamed'); 
    35     // Set the defaults 
    36     $def['timeout'] = 5; 
    37     $def['ena_directdial'] = ''; 
    38     $def['ena_directory'] = ''; 
    39     break; 
    40   case "edit": 
    41     break; 
    42   case "edited": 
    43     if (isset($_REQUEST['delete'])) { 
    44       sql("DELETE from ivr where ivr_id='$id'"); 
    45       sql("DELETE FROM ivr_dests where ivr_id='$id'"); 
    46       needreload(); 
    47     } else { 
    48       ivr_do_edit($id, $_POST); 
    49       if (isset($_REQUEST['increase']))  
    50         $nbroptions++; 
    51       if (isset($_REQUEST['decrease'])) { 
    52         $nbroptions--; 
    53       } 
    54       if ($nbroptions < 1) 
    55         $nbroptions = 1; 
    56       //ivr_show_edit($id, $nbroptions, $_POST); 
    57       $url = 'config.php?type=setup&display=ivr&action=edit&id='.$id.'&nbroptions='.$nbroptions; 
    58       needreload(); 
    59       redirect($url); 
    60       break; 
    61     } 
    62   default: 
    63  
     29if (!$action) { 
    6430?> 
    65 <div class="content"> 
    6631<h2><?php echo _("IVR"); ?></h2> 
    6732<br/><br/>{add add button here}<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> 
  • modules/branches/2.10/ivr/views/entries.php

    r12259 r12260  
    11<?php 
    22$table = new CI_Table; 
    3 $table->set_template(array('table_open' => '<table class="alt_table">')); 
     3$table->set_template(array('table_open' => '<table class="alt_table IvrEntries" id="ivr_entries">')); 
    44//build header 
    55$h = array(); 
     
    1010 
    1111$count = 0; 
    12 foreach ($entires as $e) { 
     12foreach ($entries as $e) { 
    1313  $count++; 
    1414 
    1515  //add ext to dial 
    16   $row[] = fpbx_label
    17     form_input
    18       array( 
    19         'name' => 'entires[ext][]'
    20         'value'  => $e['selection'] 
     16  $row[] = form_input
     17       array
     18         'name'      => 'entries[ext][]', 
     19        'value'     => $e['selection']
     20        'placeholder' => _('digits pressed') 
    2121        ) 
    22       ),  
    23     'Digits to press for this choice'); 
     22      ); 
    2423   
    25   //add destination 
    26   $row[] = drawselects($e['dest'], $count, false, false) . form_hidden('entires[goto][]', ''); 
     24  //add destination. The last one gets a different count so that we can manipualte it on the page 
     25  if ($count == count($entries)) { 
     26    $row[] = drawselects($e['dest'], 'DESTID', false, false) . form_hidden('entries[goto][]', ''); 
     27  } else { 
     28    $row[] = drawselects($e['dest'], $count, false, false) . form_hidden('entries[goto][]', ''); 
     29  } 
     30   
    2731   
    2832  //return to ivr 
    29   $row[] = fpbx_label(form_checkbox('entires[ivr_ret][]', 'ivr_ret', $e['ivr_ret']),  
    30       'Check this box to have this option return to a parent IVR if it was called
    31       . ' from a parent IVR. If not, it will go to the chosen destination.<br><br>' 
     33  $row[] = fpbx_label(form_checkbox('entries[ivr_ret][]', '1', ($e['ivr_ret'] == 1)),  
     34      'Check this box to have this option return to a parent IVR if it was called
     35      . 'from a parent IVR. If not, it will go to the chosen destination.<br><br>' 
    3236      . 'The return path will be to any IVR that was in the call path prior to this ' 
    3337      . 'IVR which could lead to strange results if there was an IVR called in the ' 
    3438      . 'call path but not immediately before this'); 
    35    
     39 
     40  //delete buttom 
     41  $row[] = '<img src="images/trash.png" style="cursor:pointer" title="'  
     42  . _('Delete this entry. Dont forget to click Submit to save changes!')  
     43  . '" class="delete_entrie">'; 
     44     
    3645  //add module hooks   
    37   if ($e['hooks']) { 
     46  if (isset($e['hooks']) && $e['hooks']) { 
    3847    foreach ($e['hooks'] as $module => $hooks) { 
    3948      foreach ($hooks as $h) { 
     
    4453  } 
    4554   
    46   //delete buttom 
    47   $row[] = '<img src="images/trash.png" style="cursor:pointer" title="'  
    48   . _('Delete this entry. Dont forget to click Save to save changes!')  
    49   . '" onclick="delEntry(' . $e['selection'] . ')""'; 
    5055 
    5156  $table->add_row(array_values($row));   
     
    5459} 
    5560 
     61$ret = ''; 
     62$ret .= $table->generate(); 
     63$ret .= '<img src="modules/ivr/assets/images/add.png" style="cursor:pointer" title="' . _('Add Entrie')  
     64    . '" id="add_entrie">'; 
    5665 
    57 echo $table->generate(); 
     66 
     67echo $ret; 
    5868?> 
  • modules/branches/2.10/ivr/views/rnav.php

    r12258 r12260  
    66if (isset($ivr_results)){ 
    77  foreach ($ivr_results as $r) { 
    8     $li[] = '<a id="' . ( $id == $r['ivr_id'] ? 'current' : '')  
     8    $r['name'] = $r['name'] ? $r['name'] : 'IVR ID: ' . $r['id']; 
     9    $li[] = '<a id="' . ( $id == $r['id'] ? 'current' : '')  
    910      . '" href="config.php?display=ivr&amp;action=edit&amp;id='  
    10       . $r['ivr_id'] . '">'  
    11       . $r['displayname'] .'</a>'; 
     11      . $r['id'] . '">'  
     12      . $r['name'] .'</a>'; 
    1213  } 
    1314}