<?php

/**
 * @file
 * popup window for isdn and anolog groups
 */

chdir("..");

include "./includes/variables.php";
include "./misc/database.php";
$ba = new beroAri();
require_once ('./includes/lang.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="../includes/images/favicon.ico" type="image/x-icon">
<script type="text/javascript" language="javascript" src="../includes/validation_modul.js"></script>

<script>
function resize(){
	if(window.sizeToContent) window.sizeToContent();
}
function closeW(){
	this.window.close();
}

</script>
<TITLE>CALL PROGRESS</TITLE>
<link rel="stylesheet" href="../includes/template_css.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body onload='resize();'>
<script type="text/javascript" src="../includes/notes/wz_tooltip.js"></script>
<script type="text/javascript" language="javascript" src="../includes/js/jquery-1.5.1.js"></script>
<link type="text/css" href="../includes/css/custom-theme/jquery-ui-1.8.10.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="../includes/js/jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  $("#183_to_alerting_rules").css("display","none");
  $('#call_direction').change(function() {
	  if ($("#call_direction").attr("selectedIndex")==0) {
		  $("#callforward_rules").css("display","");
		  $("#ea_outbound_rules").css("display","");
		  $("#183_to_alerting_rules").css("display","none");
	  }else if ($("#call_direction").attr("selectedIndex")==1){
		  $("#callforward_rules").css("display","none");
		  $("#ea_outbound_rules").css("display","none");
		  $("#183_to_alerting_rules").css("display","");
	  }
  });
});

</script>
<center>
<?php
@session_start();
if((isset($_SESSION['beroari_time']))&&(($_SESSION['beroari_time']+1200)<time())){
        @session_unset();
        @session_destroy();
        echo "<script>window.opener.location='../index.php?m=sip'</script>";
        echo "<script>this.window.close();</script>";
}else{
        $_SESSION['beroari_time']=time();
}

function call_direction($dir){
	if ($dir=="SIP-ISDN" || $dir=="ISDN-SIP")	$ret="<select name='call_direction' id='call_direction' style='color:#888888;' disabled>";
	else	$ret="<select name='call_direction' id='call_direction'>";
	if ($dir=="SIP-ISDN") $ret.="<option value='SIP-ISDN' selected >SIP-ISDN</option>";
	else $ret.="<option value='SIP-ISDN'>SIP-ISDN</option>";
	if ($dir=="ISDN-SIP") $ret.="<option value='ISDN-SIP' selected>ISDN-SIP</option>";
	else $ret.="<option value='ISDN-SIP'>ISDN-SIP</option>";
	$ret.="</select>";
	return $ret;
}

function get_data(){
	$ba=new beroAri();
	if (isset($_GET['id'])){
		$q=$ba->select("select * from callprogress where id='".$_GET['id']."'");
		$e=sqlite_fetch_all($q);
		return $e;
	}
}
//echo "<script>window.opener.location='../index.php?m=isdn'</script>";
print "<br><table align=\"center\" bgcolor=\"#f0f0ec\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"450\">
<colgroup>
<col width=\"39\"></col>
</colgroup>
<tbody><tr>
<td colspan=\"2\"><img src=\"../includes/images/bg_top.png\"></td>
</tr>
<tr>
<td background=\"../includes/images/bg_left.png\" style='background-repeat:repeat-y;' width=\"30\"><img src=\"../includes/images/trans.gif\" height=\"10\" width=\"39\"></td>
<td><p align='left'><img src=\"../includes/images/berofixlogo.png\"/><hr size= \"1\" noshade></p><p><center><font size='3'>".CALL_PROGRESS_TITLE_DIS."</font></p><br><br>";
$data=get_data();
	echo ("<form class='extensions_form' name='isdn' action='callprogress_submit.php' method='POST'>

			<table border='0' style='border-collapse:collapse' width='330'>
			<tr>
			<td><b>".CALL_PROGRESS_NAME_DIS.":</b>&nbsp;</td>
			<td><input type='text' name='name' value='".$data[0]['name']."'></td>
			</tr>
			<tr>
			<td><b>".CALL_PROGRESS_DIRECTION_DIS.":</b>&nbsp;</td>
			<td>".call_direction($data[0]['direction'])."</td>
			</tr>");
	if ($data[0]['name']=="")
		echo ("<tr id='callforward_rules'>
			<td><b>".CALL_PROGRESS_CALLFORWARD_RULES_DIS.":</b>&nbsp;</td>
			<td><input type='hidden' name='callforward_rules' value='0'>
			<input type='checkbox' name='callforward_rules' value='1'></td>
			</tr>
			<tr id='ea_outbound_rules'>
			<td><b>".CALL_PROGRESS_EA_OUTBOUND_RULES_DIS.":</b>&nbsp;</td>
			<td><input type='hidden' name='ea_outbound_rules' value='0'>
			<input type='checkbox' name='ea_outbound_rules' value='1'></td>
			</tr>
			<tr id='183_to_alerting_rules'>
			<td><b>".CALL_PROGRESS_183_TO_ALERTING_RULES_DIS.":</b>&nbsp;</td>
			<td><input type='hidden' name='183_to_alerting_rules' value='0'>
			<input type='checkbox' name='183_to_alerting_rules' value='1'></td>
			</tr>");
	echo ("</table>
			<br/>");
		if (isset($_GET['id'])) echo" <input type='hidden' name='id_upd' value='". $_GET['id']."'>";
		echo ("<input name='submit' type='submit' value='".BUTTON_SAVE."'>
			 &nbsp;&nbsp;<input name='close' type='button' value='".BUTTON_CLOSE."' onclick='javascript:closeW();' onmouseover=\"Tip('".POPUPS_BUTTON_CLOSE."');\" onmouseout='UnTip();'>
			</form>");



print "<hr size= \"1\" noshade>";
print "<br><a href=\"http://www.beronet.com\" target=\"_blank\" onfocus=\"if (this.blur()) { this.blur(); }\"><img src=\"../includes/images/beroLogo.gif\" align=\"right\" border=\"0\"></a>";
print "</center></td></tr>
<tr>
<td colspan=\"2\" style=\"background-repeat:no-repeat\" background=\"../includes/images/bg_bottom.png\"><img src=\"../includes/images/trans.gif\" border=\"0\" height=\"39\" width=\"10\"><div style=\"color: white;\" align=\"right\">&nbsp;&nbsp;&nbsp;</div>
</td></tr></table>";
?>
</center>
</body>
</html>

