<?php
	session_start();
	include('../conn.php');
	$branch=$_SESSION['branch'];
		$profid=$_SESSION['profid'];
	if (!isset($_SESSION['profid']) ||(trim ($_SESSION['profid']) == '')) {
	header('location:../');
    exit();
	}
	
	$query=mysqli_query($conn,"select * from branch where branch_id='$branch'")or die(mysqli_error($conn));
  $row=mysqli_fetch_array($query);
           $branch_name=$row['branch_name'];
           
           
	$sq=mysqli_query($conn,"select * from `user` where user_id='".$_SESSION['id']."'");
	$srow=mysqli_fetch_array($sq);
		
	if ($srow['access']!=1){
		header('location:../');
		exit();
	}
	
	$user=$srow['username'];
?>
<!DOCTYPE html>
<html>
<head>

	<link rel="icon" href="../upload/bulogo_1650454325.png" type="image/ico">
	
	
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Home | <?php include('../dist/includes/title.php');?></title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

	
	<link href="../css/dataTables.bootstrap.css" rel="stylesheet">
	<link href="../css/dataTables.responsive.css" rel="stylesheet">
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="../dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="../plugins/select2/select2.min.css">
	
	
	 <script src="https://unpkg.com/boxicons@2.1.4/dist/boxicons.js"></script>
	<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
	
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="font-awesome.min.css">
</head>
<body style="background-color: #ECF0F5">
<?php
//session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;
date_default_timezone_set("Asia/Manila"); 
?>
<?php
include('../dist/includes/dbcon.php');

$branch=$_SESSION['branch'];
$access=$_SESSION['access'];
$id=$_SESSION['id'];
$query=mysqli_query($con,"select * from branch where branch_id='$branch'")or die(mysqli_error($con));
  $row=mysqli_fetch_array($query);
           $branch_name=$row['branch_name'];
		   
		  $query1=mysqli_query($con,"select * from user where user_id='$id'")or die(mysqli_error($con));
  $row1=mysqli_fetch_array($query1); 
?>




<?php
//session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;
date_default_timezone_set("Asia/Manila"); 
?>
<?php
include('../dist/includes/dbcon.php');

$branch=$_SESSION['branch'];
$access=$_SESSION['access'];
$id=$_SESSION['id'];
$query=mysqli_query($con,"select * from branch where branch_id='$branch'")or die(mysqli_error($con));
  $row=mysqli_fetch_array($query);
           $branch_name=$row['branch_name'];
		   
		  $query1=mysqli_query($con,"select * from user where user_id='$id'")or die(mysqli_error($con));
  $row1=mysqli_fetch_array($query1); 
?>


<style>
    
.show-menu {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-decoration: none;
    color: #fff;
   
    text-align: center;
    padding: 10px 0;
    display: none;
}
/*Hide checkbox*/
input[type=checkbox]{
    display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
    display: block;
}
/*Responsive Styles*/
@media screen and (max-width : 760px){
    /*Make dropdown links appear inline*/
    #menu {
        position: static;
        display: none;
    }
    ul {
        position: static;
        display: block;
    }
    /*Create vertical spacing*/
    li {
        margin-bottom: 1px;
    }
    /*Make all menu links full width*/
    ul li, li a {
        width: 100%;
    }
    /*Display 'show menu' link*/
    .show-menu {
        display:block;
    }
	
	
	
}
</style>


<style>

						ul li ul li a {display:block !important;} 
						ul li ul li:hover {
							background-color:#337AB7;
							color:black;
							}
						#kid {
background-color:#3C8DBC;
							color:black;
						}							
							.navbar-nav li a:hover
{
    background-color: #337AB7;
	color:black;
}

 .dropdown-menu li a:hover
{
    background-color: #337AB7;
	color:black;
}

#menu li a:hover{
	background-color:#337AB7;
							
}

#tarzan li ul li a:hover{
	background-color:#337AB7;
							
}

