<?php  if($count > 4){
            $tomuch = 1;
        }else{
            $tomuch = 0;
        };
?>
<script>
    function checkAlarmAdd(){
        
        if( <?php echo ($tomuch); ?>){
            alert("Er zijn teveel alarmen. Verwijder alarmen om nieuwe te kunnen toevoegen.");
        }else{
            window.location.href = "alarmen.php?i=toevoegen";
        }   
    }
</script>
<div class="col-lg-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>Alarmen overzicht</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a href="javascript:checkAlarmAdd()">  <i class="fa fa-plus"></i></a>
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-wrench"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#">Alle alarmen verwijderen</a></li>
                </ul>
                <a class="close-link">
                    <i class="fa fa-times"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Naam</th>
                        <th>Tijd</th>
                        <th>StreamUrl</th>
                        <th>Beschrijving</th>
                        <th>Acties</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    	if($stmt = $mysqli -> prepare("SELECT id, message, name, streamurl, streamport, streamip, tijd, streamdomain FROM alarm WHERE uid=?")){
                        	$stmt -> bind_param('i', $userid);
                        	$stmt -> execute();
                        	$stmt -> bind_result($id, $message, $name, $streamurl, $streamport, $streamip, $tijd, $streamdomain);
                        	while($result = $stmt -> fetch()){
                        	    print '
                        	        <tr>
                        	            <td>'.$id.'</td>
                        	            <td>'.$name.'</td>
                        	            <td>'.$tijd.'</td>
                        	            <td><a href="'.$streamdomain.'" target="_blank"><i class="fa fa-music"></i></a> '.$streamdomain.'</td>
                        	            <td>'.$message.'</td>
                        	            <td style="width: 100px !important" class="text-center valign-middle" >
							                <a href="alarmen.php?i=wijzigen&id='.$id.'"><button class="btn btn-xs btn-primary"><i class="fa fa-pencil"></i></button></a>
										    &nbsp;
							                <a href="alarmen.php?i=verwijderen&id='.$id.'"><button class="btn btn-xs btn-danger"><i class="fa fa-times"></i></button></a>
						                </td>
                        	        </tr>
                        	    ';
                        	};
                        	$stmt -> close();
                        }
                    ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
