<div id="content">
<h2><?php echo $this->lang->L_STATUS;?></h2>
<?php echo $this->render('sql-server/head-navi.phtml'); ?>
<div style="height:20px;">
    <div style="width:32px;float: left">
        &nbsp;
        <span id="loader" class="invisible"><?php echo $this->getIcon('ajax-loader');?>
        </span>
    </div>
    <div style="padding-top:2px;">
        <?php echo $this->lang->L_REFRESHTIME .': <span id="refreshTime">'.$this->interval.'</span> '.$this->lang->L_SECONDS;?>
    </div>
</div>
<div  id="processlist-table">
<table class="bdr">
    <thead>
    <tr class="thead">
        <th><?php echo $this->lang->L_ACTION;?></th>
        <th>#</th>
        <th><?php echo $this->lang->L_PROCESS_ID;?></th>
        <th><?php echo $this->lang->L_DB_USER;?></th>
        <th><?php echo $this->lang->L_DB_HOST;?></th>
        <th><?php echo $this->lang->L_DB;?></th>
        <th><?php echo $this->lang->L_COMMAND;?></th>
        <th><?php echo $this->lang->L_TIME;?></th>
        <th><?php echo $this->lang->L_STATUS;?></th>
        <th><?php echo $this->lang->L_INFO;?></th>
    </tr>
    </thead>
    <tbody id="processlist">
        <tr>
            <td colspan="10"></td>
        </tr>
    </tbody>
</table>
</div>
<script type="text/javascript">
<?php
$getProcesslistUrl = $this->url(array(
        'controller'=>'sql.server',
        'action'=>'get.processlist')
);
?>
function refreshProcesslist() {
    setOpacity('#processlist-table', 0.5);
    $('#loader').show();
    $.ajax({
        url: '<?php echo $getProcesslistUrl;?>',
        cache: false,
        success: function (data) {
            $('#loader').hide();
            $('#processlist').html(data);
            setOpacity('#processlist-table', 1);
            $('#refreshTime').html(<?php echo $this->interval;?>);
            window.setTimeout("refreshTimer()", 1000);
        }
    });
}

function refreshTimer()
{
    var seconds = $('#refreshTime').html();
    seconds--;
    if (seconds <= 0){
        $('#refreshTime').html(0);
        refreshProcesslist();
        seconds = <?php echo $this->interval;?>;
    } else {
        window.setTimeout("refreshTimer()", 1000);
        $('#refreshTime').html(seconds);
    }
}

$(document).ready(function() {
    refreshProcesslist();
});
</script>
<br /><br /><br />
</div>