<?php
function status($status_id)
{
	switch($status_id)
	{
		case 0:
			return 'empty';
			break;

		case 1:
			return 'active';
			break;

		case 2:
			return '<b>disabled</b>';
			break;
	}
}
?>

<div>
<form name="idselect" action="/partners/keys" method="POST">

KEY # or user field search: <?=form_input(array('name'=>'search','size'=>10))?><?=form_submit('filter','filter')?>

</form>

<form name="idselect" action="/partners/keys" method="POST">
<?=form_hidden('empty',1)?>
<input type="submit" value="Show only the empty keys" />
</form>


<form name="idselect" action="/partners/keys" method="POST">
<?=form_hidden('disabled',1)?>
<input type="submit" value="Show only the disabled keys" />
</form>

<form name="idselect" action="/partners/keys" method="POST">

<input type="submit" value="Show all" />
</form>
<form name="idselect" action="/partners/keys" method="POST">
Limit: <?=form_input(array('name'=>'limit','size'=>3,'value'=>$limit))?><?=form_submit('filter','Limit')?>
</form>
<form name="idselect" action="/partners/keys" method="POST">
From: <?=form_input(array('name'=>'from','size'=>6,'value'=>$from))?>
To: <?=form_input(array('name'=>'to','size'=>6,'value'=>$to))?>
<br />
<?=form_submit('filter','Range')?>
</form>
</div>

<?if($sorok):?>
	<br />
	Result(s) <?=$min?> - <?=$max?> of <?=$found?><br />
	<table width="100%" cellpadding="2" cellspacing="0" border="0">
		<tr>
			<th width="80">Key</td>
			<th width="80">IDcode </td>
			<th width="60">Status</td>
			<th width="30">Lan</td>
			<th width="auto">User</td>
			<th width="auto">Info</td>
		</tr>
		<?foreach($sorok as $s):?>

			<?if($sorok++%2 == 0):?>
				<tr valign="top">
			<?else:?>
				<tr valign="top">
			<?endif;?>

			<tr valign="top">
				<td><?=anchor('partners/key/'.$s->hlNum,$s->hlNum)?></td>
				<td><?if(substr($s->hlNum,0,2)=="99"):?><?=archlineID($s->hlNum)?><?endif;?> </td>
				<td><?=status($s->hlStat)?></td>
				<td align="center"><?=$s->hlLan?></td>
				<td>
					<?if(is_numeric($s->hlUser)):?>
						<?=iconv("ISO-8859-1", "UTF-8",$s->strCompany.' '.$s->strName)?>
					<?else:?>
						<?=$s->hlUser?>
					<?endif;?>
				</td>
				<td><?=$s->hlInfo?></td>
			</tr>
		<?endforeach;?>
	</table>
<?if($pages==-1):?>
<?elseif($page==1):?>
<?=anchor('partners/keys/2','Next >')?>&nbsp;<?=anchor('partners/keys/'.$pages,'Last >>')?>
<?elseif($page!=$pages):?>
<?=anchor('partners/keys/1','<< First')?>
&nbsp;
<?=anchor('partners/keys/'.($page-1),'< Previous')?> - <?=anchor('partners/keys/'.($page+1),'Next >')?>
&nbsp;
<?=anchor('partners/keys/'.$pages,'Last >>')?>
<?else:?>
<?=anchor('partners/keys/1','<< First')?>&nbsp;<?=anchor('partners/keys/'.($page-1),'< Previous')?>
<?endif;?>
<?endif;?>

<?
function archlineID($kulcs){
	if(!$kulcs)
		return false;

	$ch = substr(md5($kulcs."Dc43dT"),5,2);
	if($ch[0]=="0")
		$ch[0]=1;
	if($ch[1]=="0")
		$ch[1]=1;

	return $kulcs.$ch;

}
?>
