<?php
/**
 * Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *
 */


/** @var $this \Zend\View\Renderer\PhpRenderer */

$this->headScript()
    ->appendFile('/js/adm/supports.js')
;


/** @var $layoutInfo \App\Entity\LayoutInfo */
$layoutInfo = $this->layoutInfo;

$form_link = $this->url('adm.supports.create',['lang' => $this->lang]);
$cancel_link = $this->url('adm.supports',['lang' => $this->lang]);

$supportUser = $this->support;
if($supportUser) {
    $form_link = $this->url('adm.supports.edit',['lang' => $this->lang, 'id' => $supportUser->getId()]);
    
    $fullname = $supportUser->getFullname();
    $email = $supportUser->getEmail();
    $role = $supportUser->getRoleId();
}


?>
<section class="b-content__work">
    <form id="support-create-form" method="post" action="<?= $form_link ?>">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h1 style="padding: 0 0 10px 0;"><?= _t('Добавление менеджера') ?></h1>
            </div>
            <div class="panel-body">
                <form action="<?= $form_link?>" method="POST">
                    <div class="form-group">
                        <label for="id-name"><?= _t('Имя')?></label>
                        <input type="text" class="form-control" id="id-name" name="fullname" value="<?= $fullname?>" placeholder="<?= _t('Имя') ?>">
                    </div>
                    <div class="form-group">
                        <label for="id-mail"><?= _t('Email')?></label>
                        <input type="text" class="form-control" id="id-email" name="email" value="<?= $email?>" placeholder="<?= _t('Email') ?>">
                    </div>                   
                    <div class="form-group">
                        <label for="user-name"><?= _t('Пароль')?></label>
                        <input type="text" class="form-control" id="id-password" name="password" value="" placeholder="<?= _t('Пароль') ?>">
                    </div>
                    <div class="form-group">
                        <label for="user-name"><?= _t('Роль')?></label>
                        <select class="form-control" id="id-role" name="role">
                            <option value="<?= \App\Acl\Roles::ROLE_ADMIN ?>" <?= ($role == \App\Acl\Roles::ROLE_ADMIN ? 'selected' : '')?> ><?= _t(\App\Acl\Roles::ROLE_ADMIN) ?></option>
                            <option value="<?= \App\Acl\Roles::ROLE_MANAGER ?>" <?= ($role == \App\Acl\Roles::ROLE_MANAGER ? 'selected' : '')?> ><?= _t(\App\Acl\Roles::ROLE_MANAGER) ?></option>
                            <option value="<?= \App\Acl\Roles::ROLE_MANAGER_FEED ?>" <?= ($role == \App\Acl\Roles::ROLE_MANAGER_FEED ? 'selected' : '')?> ><?= _t(\App\Acl\Roles::ROLE_MANAGER_FEED) ?></option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-primary"><?= _t('Сохранить')?></button>
                    <a class="btn btn-default" href="<?= $cancel_link?>"><?= _t('Отмена')?></a>
                </form>                               
            </div>            
        </div>
    </form>
    </div>
</section>