#walk:not(:hover{
	
	background-color:yellow;
)}

  .newstyle {
            color: white;
        }

						</style>
						
						 <div class="wrapper">
						 
						 
						 



           <header class="main-header" style="background-color: #3C8DBC;">
        <nav class="navbar navbar-static-top" style="background-color: #3C8DBC;">
		
          <div class="container" style="background-color: #3C8DBC;width:90%;  margin-left:10px;">
            <a href="home.php" class="navbar-brand" style="margin-left:5px">     <b><i  class="glyphicon glyphicon-user"></i> <?php echo $branch_name;?> </b></a>
             
            <div class="navbar-header" style="padding-left:25"> <img src="../dist/img/bulogo.png" alt="avatar" width="52" style="border-radius:50%;" height="52" >
            
            <span>&nbsp </span> <span>&nbsp </span> 
            </div>
  
            <!-- Navbar Right Menu -->
              <div class="navbar-custom-menu-left">
                <label for="show-menu"  class="show-menu" style="margin-left:300px;margin-top:-45px;position:absolute;"><i class="fa fa-bars"></i></label>
    <input type="checkbox" id="show-menu" role="button">
                 
                <ul class="nav navbar-nav" id="menu">
				
				
				      <li class="" >
             <a href="../pages/home.php" style="color:white;" class="dropdown-toggle">
                             <i href="home.php../pages/" class="glyphicon glyphicon-home text-orange"></i> Home
                            </a>
                          </li>
						  <li>
						 <a href="../pages/addannouncement.php" style="color:white;" class="dropdown-toggle">
                              <i class="glyphicon glyphicon-envelope text-orange"></i> Add Announcements
                            </a>
                          </li>
				   
				   
				   
				   <li >
                    <!-- Menu toggle button -->
                    <a href="../pages/professorsetschedule.php" style="color:white;" class="dropdown-toggle">
                      <i class="glyphicon glyphicon-stats text-orange"></i> Schedule
                     
                    </a>
                    
						  
						
						  
				
                  </li>
                  <!-- Tasks Menu -->
				  
				  
				    <li class="">
                
                    <a href="../pages/professordrive.php" class="dropdown-toggle" style="color:white;">
                      <i class="glyphicon glyphicon-th-list text-orange"></i>
       Drive
                    </a>
                  </li>
				  
				  
				  
				    <li class="">
                
                    <a href="../admin/user.php" class="dropdown-toggle" style="color:white;">
                      <i class="glyphicon glyphicon-list-alt text-orange"></i>
                      Add Users
                    </a>
                  </li>
				  
				  
				  
				     <li class="">
                
                    <a href="../pages/professorsetgroup.php" class="dropdown-toggle" style="color:white;">
                      <i class="glyphicon glyphicon-list-alt text-orange"></i>
                      Set Group
                    </a>
                  </li>
				  
				     <li class="">
                
                    <a href="../pages/professorassignlistadd.php" class="dropdown-toggle" style="color:white;">
                      <i class="glyphicon glyphicon-list-alt text-orange"></i>
                      Assign List
                    </a>
                  </li>
				  
				  
                 
				  				  
				  <?php
include('../dist/includes/dbcon.php');

$idko=$_SESSION['id'];
$query=mysqli_query($con,"select * from user where user_id='$idko'")or die(mysqli_error($con));
  $row=mysqli_fetch_array($query);
           $access=$row['access'];
		   
		   if($access == 1){
			   $love="admin";
		   }elseif($access == 2){
			    $love="user";
		   }
?>
                  <!-- Notifications Menu -->
                  <li class="dropdown notifications-menu">
                    <!-- Menu toggle button -->
                    <a href="../<?php echo ($love); ?>" style="color:white;">
                      <i class="glyphicon glyphicon-envelope text-orange"></i> Chats
                     
                    </a>
              
                  </li>
				  
				 
				  
				  
				  
                
				  
				  
				  <li class="">
                    <!-- Menu Toggle Button -->
                    <a href="../pages/profile.php" class="dropdown-toggle" style="color:white;">
                      <i class="glyphicon glyphicon-cog text-orange"></i>
                      <?php echo "My Profile";?>
                    </a>
                  </li>
                  <li class="">
                    <!-- Menu Toggle Button -->
                    <a class="dropdown-toggle logout" style="color:white; margin-right:-20px"><i class="glyphicon glyphicon-off text-orange"></i> Logout</a>
					
					
                  </li>
                  
                </ul>
              </div><!-- /.navbar-custom-menu -->
          </div><!-- /.container-fluid -->
        </nav>
      </header>
	  
	

  <div class="content-wrapper">
        <div class="container">

	

<!-- Delete Room -->
    <div class="modal fade" id="logout" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Logout Account</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<h3><center>Are you sure?</center></h3>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="button" class="btn btn-danger" id="confirm_logout"><span class="glyphicon glyphicon-check"></span> Logout</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->





<script>
$(document).ready(function(){
	
	$(document).on('click', '.logout', function(){
		var rid=$(this).val();
		$('#logout').modal('show');
		$('.modal-footer #confirm_logout').val(rid);
	});
	
	
	$(document).on('click', '#confirm_logout', function(){
		$('#logout').modal('hide');
		$('body').removeClass('modal-open');
		$('.modal-backdrop').remove();
			window.location.href='../pages/logout.php';
	});
	
	
	});
