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

$this->headTitle($this->projectName);
$this->placeholder('title')->set($this->t('zpravy-f'));
?>
<h1 class="page_title"><?=$this->t('zpravy-f')?></h1>
<h1 class="group_title"><?=$this->t('nova-zprava-f')?></h1>

	<div class="main_inner2">
    	<div class="main_inner">
        	<div class="left_column">
    	    	<div class="left_column_item">
    	        	<?=$this->action('messages-menu', 'layout', 'default', array('leftmenu' => $this->leftmenu)); ?>
    	        </div>
    	    </div>
        
	        <div class="main_text_right">
	            <h2 class="section_heading"><?=$this->t('nova-zprava-f')?></h2>
	            <br />
	            
	            <?php if ($this->error) : ?>
	            	<div class="error_box"><?=$this->t('vsechny-polozky-jsou-povinne-f')?>.</div>
	            <?php endif; ?>
	            
	            <?php if ($this->sent) : ?>
	            		<div class="ok_box"><?=$this->t('zprava-byla-odeslana-f')?>. <a href="<?=$this->baseUrl()?>/messages/new-message"><?=$this->t('poslat-dalsi-f')?>.</a></div>
	            <?php else : ?>
	            
	            <form action="<?=$this->baseUrl()?>/messages/new-message" method="post">
	                <label><?=$this->t('adresat-f')?>:</label>
	                <select class="short" name="reciever">
	                	<optgroup label="<?=$this->t('obecne-f')?>">
	                		<option value="all" <?if ($this->reciever == 'all') echo 'selected="selected"'?>><?=$this->t('vsichni-f')?></option>
	                		<option value="all-admins" <?if ($this->reciever == 'all-admins') echo 'selected="selected"'?>><?=$this->t('vsichni-administratori-f')?></option>
	                		<option value="all-non-admins" <?if ($this->reciever == 'all-non-admins') echo 'selected="selected"'?>><?=$this->t('vsichni-bezni-uzivatele-f')?></option>
	                	</optgroup>
	                	<optgroup label="<?=$this->t('skupiny-f')?>">
	                		<?php foreach ($this->groups as $i) : ?>
	                			<option value="group-<?=$i->id_group?>" <?if ($this->reciever == 'group-' . $i->id_group) echo 'selected="selected"'?>><?=$i->group_name?></option>
	                		<?php endforeach; ?>
	                	</optgroup>
	                	<optgroup label="<?=$this->t('uzivatele-f')?>">
	                		<?php foreach ($this->users as $i) : ?>
	                			<option value="user-<?=$i->id_user?>" <?if ($this->reciever == 'user-' . $i->id_user) echo 'selected="selected"'?>><?=$i->user_surname . ' ' . $i->user_firstname?></option>
	                		<?php endforeach; ?>
	                	</optgroup>
	                </select>
	                <label><?=$this->t('predmet-f')?>:</label>
	                <input class="short" type="text" name="subject" value="<?=$this->subject?>"/>
	                <label><?=$this->t('zprava-f')?>:</label>
	                <textarea class="wide" rows="15" name="body"><?=$this->body?></textarea>
	                <button type="submit"><?=$this->t('odeslat-zpravu-AF')?></button>
	                <button type="submit"><?=$this->t('zpet-AF')?></button>
	            </form>
	            <?php endif; ?>
			</div>
		</div>
	</div>
			
