<?php 	if( $this->rowcount < 1) : ?>
	<table id="subadminListMatches" class="aliases">
		<tbody>
			<tr class="subadminRow divide">
			<td>
<?php 		echo $this->translate('0 Messaages in the queue') ?>
			</td>
			</tr>
		</tbody>
	</table>
	
<?php endif ?>

<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Age') ?></b></td>
			<td><b><?php echo $this->translate('Size') ?></b></td>
			<td><b><?php echo $this->translate('Id') ?></b></td>
			<td><b><?php echo $this->translate('From') ?></b></td>
			<td><b><?php echo $this->translate('Status') ?></b></td>
		</tr>

<!--
array(10) {
  ["id"]=>
  string(6) "224608"
  ["messageId"]=>
  string(16) "1UChWv-0002aA-Sq"
  ["lineType"]=>
  string(4) "main"
  ["lineStatus"]=>
  string(6) "frozen"
  ["recipient"]=>
  NULL
  ["sender"]=>
  string(21) "TAG_FROZEN_FROM_BLANK"
  ["age"]=>
  string(4) "2160"
  ["size"]=>
  string(1) "2"
  ["sessionId"]=>
  NULL
  ["logDate"]=>
  string(19) "2013-03-24 18:50:40"
}

<td><div title='<?php echo $respString;?>' class='max16chars'>
			<?php echo $respString;?>
			</div></td>

 -->

<?php if($this->rows) : ?>
<?php foreach( $this->rows as $row ) : ?>
	<?php if($row['lineType'] == 'main') : 	?>
	<?php
	if($row['sender'] == 'TAG_FROZEN_FROM_BLANK')
	{
		$row['sender'] = htmlspecialchars('<>');
	}
	if($row['lineStatus'] == 'frozen') {
			$row['status'] = '*** frozen ***';
	}
	?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['messageId'] ?>">
			<td><?php echo $row['age'] ?> s</td>
			<td><?php echo $row['size'] ?> Kb</td>
			<td><a href='#' class='exim_message_id' id='<?php echo $row['messageId'] ?>'><?php echo $row['messageId'] ?></a></td>
			<td><?php echo $row['sender'] ?></td>	
			<td><?php echo $row['status'] ?></td>	
		</tr>
	<?php endif ?>
	<?php if($row['lineType'] == 'recipent') : 	?>
		<?php if($row['lineStatus'] == 'neutral') {
			$row['lineStatus'] = '';
		} ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['messageId'] ?>">
			<td><?php echo $row['lineStatus'] ?></td>
			<td colspan='4'><div title='<?php echo $row['recipient'] ?>' class='max16chars'>
			<?php echo $row['recipient'] ?>
			</div></td>
		</tr>
	<?php endif ?>

<?php endforeach ?>
<?php endif ?>
       </tbody>
</table>

<select name="paginationSearch" style='display:none;'>
<?php echo $this->pagination ?>
</select>

<script>
$(function() 
{
	$("SELECT[name=page]").html( $("SELECT[name=paginationSearch]").html() );

	

	
	$(".exim_message_id").bind('click', function(event){

		event.preventDefault();

		var r=confirm("Do you want to delete this message?")
		if (r==true)
		{
  			
  		// var currentId = $(this).attr('id');
		// var currentId = event.target.id

		var params = {};
		params.currentId = event.target.id;

		// Launch the JSON to ask the api to delete the message
		$.get('<?php echo $this->appBaseUrl ?>/admin/dashboard/deletemessage/', params, function(message) {

			$('#primary_header H1', '#searchLogs').html("<?php echo $this->translate('Loading') ?> ...");
			$('#log-table').load('<?php echo $this->moduleBaseUrl ?>/dashboard/queuepage/index/' + ($("SELECT[name=page]").val() - 1));

		});

		}
	});

	var logCount = '<?php echo $this->rowcount ?>';

	$('#pageResults').html("<span class='logCount'><?php echo $this->rowcount ?></span> results");

	// Hide pagination if 0 results
	if(logCount == 0)
		$('.mail_row_paginator_aliases', '#searchLogs').hide();
	else
		$('.mail_row_paginator_aliases', '#searchLogs').show();

	// Last, select the page we are on
	<?php if(!empty($this->index)) :?>
		$("OPTION[value=<?php echo $this->index ?>]").attr('selected', true);
	<?php endif ?>
	
	// Last, update how many rows we matched
	$('#primary_header H1').html("Exim queue - &gt; <span class='logCount'><?php echo $this->rowcount; ?></span> results");
	
	$("SPAN.logCount").format({format:"#,###", locale:"us"});

	//resize parent to fit
	rows = $('#subadminListMatches').children('tbody').children('tr').length

	if( rows < 3 )
		rows = 3
		
	newHeightA = rows * 29
	newHeightB = $("body").innerHeight() - 230
	
	//if wants to be higher than available space then scroll
	if( newHeightA > newHeightB )
		newHeight = newHeightB
	else
		newHeight = newHeightA
	
	//set minimum height
	if( newHeight < 80 )
		newHeight = 100

	$('#subadminListMatches').parent().height( newHeight );

	// Scroll to the top for matches
	$("#log-table").scrollTo(0);
	
})
</script>