<div class="row">
    <div class="col-lg-12">
        <div class="card card-outline-info">
            <div class="card-header">
                <h4 class="m-b-0 text-white">Alterar Usuário #<?php echo $result->idUsuarios; ?></h4>
            </div>
            <div class="card-block">
                <form action="<?php echo current_url(); ?>" method="post" name="formUsuario" id="formUsuario"
                      class="floating-labels m-t-40">
                    <div class="form-body">
                        <h3 class="card-title">Informações Pessoais</h3>
                        <hr>

                        <div class="row p-t-20 ">
                            <div class="form-group col-lg-6">
                                <input type="text" class="form-control" id="nome" name="nome"
                                       value="<?php echo $result->nome; ?>">
                                <span class="bar"></span>
                                <label for="input1">Nome</label>
                            </div>
                            <!--/span-->
                            <div class="form-group col-lg-6">
                                <input type="text" class="form-control" id="sobreNomeUsuario" name="sobreNomeUsuario"
                                       value="<?php echo $result->sobreNomeUsuario; ?>">
                                <span class="bar"></span>
                                <label for="input1">sobrenome</label>
                            </div>
                            <!--/span-->
                        </div>

                        <div class="row p-t-20 ">
                            <div class="form-group col-lg-4">
                                <input type="text" class="form-control" id="endereco"
                                       name="endereco"
                                       required value="<?php echo $result->endereco; ?>">
                                <span class="bar"></span>
                                <label for="input1">Endereço</label>
                            </div>
                            <div class="form-group col-lg-4">
                                <input type="text" class="form-control inputmask" id="cpf"
                                       name="cpf" maxlength="14" data-inputmask="'mask': '999.999.999-99'"
                                       required value="<?php echo $result->cpf; ?>">
                                <span class="bar"></span>
                                <label for="input1">CPF</label>
                            </div>
                            <!--/span-->
                            <div class="form-group col-lg-4">
                                <input type="text" class="form-control" id="rg"
                                       name="rg" maxlength="14"
                                       value="<?php echo $result->rg; ?>">
                                <span class="bar"></span>
                                <label for="input1">RG</label>
                            </div>

                        </div>

                        <div class="row p-t-20 ">
                            <div class="form-group col-lg-4">
                                <input type="text" class="form-control inputmask" id="celular"
                                       name="celular" maxlength="16"
                                       data-inputmask="'mask': '(99) 9 9999-9999'"
                                       required value="<?php echo $result->celular; ?>">
                                <span class="bar"></span>
                                <label for="input1">Telefone Celular</label>
                            </div>
                            <!--/span-->
                            <div class="form-group col-lg-4">
                                <input type="text" class="form-control inputmask" id="telefone"
                                       name="telefone" maxlength="14"
                                       data-inputmask="'mask': '(99) 9999-9999'"
                                       required value="<?php echo $result->telefone; ?>">
                                <span class="bar"></span>
                                <label for="input1">Telefone Residencial</label>
                            </div>

                            <div class="form-group col-lg-4">
                                <div class="onoffswitch">
                                    <input type="checkbox" name="situacao" class="onoffswitch-checkbox"
                                           id="situacao" <?php echo $result->situacao==1?'checked':''; ?>  value="1">
                                    <label class="onoffswitch-label" for="situacao">
                                        <span class="onoffswitch-inner"></span>
                                        <span class="onoffswitch-switch"></span>
                                    </label>
                                </div>
                            </div>
                            <!--/span-->
                        </div>

                        <h3 class="box-title m-t-40">Dados de Acesso</h3>
                        <hr>


                        <?php if ($this->session->userdata('id') == 1) { ?>
                            <div class="row p-t-20 ">
                                <div class="form-group col-lg-4">
                                    <select name="situacao" id="situacao" class="form-control">
                                        <option value="<?php echo $result->situacao; ?>"><?php echo $result->situacao == 1 ? "Ativo" : "Inativo"; ?></option>
                                        <option value="">-----------</option>
                                        <option value="1">Ativo</option>
                                        <option value="0">Inativo</option>
                                    </select>
                                    <span class="bar"></span>
                                    <label for="input1">Situação</label>
                                </div>
                                <!--/span-->

                            </div>
                        <?php } ?>

                        <div class="row p-t-20 ">
                            <div class="form-group col-lg-4">
                                <select name="funcaoUsuario" id="funcaoUsuario" class="form-control" required>
                                    <option value="<?php echo $result->funcaoUsuario ?>"><?php echo $result->funcaoUsuario ?></option>
                                    <option value="">----------------------</option>
                                    <option value="Técnico">Técnico</option>
                                    <option value="Adminstração">Adminstração</option>
                                    <option value="cliente">Cliente</option>
                                </select>
                                <span class="bar"></span>
                                <label for="input1">Função</label>
                            </div>

                            <div class="form-group col-lg-4">

                                <select name="nivel" id="nivel" class="form-control">
                                    <option
                                            value="<?php echo $result->nivel; ?>"><?php if ($result->nivel == 1) {
                                            echo "Administrador";
                                        } else if ($result->nivel == 2) {
                                            echo "Operacional";
                                        } else if ($result->nivel == 3) {
                                            echo "Administrativo";
                                        } else if ($result->nivel == 4) {
                                            echo "Técnico";
                                        } ?></option>
                                    <option>-------</option>
                                    <option value="1">Administrador</option>
                                    <option value="2">Operacional</option>
                                    <option value="3">Administrativo</option>
                                    <option value="4">Técnico</option>
                                </select>
                                <span class="bar"></span>
                                <label for="input1">Nível</label>
                            </div>


                            <div class="form-group col-lg-4" id="funcionarios">
                                <select name="funcionario_id" id="funcionario_id" class="form-control m-b">
                                    <option value="">Vincular Funcionário ?</option>
                                    <?php
                                    foreach ($resultscomboFuncionarios as $r) {
                                        ?>
                                        <option value="<?php echo $r->idFuncionario ?>"><?php echo $r->nomeFuncionario . ' | ' . $r->funcao ?></option>
                                    <?php } ?>
                                </select>
                                <span class="bar"></span>
                                <!--                                <label for="input1">Funcionário</label>-->
                            </div>
                        </div>

                        <div class="row p-t-20 ">
                            <div class="form-group col-lg-6">
                                <input type="email" class="form-control" id="email"
                                       name="email"
                                       required value="<?php echo $result->email; ?>">
                                <span class="bar"></span>
                                <label for="input1">Email/Login</label>
                            </div>
                            <!--/span-->
                            <div class="form-group col-lg-6">
                                <input type="password" class="form-control" id="senha"
                                       name="senha"
                                       placeholder="Nova Senha">
                                <span class="bar"></span>
                                <label for="input1">Nova Senha</label>
                            </div>

                        </div>

                    </div>
                    <div class="form-actions text-right">
                        <a href="<?php echo base_url() ?>usuarios" id="" class="btn btn-dark"><i
                                    class="icon-arrow-left"></i> Voltar</a>
                        <button type="submit" class="btn btn-success"><i class="fa fa-save"></i> Editar</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    $(document).ready(function () {
        $('#formUsuario').validate({
            rules: {
                nome: {required: true},
                cpf: {required: true},
                telefone: {required: true},
                email: {required: true},
                endereco: {required: true},
                cep: {required: true}
            },
            messages: {
                nome: {required: 'Campo Requerido.'},
                cpf: {required: 'Campo Requerido.'},
                telefone: {required: 'Campo Requerido.'},
                email: {required: 'Campo Requerido.'},
                endereco: {required: 'Campo Requerido.'},
                cep: {required: 'Campo Requerido.'}

            },
            errorClass: "help-inline",
            errorElement: "span",
            highlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').addClass('error');
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').removeClass('error');
                $(element).parents('.control-group').addClass('success');
            }
        });

    });
</script>




