<?php
/**
 * @author Lukas Havlicek
 * @version 1.0
 */

$this->headTitle($this->projectName);
$this->placeholder('title')->set($this->t('uzivatele-f'));
?>

<h1 class="page_title"><?=$this->t('uzivatele-f')?></h1>
        <h1 class="group_title"><?=$this->t('prehled-f')?></h1>
            <div class="main_inner2">
    			<div class="main_inner">
    			
    				 <div class="left_column">
    	                <div class="left_column_item">
    	                    <?=$this->action('left-menu', 'layout', 'admin', array('leftmenu' => $this->leftmenu)); ?>
    	                </div>
    	            </div>
    	            
    				<div class="main_text_right">
                        <h2 class="section_heading"><?=$this->t('uzivatele-f')?></h2>
						
                        <?php if ($this->requests->count()) : ?>
                        <h2 class="section_heading"><?=$this->t('nove-registrace-zadost-o-aktivaci-f')?></h2>
                        	
                        <table>
                        	<tr class="header">
                        		<td><?=$this->t('uzivatelske-jmeno-f')?></td>
                        		<td><?=$this->t('prijmeni-f')?> <?=$this->t('a')?> <?=$this->t('jmeno-f')?></td>
                        		<td><?=$this->t('e-mail-f')?></td>
                        		<td><?=$this->t('aktivni-f')?></td>
                        		<td class="right"><?=$this->t('moznosti-f')?></td>
                        	</tr>
                        	<?php foreach ($this->requests as $i) : ?>
                            <tr class="<?=$this->evod('odd', 'even');?>">
                                <td><?=$this->escape($i->login)?></td>
                                <td><?=$this->escape($i->user_surname . ' ' . $i->user_firstname)?></td>
                                <td><?=$this->escape($i->email)?></td>
                                <td class="<?=($i->user_active) ? 'active' : 'inactive';?>">
                                	<?php if ($i->user_active) : ?>
                                		<a href="<?=$this->baseUrl()?>/admin/users/deactivate/id/<?=$i->id_user?>"><?=$this->t('aktivni-AF')?></a>
                                	<?php else : ?>
                                		<a href="<?=$this->baseUrl()?>/admin/users/activate/id/<?=$i->id_user?>"><?=$this->t('neaktivni-AF')?></a>
                                	<?php endif; ?>    
                                </td>
                                <td class="actions">
                                    <a class="action_read" href="<?=$this->baseUrl()?>/admin/users/edit/id/<?=$i->id_user?>"><?=$this->t('editovat-AF')?></a> 
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        </table>
                        
                        <?php endif; ?>
                             
                        <div class="button_line">
                            <a href="<?=$this->baseUrl()?>/admin/users/add"><?=$this->t('pridat-uzivatele-AF')?></a>
                        </div>
                        
                        <?php 
                        $page = '/page/' . $this->page;
                        $search = '';
                        if ($this->search) {
                        	$search = '/search/' . $this->search;
                        }
                        ?>
                        
                        <div class="search_bar">
                        	<form action="<?=$this->baseUrl()?>/admin/users" method="post">
	                            <?=$this->t('hledat-uzivatele-f')?>:
	                            <input class="search_bar_input" type="text" name="search" />
	                            <button type="submit"><?=$this->t('hledat-f')?></button>
                            </form>
                            <?php if ($this->search) : ?>
                            	<form action="<?=$this->baseUrl()?>/admin/users/index<?=$page?>" method="get">
                             	<?=$this->t('vyhledavano-f')?>: <strong><?=urldecode($this->search)?></strong>
                             	<button type="submit"><?=$this->t('zrusit-f')?></button>
                            	</form>
                            <?php endif; ?>
                        </div>
                        
                        <table>
                        	<tr class="header">
                        		<td><a href="<?=$this->baseUrl()?>/admin/users/index<?=$page?><?=$search?>/order/login/sort/<?=($this->sort == 'ASC' && $this->order == 'login') ? 'DESC' : 'ASC'?>"><?=$this->t('uzivatelske-jmeno-f')?></a></td>
                        		<td>
                        			<a href="<?=$this->baseUrl()?>/admin/users/index<?=$page?><?=$search?>/order/user_surname/sort/<?=($this->sort == 'ASC' && $this->order == 'user_surname') ? 'DESC' : 'ASC'?>"><?=$this->t('prijmeni-f')?></a> <?=$this->t('a')?> 
                        			<a href="<?=$this->baseUrl()?>/admin/users/index<?=$page?><?=$search?>/order/user_firstname/sort/<?=($this->sort == 'ASC' && $this->order == 'user_firstname') ? 'DESC' : 'ASC'?>"><?=$this->t('jmeno-f')?></a>
                        		</td>
                        		<td><a href="<?=$this->baseUrl()?>/admin/users/index<?=$page?><?=$search?>/order/email/sort/<?=($this->sort == 'ASC' && $this->order == 'email') ? 'DESC' : 'ASC'?>"><?=$this->t('e-mail-f')?></a></td>
                        		<td><a href="<?=$this->baseUrl()?>/admin/users/index<?=$page?><?=$search?>/order/user_active/sort/<?=($this->sort == 'ASC' && $this->order == 'user_active') ? 'DESC' : 'ASC'?>"><?=$this->t('aktivni-f')?></a></td>
                        		<td class="right"><?=$this->t('moznosti-f')?></td>
                        	</tr>
                        	<?php foreach ($this->data as $i) : ?>
                            <tr class="<?=$this->evod('odd', 'even');?>">
                                <td><?=$this->escape($i->login)?></td>
                                <td><?=$this->escape($i->user_surname . ' ' . $i->user_firstname)?></td>
                                <td><?=$this->escape($i->email)?></td>
                                <td class="<?=($i->user_active) ? 'active' : 'inactive';?>">
                                	<?php if ($i->user_active) : ?>
                                		<a href="<?=$this->baseUrl()?>/admin/users/deactivate/id/<?=$i->id_user?>"><?=$this->t('aktivni-AF')?></a>
                                	<?php else : ?>
                                		<a href="<?=$this->baseUrl()?>/admin/users/activate/id/<?=$i->id_user?>"><?=$this->t('neaktivni-AF')?></a>
                                	<?php endif; ?>    
                                </td>
                                <td class="actions">
                                    <a class="action_read" href="<?=$this->baseUrl()?>/admin/users/edit/id/<?=$i->id_user?>"><?=$this->t('editovat-AF')?></a> 
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        </table>
                        
                        <div class="paging">
                            <?= $this->paginationControl($this->data, 'Sliding', 'users/paging.phtml', array('sort' => $this->sort, 'order' => $this->order, 'search' => $this->search)); ?>
                        </div>
                        
                    </div>
    			
    			</div>
			</div>