<?
/**
 * VoiceOne Settings/IO/
 *
 * Frontend to provide access to the IO system in voiceone. It allow to turn off 
 * or reboot the pc.  
 * @package voiceone
 * @subpackage  settings_io
 */
 
  include ("../../admin/config/cfg.php");
  global $cwlang, $cwLanguage;
 	sajax_init();

  //================ PAGE LOGIC ================

  if ($_GET["mode"]=="halt") {
    //exec ("sudo /sbin/shutdown -h now");
    $asterisk->shutdown("halt");
    $alert="<div class=\"AlertBad\"><img src='$relBasePath/public/img/ico-progress.gif' > ".$cwlang["io"]["shutingDown"]."</div>";    
  }
  
  if ($_GET["mode"]=="reboot") {
    //exec ("sudo /sbin/shutdown -r now");
    $asterisk->shutdown("reboot");
    $alert="<div class=\"AlertBad\"><img src='$relBasePath/public/img/ico-progress.gif' > ".$cwlang["io"]["rebooting"]."</div>";    
  }
  
  
  
  //================ MAIN CONTENTS ================
  ob_start();
  ?>
  <div class="SectionHeader">
    <?=$alert?>
    <h1><?=$cwlang["io"]["title"]?></h1>
  </div>
  <div id="editPane" style="padding: 10px">
    <table>
      <tr>
        <td><a href="?mode=reboot"  onclick="if (confirm('Sicuro di voler RIAVVIARE il centralino?')) return true; else return false;"><img src="<?=$relBasePath?>/public/img/reboot.png"></a></td><td><a href="?mode=reboot"  onclick="if (confirm('Sicuro di voler RIAVVIARE il centralino?')) return true; else return false;"><?=$cwlang["io"]["reboot"]?></a></td>
      </tr>
      <tr>
        <td><a href="?mode=halt" onclick="if (confirm('Sicuro di voler SPEGNERE il centralino?')) return true; else return false;"><img src="<?=$relBasePath?>/public/img/shutdown.png"></a></td><td><a href="?mode=halt" onclick="if (confirm('Sicuro di voler SPEGNERE il centralino?')) return true; else return false;"><?=$cwlang["io"]["shutDown"]?></a></td>
      </tr>
    </table>
  </div>
  <?
  $contents=ob_get_contents();
  ob_end_clean();

  //================ SIDEBAR ================
  ob_start(); 
  ?>
        <div class="Sidebar">
          <h1><?=$cwlang["io"]["sidebarTitle"]?></h1>
          <?=$cwlang["io"]["sidebarDesc"]?>
        </div>
  <?  
  $sidebar=ob_get_contents();
  ob_end_clean();

  //================ SETTINGS ================
 	sajax_handle_client_request();

  $smarty->assign("section", "io");
  $smarty->assign("subsection", "");
  $smarty->assign("templateType", "TwoColLeft");  //OneCol, TwoColLeft, TwoColRight
  $smarty->assign("contents", $contents);
  $smarty->assign("sidebar", $sidebar);
  $smarty->assign("ajax", $js);
  $smarty->display('settings.tpl');
?>

