<?php if(!defined('ACCESS_CONTROL')) {header($_SERVER['SERVER_PROTOCOL']. ' 404'); exit('404 not found');}?>
<table class="table table-small table-condensed table-bordered">
    <thead>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Countries</th>
        <th>File</th>
        <th>Limit</th>
        <th>Loads</th>
        <th>Execs</th>
        <th style="width: 180px;">Actions</th>
    </tr>
    </thead>
    <?php if($tasks):?>
    <tbody>
    <?php foreach($tasks as $task):?>
    <tr class="<?php echo($task['status'] ? '' : 'bg-warning')?>" id="task_<?php echo $task['id']?>">
        <td><?php echo($task['id'])?></td>
        <td><?php echo($task['name'])?></td>
        <td style="vertical-align: middle;"><span title="<?php echo($task['countries'])?>" class="label label-<?php echo($task['countries_inverse']) ? 'danger' : 'success'?>"><?php echo $task['cut_countries'] ? $task['cut_countries'] : 'All' ?></span></td>
        <td>
            <?php echo($task['file'])?>
        </td>
        <td><?php echo($task['limit'])?></td>
        <td><?php echo($task['load'])?></td>
        <td><?php echo($task['exec'])?></td>
        <td>
            <a style="color: #000000;  cursor: pointer; text-decoration: underline;" data-remote-url="?do=tasks&action=toggle_status&id=<?php echo($task['id'])?>" data-method="put" title="toggle status" class="remote-button"><?php echo $task['status'] ? 'Active' : 'Stopped'?></a> |
            <a style="color: #000000;  text-decoration: underline;"  href="?do=tasks&action=edit&id=<?php echo($task['id'])?>" class="">Edit</a> |
            <a style="color: #000000; cursor: pointer; text-decoration: underline;" class="remote-button" data-remote-url="?do=tasks&id=<?=$task['id']?>" data-method="delete" data-confirm="delete?" >Del</a> |
            <a style="color: #000000; cursor: pointer; text-decoration: underline;" class="remote-button" data-remote-url="?do=tasks&id=<?=$task['id']?>&action=clearstats" data-method="delete" data-confirm="clear stats?" >Clear stats</a>
        </td>
    </tr>
    <?php endforeach?>
    </tbody>
    <?php else:?>
    <tbody>
    <tr>
        <td colspan="8">Tasks not found</td>
    </tr>
    </tbody>
    <?php endif?>
</table>

<div class="clearfix"></div>
<br>