<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Button;
use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $users_to_validate */




echo "<div class='site-overview'>";
echo '<div class="jumbotron"><h2>User validation</h2></div><div class="browser">';

 if(!empty($users_to_validate)){
  echo "<p><strong>The following users signed up and are waiting to be validated!</strong></p>";
  
 
if(isset($fq)){
	$fq=$fq."&";
}
else{
	$fq="";
}
echo '<link href="'.Yii::$app->request->baseUrl.'/css/jquery.dataTables.css" rel="stylesheet">';

//echo '<div class="left-column">';

echo "<table id='myTableUser'  class='tablesorter' width='100%'>";
echo "<thead>";
echo "<tr>
		<th id= username><a href=''>Username</a></th>
		<th id= activation_key><a href=''>Name</a></th>
		<th id= activation_key><a href=''>Institution</a></th>
		<th id= activation_key><a href=''>Activation key</a></th>
</tr></thead>";



echo "<tbody>";
foreach ( $users_to_validate as $user ) {
	echo "<tr>";
	echo "<td style=\"word-wrap: break-word\">".$user->__get('username')."</td>";
	echo "<td style=\"word-wrap: break-word\">".$user->__get('name')."</td>";
	echo "<td style=\"word-wrap: break-word\">".$user->__get('institution')."</td>";
	//echo "<td style=\"word-wrap: break-word\">".$user->__get('institution')."</td>";
	$url = Yii::$app->getUrlManager ()->createAbsoluteUrl ( [
			'validation/validation',
			'token' => $user->__get('activation_key')
	] );
	echo "<td style=\"word-wrap: break-word\"><a href=".$url.">".$user->__get('activation_key')."</a>"."</td>";
	echo "</tr>";
}
echo"</tbody></table>";
echo "</div>";
 }
 else{
 	echo "<p>No users to validate!</p>";
 }
?>
</div>
</div>
<script>
$(document).ready(function() {
	$('#myTableUser').DataTable( {
		"oLanguage": {"sSearch": "Search a user:"},
		 //paging:false,
		 //bSort:false,
		 "columns": [
		             { "width": "12" },
		            null,null,null
		           ]
	} );
	$('.browser').css('height',$('#myTableUser').height()+100);

	$('.sel').change(function() {
	    $(location).attr('href',$(this).val());
	  });
});
	 
	</script>
	<style>
	.dataTables_wrapper {
  position: absolute;
  clear: both;
  }</style>