<div class="row justify-content-center">
    <div class="col">
        <div class="card shadow-sm mb-4 border-bottom-primary">
            <div class="card-header bg-white py-3">
                <div class="row">
                    <div class="col">
                        <h4 class="h5 align-middle m-0 font-weight-bold text-primary">
                            Crear Nuevo Usuario
                        </h4>
                    </div>
                    <div class="col-auto">
                        <a href="<?= base_url('user') ?>" class="btn btn-sm btn-secondary btn-icon-split">
                            <span class="icon">
                                <i class="fa fa-arrow-left"></i>
                            </span>
                            <span class="text">
                                Volver
                            </span>
                        </a>
                    </div>
                </div>
            </div>
            <div class="card-body pb-2">
                <?= $this->session->flashdata('pesan'); ?>
                <?= form_open(); ?>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="username">Nombre Usuario (Login Sistema)</label>
                    <div class="col-md-4">
                        <input value="<?= set_value('username'); ?>" type="text" id="username" name="username" class="form-control" placeholder="Nomnre Usuario" maxlength="15">
                        <?= form_error('username', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                

                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="id_entidad">Entidad (Empresa)</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text" id="basic-addon1"><i class="fas fa-building"></i></span>
                            </div>

                            <select name="id_entidad" id="id_entidad" class="select2bs4">
                                <option value="" selected disabled>Seleccione Entidad (Empresa)..</option>
                                <?php foreach ($entidades as $j) : ?>
                                    <option <?= set_select('id_entidad', $j['id_entidad']) ?> value="<?= $j['id_entidad'] ?>"><?= $j['nombre_entidad'] ?></option>
                                <?php endforeach; ?>
                            </select>
                            <div class="input-group-append">
                                <a class="btn btn-primary" href="<?= base_url('abogados/add/cf'); ?>"><i class="fa fa-plus"></i></a>
                            </div>

                        </div>
                        <?= form_error('id_entidad', '<small class="text-danger">', '</small>'); ?>
                    </div>
                </div>

                <hr>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="name">Nombre Completo</label>
                    <div class="col-md-4">
                        <input value="<?= set_value('name'); ?>" type="text" id="name" name="name" class="form-control" placeholder="Nombre Completo">
                        <?= form_error('name', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>

                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="name">RUT</label>
                    <div class="col-md-4">
                        <input value="<?= set_value('rut'); ?>" type="text" id="rut" name="rut" class="form-control" placeholder="RUT">
                        <?= form_error('rut', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>


                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="email">Email</label>
                    <div class="col-md-4">
                        <input value="<?= set_value('email'); ?>" type="text" id="email" name="email" class="form-control" placeholder="Email">
                        <?= form_error('email', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="no_telp">Teléfono</label>
                    <div class="col-md-4">
                        <input value="<?= set_value('no_telp'); ?>" type="text" id="no_telp" name="no_telp" class="form-control" placeholder="Teléfono">
                        <?= form_error('no_telp', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>

                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="role">Role</label>
                    <div class="col-md-4">
                        <div class="custom-control custom-radio">
                            <input <?= set_radio('role', 'admin'); ?> value="admin" type="radio" id="admin" name="role" class="custom-control-input">
                            <label class="custom-control-label" for="admin">Administrador</label>
                        </div>
                        <div class="custom-control custom-radio">
                            <input <?= set_radio('role', 'abogado'); ?> value="abogado" type="radio" id="abogado" name="role" class="custom-control-input" checked>
                            <label class="custom-control-label" for="abogado">Abogado</label>
                        </div>
                        <?= form_error('role', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>

                <hr>

                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="password">Password</label>
                    <div class="col-md-4">
                        <input type="password" id="password" name="password" class="form-control" placeholder="Password">
                        <?= form_error('password', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="password2">Confirm Password</label>
                    <div class="col-md-4">
                        <input type="password" id="password2" name="password2" class="form-control" placeholder="Confirm Password">
                        <?= form_error('password2', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>

                
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="finanzas">Finanzas</label>
                    <div class="col-md-4">
                        <input type="checkbox" id="chk_finanzas" name="chk_finanzas" class="custom-control-checkbox"  > 
                        <label class="" for="chk_finanzas">Puede ver las Finanzas de la Entidad (Empresa)   </label>
                    </div>
                </div>

                <br>
                <div class="row form-group justify-content-end">
                    <div class="col-md-8">
                        <button type="submit" class="btn btn-primary btn-icon-split">
                            <span class="icon"><i class="fa fa-save"></i></span>
                            <span class="text">Crear Usuario</span>
                        </button>
                        
                    </div>
                </div>
                <?= form_close(); ?>
            </div>
        </div>
    </div>
</div>