</script>

	  
	   
<div class="container">
	<div class="row">
	
 <section class="content-header">
            <h1>
              <a class="btn btn-lg btn-warning" href="../pages/home.php">Back</a>
            
            </h1>
            <ol class="breadcrumb">
              <li><a href="../pages/home.php"><i></i> Home</a></li>
              <li class="active">Chat Lists</li>
            </ol>
          </section>


    <div class="box box-primary">
    <div style="height:50px;">
        
        	
		<span style="font-size:18px; margin-left:10px; position:relative; top:13px;">List of Chat Rooms</span>
		<div class="pull-right" style="margin-right:10px; margin-top:7px;">
			<a href="#add_chatroom" data-toggle="modal" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Add</a>
		</div>
	</div>
	
<div style="margin-left: 10px; margin-right: 10px">
	<table width="100%" class="table table-bordered table-hover" id="example1">
        <thead>
            <tr style="background-color:#008B8B;color:white;">
                <th>Chat Room Name</th>
                
				<th>Date Created</th>
				<th>Action</th>
			</tr>
		</thead>
		<tbody>
		<?php
			$query=mysqli_query($conn,"select * from chatroom where profid='$profid' order by date_created desc");
			while($row=mysqli_fetch_array($query)){
				$lolipop=$row['chatroomid'];
				
				$num=mysqli_query($conn,"select * from chat_member where chatroomid='".$row['chatroomid']."'");
			?>
			<tr>
				<td><span class="glyphicon glyphicon-user"></span><span class="badge"><?php echo mysqli_num_rows($num); ?></span> <input type="hidden" id="name<?php echo $row['chatroomid']; ?>" value="<?php echo $row['chat_name']; ?>"><?php echo $row['chat_name']; ?></td>
				<!-- <td><input type="hidden" id="pass<?php echo $row['chatroomid']; ?>" value="<?php echo $row['chat_password']; ?>"><?php echo $row['chat_password']; ?></td> -->
				
				
				<td><?php echo date('M d, Y', strtotime($row['date_created'])); ?></td>
				<td><a class="btn btn-lg btn-warning" style="font-size:8px" href="chatroom.php?toid=<?php echo $row['chatroomid']; ?>" class="btn btn-info">Chat <span class="glyphicon glyphicon-comment"></span> </a> 
					<button class="btn btn-lg btn-warning edit" style="font-size:8px" value="<?php echo $row['chatroomid']; ?>">Edit <i class='bx bx-edit' ></i></button> 
					<button class="btn btn-lg btn-warning delete" style="font-size:8px" value="<?php echo $row['chatroomid']; ?>">Delete <span class="glyphicon glyphicon-trash"></span></button>
				</td>
			</tr>
			<?php
			}
		?>
        </tbody>
    </table>    
</div>	
</div>
</div>
	</div>
</div>

</div>

<!-- Delete Room -->
    <div class="modal fade" id="delete_room" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Deleting Room...</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<h3><center>Are you sure?</center></h3>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="button" class="btn btn-danger" id="confirm_delete"><span class="glyphicon glyphicon-check"></span> Delete</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->



<!-- Delete Room -->
    <div class="modal fade" id="logout" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Logout Account</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<h3><center>Are you sure?</center></h3>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="button" class="btn btn-danger" id="confirm_logout"><span class="glyphicon glyphicon-check"></span> Logout</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->






<!-- Edit Room -->
    <div class="modal fade" id="edit_room" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Edit Room</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Chat Room Name:</span>
						<input type="text" style="width:350px;" class="form-control" id="room_name">
					</div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Password:</span>
						<input type="text" style="width:350px;" class="form-control" id="room_password">
					</div>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="button" onclick="return confirm('Are you sure you want to update?');" class="btn btn-success" id="confirm_update"><span class="glyphicon glyphicon-check"></span> Update</button>
				
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->

<!-- Add Chat Room -->
    <div class="modal fade" id="add_chatroom" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Add New Chat Room</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
				<form>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Chat Room Name:<a style= "color:red;">*</a></span>
						<input type="text" style="width:350px;" class="form-control" id="chat_name" required>
					</div>
					
						<input type="hidden" style="width:350px;" class="form-control" id="chat_password">
					
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="button" class="btn btn-primary" id="addchatroom"><span class="glyphicon glyphicon-check"></span> Add</button>
				</form>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->
<!-- Logout-->
    <div class="modal fade" id="logout" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Logging out...</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<center><strong><span style="font-size: 15px;">Username: <?php echo $user; ?></span></strong></center>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <a href="logout.php" class="btn btn-danger"><span class="glyphicon glyphicon-log-out"></span> Logout</a>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->

