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

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

<h1 class="page_title"><?=$this->t('kategorie-f')?></h1>
        <h1 class="category_title"><?=($this->edit) ? $this->t('editovat-f') : $this->t('pridat-f')?> <?$this->t('zaznam')?></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('kategorie-f')?> - <?=($this->edit) ? $this->val($this->form, 'category_name') : $this->t('nova-kategorie-f')?></h2>
                        
                        <div class="button_line">
                            <a href="<?=$this->baseUrl()?>/admin/categoryies"><?=$this->t('zpet-AF')?></a>
                            <?php if ($this->edit) : ?>
                            	<a href="#rights"><?=$this->t('pristupova-prava-AF')?></a>
                           	<?php endif; ?>
                        </div>
                        
                        <div class="form_errors">
                        	<?php if (isset($this->errors)) : ?>
                        		<?php foreach ($this->errors as $k => $v) : ?>
                        		 		<?=$this->t('polozka-f')?> "<?=$this->t($k)?>": <?=$this->t($v)?>.<br />
                        		<?php endforeach; ?>
                        	<?php endif; ?>
                        </div>
                        
                        <form action="<?=$this->baseUrl()?>/admin/categoryies/<?=($this->edit) ? 'edit' : 'add'?>" method="post">
                        
	                        <label><?=$this->t('nazev-kategorie-f')?>:</label>
			                <input class="short" type="text" name="category_name" value="<?=$this->val($this->form, 'category_name')?>" />
			                <br />
			                <label><?=$this->t('nadrazena-kategorie-f')?>:</label>
			                <select class="short" name="id_parent">
			                	<?=$this->selVal($this->form, 'id_parent')?>
			                </select>
			                <br />

			                <label>
			                <input type="checkbox" name="category_active" value="1" <?=($this->val($this->form, 'category_active')) ? 'checked="checked"' : ''?>/>
			                <?=$this->t('aktivni-f')?>
			                </label>
			                <br />
			                
			                <?php if ($this->edit) : ?>
			                	<input type="hidden" name="id_category" value="<?=$this->val($this->form, 'id_category')?>" />
			                <?php endif; ?>
			                <div class="submit_line">
		                  		<button class="inline_button"><?=$this->t('ulozit-f')?></button>
	                        	
		                  		<?php if ($this->edit && $this->delAvail) : ?>
		                        	<a class="grey" id="delete_button" href="<?=$this->baseUrl()?>/admin/categoryies/delete/id/<?=$this->val($this->form, 'id_category')?>"><?=$this->t('smazat-AF')?></a>
		                        	<script type="text/javascript">
			                        	$(document).ready(function(){
			                        		$('#delete_button').attr('href', $('#delete_button').attr('href') + '/thru/1');
										   	$('#delete_button').click(function(){
										   		if (confirm("<?=$this->t('delete_confirm')?>"))
												{
													return true;	
												} else {
													return false;
												}
										   });
										 });
									 </script>
	                        	<?php endif; ?>
                        	</div>
                        </form>
                        
                        <h2 class="section_heading" id="rights"><?=$this->t('pristup-uzivatelu-do-teto-kategorie-f')?></h2>
						<div class="button_line">
						    <a href="<?=$this->baseUrl()?>/admin/categoryies/add-rights-group/id/<?=$this->val($this->form, 'id_category')?>"><?=$this->t('pridat-skupinu-AF')?></a>
						</div>
						
						<?php echo $this->render('categoryies/part_rights.phtml'); ?>
			            
                    </div>
    			
    			</div>
			</div>