<?
if($this->form){
    $form = $this->form;
} else {
    if($this->hasModule('User')){
        $form = new User\Form\AdminLoginForm();
    }else {
        $form = new Core\Form\SuperAdminLoginForm();
    }
}

if($this->hasModule('User')){
    $title = 'Admin Login';
    $url = $this->uri('/admin/user/login/');
} else {
    $title = 'Super Admin Login';
    $url = $this->uri('/admin/core/login/');
}
$form->setView($this)
->setMethod('put')
->setAction($url)
->prepare();

$this->headTitle($title, 'SET');
?>
<style>
    html, body {
            background:#D7D7D7;
            height:100%;
    }

    .block {
            text-align: center;
            height:100%;
    }

    .block:before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
            margin-right: -0.25em; /* Adjusts for spacing */
    }

    .centered {
            display: inline-block;
            vertical-align: middle;
    }

    #admin-login{
            text-align:left;    
    }
</style>

<div class="block" style="">
    <div class="centered">
        <div id="admin-login" class="container">
            <div class="row">
                <div class="span6 offset3">
                    <div id="user-name-failed" class="alert alert-error <?if(!$this->flashMessenger('user-name-failed')):?>hide<?endif?>">
                        <a href="#" data-dismiss="alert" class="close">x</a>
                        <h4 class="alert-heading"><?=$this->_('Input user not exist');?></h4>
                    </div>
                    <div id="password-failed" class="alert alert-error <?if(!$this->flashMessenger('password-failed')):?>hide<?endif?>">
                        <a href="#" data-dismiss="alert" class="close">x</a>
                        <h4 class="alert-heading"><?=$this->_('Password not match');?></h4>
                    </div>
                    <div id="permission-not-enough" class="alert alert-error <?if(!$this->flashMessenger('permission-not-enough')):?>hide<?endif?>">
                        <a href="#" data-dismiss="alert" class="close">x</a>
                        <h4 class="alert-heading"><?=$this->_('Permission not enough');?></h4>
                    </div>

                    <div class="slate">
                        <form class="form-horizontal" <?=$this->formAttr($form)?> >
                            <?=$form->restful();?>
                            <header class="page-header">
                            <h3><?=$this->_($title)?></h3>
                            </header>
                            <fieldset>
                                <div class="control-group <?=$form->isError('loginName') ? 'error' : '';?>">
                                    <?=$form->helper('loginName', 'label', array('class' => 'control-label'))?>
                                    <div class="controls">
                                        <?=$form->helper('loginName', array('class' => ''))?>        
                                        <div class="help-block"><?=$form->helper('loginName', 'formElementErrors')?></div>
                                    </div>
                                </div>
                                <div class="control-group <?=$form->isError('inputPassword') ? 'error' : '';?>">
                                    <?=$form->helper('inputPassword', 'label', array('class' => 'control-label'))?>
                                    <div class="controls">
                                        <?=$form->helper('inputPassword', array('class' => ''))?>        
                                        <div class="help-block"><?=$form->helper('inputPassword', 'formElementErrors')?></div>
                                    </div>
                                </div>
                                <?if($this->hasModule('User')):?>
                                <div class="control-group <?=$form->isError('isSuperAdmin') ? 'error' : '';?>">
                                    <div class="controls">
                                        <label class="checkbox"><?=$form->helper('isSuperAdmin', array('class' => 'checkbox'))?> <?=$this->_('Login As Super Admin');?></label>
                                    </div>
                                </div>
                                <?endif?>
                                <div class="form-actions">
                                    <input name="callback" type="hidden" value="<?=$this->callback?>" />
                                    <button class="btn btn-primary" type="submit"><?=$this->_('Login')?></button>
                                    <?if($this->hasModule('User')):?>
                                    <a href="<?=$this->uri('/admin/user/reset/')?>"><?=$this->_('Forgot Passsword')?></a>
                                    <?endif?>
                                </div>
                            </fieldset>
                        </form>
                    </div><!--slate end-->

                </div>
            </div><!-- row end-->
        </div>
    </div>

</div>