<!-- Update Photo-->
    <div class="modal fade" id="photo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Uploading Photo...</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
					<form method="POST" enctype="multipart/form-data" action="update_photo.php">
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Photo:</span>
						<input type="file" style="width:350px;" class="form-control" name="image">
					</div>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-upload"></span> Upload</button>
					</form>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->

<!-- Account-->
    <div class="modal fade" id="account" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">My Account</h4></center>
                </div>
                <div class="modal-body">
				<div class="container-fluid">
				<form method="POST" action="update_account.php">
					<div style="height: 10px;"></div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Name:</span>
						<input type="text" style="width:350px;" class="form-control" name="mname" value="<?php echo $srow['name']; ?>">
					</div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Username:</span>
						<input type="text" style="width:350px;" class="form-control" name="musername" value="<?php echo $srow['username']; ?>">
					</div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Password:</span>
						<input type="password" style="width:350px;" class="form-control" name="mpassword" value="<?php echo $srow['password']; ?>">
					</div>
					<hr>
					<span>Enter current password to save changes:</span>
					<div style="height: 10px;"></div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Password:</span>
						<input type="password" style="width:350px;" class="form-control" name="cpassword">
					</div>
					<div class="form-group input-group">
						<span class="input-group-addon" style="width:150px;">Again:</span>
						<input type="password" style="width:350px;" class="form-control" name="apassword">
					</div>
                </div> 
				</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-check"></span> Update</button>
				</form>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<!-- /.modal -->

<script src="../js/jquery.dataTables.min.js"></script>
<script src="../js/dataTables.bootstrap.min.js"></script>
<script src="../js/dataTables.responsive.js"></script>
<script>
$(document).ready(function(){
	
	$('#chatRoom').DataTable({
	"bLengthChange": true,
	"bInfo": true,
	"bPaginate": true,
	"bFilter": true,
	"bSort": false,
	"pageLength": 7
	});
	
	$(document).on('click', '#addchatroom', function(){
		chatname=$('#chat_name').val();
		chatpass=$('#chat_password').val();
			$.ajax({
				url:"add_chatroom.php",
				method:"POST",
				data:{
					chatname: chatname,
					chatpass: chatpass,
				},
				success:function(data){
				window.location.href='chatroom.php?toid='+data;
				}
			});
		
	});
	//
	$(document).on('click', '.delete', function(){
		var rid=$(this).val();
		$('#delete_room').modal('show');
		$('.modal-footer #confirm_delete').val(rid);
	});
	
	
	
	$(document).on('click', '.logout', function(){
		var rid=$(this).val();
		$('#logout').modal('show');
		$('.modal-footer #confirm_logout').val(rid);
	});
	
	
	$(document).on('click', '#confirm_logout', function(){
		$('#logout').modal('hide');
		$('body').removeClass('modal-open');
		$('.modal-backdrop').remove();
			window.location.href='../pages/logout.php';
	});
	
	
	
	
	
	
	
	$(document).on('click', '#confirm_delete', function(){
		var nrid=$(this).val();
		$('#delete_room').modal('hide');
		$('body').removeClass('modal-open');
		$('.modal-backdrop').remove();
			$.ajax({
				url:"deleteroom.php",
				method:"POST",
				data:{
					id: nrid,
					del: 1,
				},
				success:function(){
					window.location.href='index.php';
				}
			});
	});
	
	$(document).on('click', '.edit', function(){
		var rid=$(this).val();
		var name=$('#name'+rid).val();
		var pass=$('#pass'+rid).val();
		$('#edit_room').modal('show');
		$('.modal-body #room_name').val(name);
		$('.modal-body #room_password').val(pass);
		$('.modal-footer #confirm_update').val(rid);
	});
	
	$(document).on('click', '#confirm_update', function(){
		var nrid=$(this).val();
		var roomname=$('#room_name').val();
		var roompass=$('#room_password').val();
		$('#edit_room').modal('hide');
		$('body').removeClass('modal-open');
		$('.modal-backdrop').remove();
			$.ajax({
				url:"update_room.php",
				method:"POST",
				data:{
					id: nrid,
					name: roomname,
					pass: roompass,
					edit: 1,
				},
				success:function(){
					window.location.href='index.php';
				}
			});
	});
 
});
</script>

  <script>
    $(function () {
        $("#example2").DataTable();
        $('#example1').DataTable({
          "paging": true,
          "lengthChange": true,
          "searching": true,
          "ordering": false,
          "info": true,
		  "lengthMenu": [3, 5, 10, 25, 50, 100],
          "autoWidth": true
        });
      });
    </script>
</body>
</html>