<?
/**
 * VoiceOne Settings/Tech/options
 *
 * Frontend to provide access to the tech system in voiceone.
 * @package voiceone
 * @subpackage  settings_tech
 */
  include ("../../../admin/config/cfg.php");
  global $cwlang, $cwLanguage;
 	sajax_init();
  
  
  //================ PAGE LOGIC ================

  if (count($_POST)>0) {

    //get technology
    $tech=$_POST["technology"];

    //add options to the entry
    foreach ($_POST as $k=>$v) {
      if (substr($k,0,7)=="status_") {
        $k=substr($k,7);
        if ($v=="1") {
          $o["key"]=$k; 
          $o["value"]=$_POST["option_".$k];
          $options[]=$o;
        }
      }
    }
    
    $ret=$asterisk->putOption($tech,$options,SECTION_GENERAL);
    if ($ret>0 and $ret2=="") $alert="<div class=\"AlertGood\">".T_("The options has been saved")."</div>";
    else $alert="<div class=\"AlertBad\">".T_("The options hasn't been saved")."</div>";
  }
  
  //================ MAIN CONTENTS ================
  ob_start();
  ?>
  
  <div class="SectionHeader">
    <?=$alert?>
    <h1><?=T_("General Technology Options")?></h1>
  </div>

  <div id="basic_form">
    <form action="<?=$PHP_SELF?>" method="post">

<?    echo listOption($js, $tech, null, true, true, RULE_INCOMING);?>      

      <div class="action">
        <input type="image" src="<?=$relBasePath?>/public/img/<?=$cwLanguage?>/b-save.gif" alt="Save" />
      </div>
    </form>
  </div>      
  <?
  $contents=ob_get_contents();
  ob_end_clean();

  //================ SIDEBAR ================
  ob_start(); 
  ?>
      <div class="Sidebar">
        <?$sel="option";include("../sidebar.php");?>
        <h1><?=T_("Informations")?></h1>
        <p><?=T_("This page shows the geneal options for the technologies in use on the system. To modify this settings you have to select the option category, to enable and configure desired settings and to press save button on the end of the page.")?></p>
      </div>
  <?  
  $sidebar=ob_get_contents();
  ob_end_clean();

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

  $smarty->assign("section", "sip");
  $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');
?>

