<?php

 require_once("../admin_common.php");
 validate_session($identity);

$thisoperator = new CSLH_operator();
$chatarray = $thisoperator->arrayofchats();
 
if($UNTRUSTED['whattodo'] == "update"){
	if($UNTRUSTED['autoin']=="Y"){  $auto = "Y"; } else { $auto = "N"; }
	if($UNTRUSTED['cellin']=="Y"){  $cellin = "Y"; } else { $cellin = "N"; }
	
  $query = "UPDATE livehelp_users SET cellphone='".$UNTRUSTED['cellphone']."',auto_invite='$auto',cell_invite='$cellin' WHERE sessionid='".$identity['SESSIONID']."'";	
  $mydatabase->query($query);
 
  
}
 
// get the info of this user.. 
$query = "SELECT * FROM livehelp_users WHERE sessionid='".$identity['SESSIONID']."'";	
$people = $mydatabase->query($query);
if($people->numrows() != 0){
 $people = $people->fetchRow(DB_FETCHMODE_ASSOC);
 $UNTRUSTED['myid'] = $people['user_id'];
 $operator_id = $UNTRUSTED['myid'];
 $channel = $people['onchannel'];
 $cellphone =  $people['cellphone'];
 if($people['auto_invite'] == "Y"){ $auto_invite = " CHECKED "; } else {  $auto_invite = "   ";}
 if($people['cell_invite'] == "Y"){ $cell_invite = " CHECKED "; } else {  $cell_invite = "   ";}
}  
  
$jsrn = get_jsrn($identity);

 
 
 
$timeof = date("YmdHis");
 
if(isset($starttimeof)){
  $timeof = $starttimeof;
}
  
if(!($serversession))
  $mydatabase->close_connect();
 
 $selectedtab = "settings";
 include "mobileheader.php";
 
?>
<script type="text/javascript">
var myScroll;
window.addEventListener('orientationchange', setHeight);

function setHeight() {
	document.getElementById('wrapper').style.height = window.orientation == 90 || window.orientation == -90 ? '85px' : '300px';
}

function loaded() {

	setHeight();
	document.addEventListener('touchmove', function(e){ e.preventDefault(); });
	myScroll = new iScroll('currentwindow');
 
}
document.addEventListener('DOMContentLoaded', loaded);


</script>
	 
      <div id="wrapper">
       <div id="currentwindow">           	
       	   <form action=settings.php method=post>
       	   	<input type=hidden name=whattodo value=update>
       	   <b><input name=autoin type=checkbox value="Y" <?php echo $auto_invite; ?> >Auto Invite Enabled</b>
       	   <br>
       	   <hr>
       	   <b><input name=cellin type=checkbox value="Y" <?php echo $cell_invite; ?> >Cell Phone alert Chat requests:</b>
       	   <br>Phone#<input type=text name=cellphone value="<?php echo $cellphone;?>"><br>
       	   <i>MUST BE FULL E-mail to phone for example:<br>
       	  <b>xxxxxxxxxx@txt.att.net</b>
       	   <br>
       	   <hr>
        	 <input type=submit value=UPDATE></form>
       	   <hr>
       	   <br><br>
       	   <a href=logout.php><img src=images/logout.jpg width=109 height=29 border=0></a>
       	   <hr>
       	   
       </div>
      </div>
 
    </body>
</html>