<?
/**
 * VoiceOne Settings/
 *
 * Frontend to provide access to the voiceone system.
 * @package voiceone
 * @subpackage  settings_main
 */
  include ("../admin/config/cfg.php");
  global $cwlang,$cw_version;
 	sajax_init();
  //$sajax_debug_mode=true;
  
  //get the public key
  $key=nl2br($asterisk->getPublicKey());

  //get the speeddial trunk keys
  $count=1;
  $trunkArr=$asterisk->getTrunk(0,0);
  if (is_array($trunkArr))
  foreach ($trunkArr as $t) {
    $dialHtml.="<td class=\"value\" width=\"10%\"> <strong>".$t["speeddial"]."*</strong> </td><td class=\"label\"> &rarr; ".$t["name"]." </td>";
    if ($count%3==0) $dialHtml.="</tr><tr>";
    $count++;
  }    

  //get the speeddial apps keys
  $count=1;
  $appArr=$asterisk->getApplication(0);
  if (is_array($appArr))
  foreach ($appArr as $a) {
    $appHtml.="<td class=\"value\"  width=\"10%\"> <strong>".$a["extension"]."</strong> </td><td class=\"label\"> &rarr; ".$a["name"]." </td>";
    if ($count%3==0) $appHtml.="</tr><tr>";
    $count++;
  }    
    
  ob_start();
?>
  <div class="SectionHeader">
    <h1><?=$cwlang["overview"]["title"]?></h1>
  </div>
  
  <div id="basic_form">
      
    <? echo lastVersion($js);?>
  
  </div>

    <? if ($dialHtml!="") {?>
    <h2><?=$cwlang["overview"][""]?>Trunk: speed dial keys</h2>
    <p class="blockintro">
      <table class="speeddial"><tr><?=$dialHtml?></tr></table>
    </p>
    <? }?>
  
    <? if ($appHtml!="") {?>
    <h2><?=$cwlang["overview"][""]?>Application: speed dial keys</h2>
    <p class="blockintro">
      <table class="speeddial"><tr><?=$appHtml?></tr></table>
    </p>
    <? }?>
    
    <h2><?=$cwlang["overview"]["publickey"]?></h2>
    <p class="blockintro">
      <?=$key?>
    </p>

<!--
  <h2><?=$cwlang["overview"]["firststep"]?></h2>
  <p class="blockintro">
    <?=$cwlang["overview"]["firststepDesc"]?>
  </p>
-->

<?
  $contents=ob_get_contents();
  ob_end_clean();

  
  //================ SIDEBAR ================
  ob_start(); 
  ?>
        <div class="Sidebar">
          <h1><?=$cwlang["overview"]["configuration"]?></h1>
          <p>
            <?=$cwlang["overview"]["configurationDesc"]?>
          </p>
          <p> 
            <img src="../admin/public/img/toolbox.gif" width="206" alt="Vocione" />
          </p>
        </div>
  <?  
  $sidebar=ob_get_contents();
  ob_end_clean();
 	sajax_handle_client_request();
  
  $smarty->assign("section", "settings");
  $smarty->assign("subsection", "");
  $smarty->assign("contents", $contents);
  $smarty->assign("sidebar", $sidebar);
  $smarty->assign("ajax", $js);
  $smarty->display('settings.tpl');
?>

