<?php
/**
 * YAWIK
 *
 * Partial for an employee form element.
 *
 * @author Mathias Gelhausen <gelhausen@cross-solution.de>
 * @filesource
 * @license MIT
 * @copyright  2013 - 2015 Cross Solution <http://cross-solution.de>
 * @since 0.18
 */

    /* @var \Organizations\Form\Element\Employee  $employee */
    $employee = $this->element->get('user');
    /* @var \Laminas\Form\Element\Hidden $pending */
    $pending = $this->element->get('status');
    $user = $employee->getUser();
    if (!$user) {
        $this->element->get('permissions')->setValue(array(16, 2));
    }
    $fsId = $this->element->getAttribute('id');
?>
<fieldset id="<?php echo $fsId ?>" class="employee-wrapper">

    <?php echo $this->formHidden($employee); echo $this->formHidden($pending) ?>


    <div class="employee-info-wrapper">
        <?php echo $user ? $user->getInfo()->getDisplayName() : '__userName__' ?>
        <span>&lt;<?php echo $user ? $user->getInfo()->getEmail()  : '__userEmail__' ?>&gt;</span>
        <?php if (($user && 'PENDING' == $pending->getValue()) || !$user):?>
            <span class="label label-warning"><?php echo $this->translate('PENDING') ?></span>
        <?php elseif ($user && 'ASSIGNED' != $pending->getValue()): ?>
            <span class="label label-danger"><?php echo $this->translate($pending->getValue()) ?></span>
        <?php endif; ?>
        <button type="button" class="pull-right btn btn-default btn-xs remove-employee" data-id="<?php echo $fsId ?>"><span class="yk-icon yk-icon-minus"></span></button>

    </div>
    <div id="<?php

    $elementId = preg_replace(
        array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'),
        array('-'              , '-'    , ''       ),
        $this->element->get('permissions')->getName()
    );
    $this->element->get('permissions')->setAttribute('id', $elementId);
    echo $this->element->get('permissions')->getAttribute('id')?>-wrapper" class="cam-description-toggl employee-permissions-wrapper">

        <?php echo $this->formMultiCheckbox($this->element->get('permissions')) ?>
        <?php echo $this->formSelect($this->element->get('role')) ?>
    </div>
<hr>
</fieldset>
