<? include("../settings.php"); ?>
<? include("session.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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SP Admin Panel</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Include all CSS/JS -->
        <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/jquery.dataTables.css" rel="stylesheet">
    <link href="http://cdn.datatables.net/responsive/1.0.1/css/dataTables.responsive.css" rel="stylesheet">
    

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-2.1.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="http://cdn.datatables.net/responsive/1.0.1/js/dataTables.responsive.js"></script>

    <!-- End of all CSS/JS -->
      <script>
          
      </script>
    
   </head>
<body>


<? include("nav_menu.php"); ?>
    <?
        if (isset($_REQUEST['submit'])){
            $insert = array(
				"user_login" => $_REQUEST['user_login'],
				"user_password" => $_REQUEST['user_password'],
				"user_admin" => "0",
				"user_master" => "0"
            );
            $db->insert("tbl_abstract_user", $insert);
            $results = $db->run("select last_insert_id() as lastid;");
            $user_id = $results[0]['lastid'];          
			$insert = array(
				"user_id" => $user_id,
				"topic_id" => $_REQUEST['topic_id']
			);
			$db->insert("tbl_topic_user", $insert);
            echo "<script>alert('Abstract User Added');</script>";
        }
    ?>
      <div class="well">
<div class="content" bgcolor="#FFFFD0">
<div class="col-12 feature">
<div class="panelCheck">
    <div class="panel-heading">
        <h3 class "panel-title"><strong>SP Admin Panel - Add Delegate</strong></h3>
    </div>

    
    <div class="well well-lg">
        <form class="form-horizontal" method="post" action="">
        
		<div class='form-group'>
            <label for='user_login' class='col-lg-4 control-label'>Login</label>
            <div class='col-lg-6 text-left'>
                <input type="text" class="form-control" name="user_login" id="user_login">
            </div>
        </div>    	
        <div class='form-group'>
            <label for='user_password' class='col-lg-4 control-label'>Password</label>
            <div class='col-lg-6 text-left'>
                <input type="text" class="form-control" name="user_password" id="user_password">
            </div>
        </div>
		<div class='form-group'>
            <label for='topic_id' class='col-lg-4 control-label'>Topic</label>
            <div class='col-lg-6 text-left'>
                <select class="form-control" name="topic_id" id="topic_id">
				<?
					$results = $db->select("tbl_topic");
					foreach ($results as $result){
						echo "<option value='".$result['topic_id']."'>".$result['topic']."</value>";
					}
				?>
				</select>
            </div>
        </div>
		
		
        </div>            
            <center>
            <button type="submit" name="submit" class="btn btn-info">Add New Abstract User</button>
            <button type="reset" class="btn btn-default" onclick="window.location='user_admin.php';">Cancel</button>
            </center>
        </form>        
        
        
    </div>
    
<!-- /.modal -->
</div>
</div>
</div>
</div>
</body>
</html>
