//$council->add_council("UNHRC");
$list = $council->get_council();
?>

	<?php 
$council = new delcountry_crud();
//$council->add_country("Afganistan",10);
//$council->add_country("USA",10);
//$council->add_country("India",10);
//$council->add_country("Japan",10);
//$council->update_count("USA",10);
//$council->add_country("UK",10);
$counts = $council->get_count();
?>
	<?php 
$info = new info_crud();
$status = $info->readStatus($username);
if ($status) {
    ?>
	<br>
	<div class="form-group">
    <label class="control-label col-sm-4" for="cfp">Council First Preference:</label>
    <div class="col-sm-8">
	<?php 
    $idf = "cfp";
    $ids = "csp";
    $idt = "ctp";
    $cp11 = "1cp1";
    $cp12 = "1cp2";
    $cp13 = "1cp3";
    $cp14 = "1cp4";
          	</div>
        	</div>
		<div class="jumbotron">
    		<h1>Step 1 | International Press Registrations</h1>
	 <p class='lead'><br></p>
        <p class='lead'>Please Select the Position You would Like To Apply For In International Press<br></p>
	</div>        
	<div class='row'>
		  			<div class="col-lg-6">
			<form class='form-horizontal' role='form' method='post' action='<?php 
echo htmlspecialchars($_SERVER['PHP_SELF']);
?>
' >
	
	<?php 
$info = new info_crud();
$valid = $info->readStatus($username);
if ($valid) {
    echo "<div class='form-group'><label class='control-label col-sm-4' for='pa'>Positions Available:</label><div class='col-sm-8'>";
    $test = new ipStep1_crud();
    $cursor = $test->read($username);
    if ($cursor->count() != 0) {
        foreach ($cursor as $doc) {
            echo "<input class='form-control' type='text' value=" . $doc['positionAvailable'] . " readonly>";
        }
    } else {
        echo "<select class='form-control' id='pa' name='pa' placeholder='' required>";
        echo "<option selected='selected' value='Select' disabled='disable'>Select</option>";
        foreach ($list as $doc) {
            echo "<option class=" . $doc . " name=" . $doc . " value=" . $doc . ">" . $doc . " </option>";
        }
          	</div>
        	</div>
		<div class="jumbotron">
    		<h1>Applicant Information</h1>
	 <p class="lead"><br></p>
        <p class="lead">Please Select the Position You would Like To Apply For In International Press<br></p>
	</div>        
	<div class="row">
		  			<div class="col-lg-6">
			<form class="form-horizontal" role="form" method="post" action="<?php 
echo htmlspecialchars($_SERVER['PHP_SELF']);
?>
" >
	
	<?php 
$infom = new info_crud();
$info = $infom->read($username);
foreach ($info as $doc) {
    echo "<div class='form-group'><label class='control-label col-sm-4' for='username'>User Name</label><div class='col-sm-12'><label class='control-label col-sm-4' for='username'>" . $_GET['username'] . "</label></div></div>";
    echo "<div class='form-group'><label class='control-label col-sm-4' for='username'>Committee</label><div class='col-sm-12'><label class='control-label col-sm-4' for='username'>" . $_GET['committee'] . "</label></div></div>";
    //echo "<div class='form-group'><label class='control-label col-sm-4' for='essay".$i."'>". $list[$i] ."</label><div class='col-sm-12'><textarea class='form-control execexp' name='essay".$i."' rows='20' id='essay".$i."' placeholder='Write your answer here' required>".$variable."</textarea></div></div>";
    //echo "<div class='form-group'><label class='control-label col-sm-4' for='essay".$i."'>". $list[$i] ."</label><div class='col-sm-12'><textarea class='form-control execexp' name='essay".$i."' rows='20' id='essay".$i."' placeholder='Write your answer here' required>".$variable."</textarea></div></div>";
}
?>
  
  </form>
  </div>   
  </div>
</div></div>

<!-- Bootstrap core JavaScript
echo "</form>";
echo "</div></div>";
echo "<div class='table-responsive'>";
if ($committee == "InternationalPress") {
    echo "<table id ='usertable' class='table table-striped'><thead><tr><th>Username</th><th>Name</th><th>Phone No.</th><th>Email ID</th><th>Institute</th><th>Position Selected</th><th>Status</th><th>View</th></tr></thead><tbody>";
} else {
    if ($committee == "ExecutiveBoard") {
        echo "<table id ='usertable' class='table table-striped'><thead><tr><th>Username</th><th>Name</th><th>Phone No.</th><th>Email ID</th><th>Institute</th><th>Status</th><th>View</th></tr></thead><tbody>";
    } else {
        if ($committee == "Delegates") {
            echo "<table id ='usertable' class='table table-striped'><thead><tr><th>Username</th><th>Name</th><th>Phone No.</th><th>Email ID</th><th>Institute</th><th>Status</th><th>View</th></tr></thead><tbody>";
        }
    }
}
echo "<table id ='usertable' class='table table-striped'><thead><tr><th>Username</th><th>Name</th><th>Phone No.</th><th>Email ID</th><th>Institute</th><th>Status</th><th>View</th></tr></thead><tbody>";
$show = new info_crud();
$info = $show->readGeneral();
$res = new result_crud();
foreach ($info as $doc) {
    $status = (new ipEssayAns_crud())->readStatus($doc['username']);
    if ($status) {
        echo "<tr>\n\t\t\t\t  <td>" . $doc['username'] . "</td>\n\t\t\t\t  <td>" . $doc['name'] . "</td>\n\t\t\t\t  <td>" . $doc['countryCode'] . $doc['phoneNumber'] . "</td>\n\t\t\t\t  <td>" . $doc['email'] . "</td>\n\t\t\t\t  <td>" . $doc['institute'] . "</td>";
        if ($committee == "InternationalPress") {
            echo "<td>Reporter</td>";
        }
        $result = $res->read($doc['username']);
        $arg1 = $doc['username'];
        $arg2 = $doc['name'];
        $arg = $arg1 . $committee;
        $argw = $arg . "view";
        $status = "InProgress";
     </div>
  </div>

   <div class="form-group"> 
    <div class="col-sm-offset-4 col-sm-8">
      <button type="submit" class="btn btn-lg btn-primary" name="submit" value="Submit">Submit</button>
    </div>
  </div>
  </form>
  </div>   
  </div>
</div></div>

<?php 
if ($status) {
    $info_crud = new info_crud();
    $info_crud->insert($username, $name, $email, $ccode, $phone, $institute, $nofmun, true);
}
?>


<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->


</body>
</html>