<?
/**
 * VoiceOne Main Gui
 *
 * Frontend to provide access to the voiceone system.
 * @package voiceone
 * @subpackage  gui_main
 */

  include ("admin/config/cfg.php");
  global $cwBasePath,$cwlang,$soapHostname;

  //create the web interface
  $ret=$asterisk->getDirectory(0);
  if ($err=$asterisk->getError()) die("Error: $err");
  if (is_array($ret)) {
    foreach($ret as $v) {
      $name=$v["name"];
      $username=$v["username"];
      $status=$v["status"];
      $domain=$soapHostname;
      if (strpos($status,"OK")!==false) $class="online";
      if (strpos($status,"UNKNOWN")!==false) $class="offline";
      if (strpos($status,"Unmonitored")!==false) $class="unknown";
      $txt.="<tr><td class=\"$class\"><img src=\"admin/public/img/$class.gif\" /> <a href=\"sip:$username@$domain\">$name</a></td><td class=\"$class\">$class</td></tr>";
    }
    $html="<table id=\"directory\">";
    $html.="<th>".$cwlang["phonebook"]["name"]."</th><th>".$cwlang["phonebook"]["status"]."</th>";
    $html.="$txt</table>";
  }
  ob_start();
?>
  <div class="SectionHeader">
    <h1><?=$cwlang["phonebook"]["title"]?></h1>
  </div>
  
  <h2><?=$cwlang["phonebook"]["personal"]?></h2>
  <p class="blockintro">
    <?=$cwlang["phonebook"]["description"]?>
  </p>
  <div class="block">
    <?=$html?>
  </div>
<? // record the contents and output it into the template
  $contents=ob_get_contents();
  ob_end_clean();

  //================ SIDEBAR ================
  ob_start(); 
  ?>
        <div class="Sidebar">
          <h1><?=$cwlang["phonebook"]["information"]?></h1>
          <p><?=$cwlang["phonebook"]["sidebarText"]?></p>
          <div style="text-align: center"><img src="admin/public/img/book.jpg" alt="Rubrica" align="center"/></div>
        </div>
  <?  
  $sidebar=ob_get_contents();
  ob_end_clean();
  
  $smarty->assign("section", "contacts");
  $smarty->assign("subsection", "");
  $smarty->assign("contents", $contents);
  $smarty->assign("sidebar", $sidebar);
  $smarty->display('main.tpl');
?>

