<!-- Modal -->
<div id="modalAddUser"  class='modal fade' data-backdrop="static" data-keyboard="false" role="dialog" style=" overflow: hidden;background: transparent">
    <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
        <div class="modal-body"> 
            <div class="box box-primary">
            <div class="box-header with-border">
                <button type="button" class="close _closeModalUser"><i class="fa fa-window-close"></i></button>
                <h4><i class='fa-fw fa fa-user'></i> <span id="title_modal_user"><?php echo $_translator->_getTranslation('Agregar usuario');?></span></h4>
            </div>
                <?php 
                echo $_form->openForm();
                echo $_form->showActionController();
                echo $_form->showId();?>
                
                <div class="box-body">
                    <div class='flashmessenger'><?php $flashmessenger->showMessage(true);?></div>
                    <div class="col-md-6 col-xs-12">
                        <?php
                        $_form->showElement('usuario');
                        $_form->showElement('contrasena');
                        $_form->showElement('confirmar_contrasena');                       
                        $_form->showElement('role');
                        ?>
                    </div>
                    <div class="col-md-6 col-xs-12">
                        <?php                         
                        $_form->showElement('nombre');    
                        $_form->showElement('apellido');    
                        $_form->showElement('telefono');    
                        $_form->showElement('email');
                        $_form->showElement('status');                
                        ?>
                    </div>     
                </div>
                <div class="box-footer">
                    <div class="pull-right">
                        <input type="submit" value="<?php echo $_translator->_getTranslation('Terminar')?>" class='btn btn-primary'/>
                    </div>
                    <div class="pull-left">
                        <input type="button" value="<?php echo $_translator->_getTranslation('Cancelar')?>" class="btn btn-default _closeModalUser" />
                    </div>
                </div>
                <?php echo $_form->closeForm();?>
            </div>
        </div>
    </div>           
    </div>
    <script>
        $('#modalAddUser').on('shown.bs.modal', function (e) {
            if($('#action').val() === 'insert'){$('#user').focus();}
            
            var input = null;
            $("form[name=user]").find('div').each(function() {
                if($(this).hasClass('has-error') === true){
                    input = $(this).data('errorfor');
                    return false;
                }
            });    
            
            if(input !== null){$('#'+input).focus();}
        });
    </script>
</div>