<div class="row-fluid" style="margin-top:0">
    <div class="span12">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                    <i class="icon-tags"></i>
                </span>
                <h5>Editar Funcionario</h5>
            </div>
            <section class="panel panel-default">
                <header class="panel-heading text-right bg-light">
                    <ul class="nav nav-tabs pull-left">
                        <li class="active"><a href="#profile-1" data-toggle="tab"><i class="fa fa-user text-muted"></i>
                                Dados do Funcionario</a></li>
                    </ul>
                    <span class="hidden-sm">Informações referentes aos Moradores</span>
                </header>
                <div class="panel-body">
                    <div class="tab-content">
                        <div class="tab-pane fade active in" id="profile-1">
                            <section class="panel panel-default">
                                <div class="panel-body">
                                    <form action="<?php echo current_url(); ?>" id="formEditarMorador" method="post"
                                          class="form-horizontal">
                                        <?php echo form_hidden('idFuncionario', $result->idFuncionario) ?>
                                        <div class="panel-esquerda">
                                            <?php if ($result->foto_url != "" || $result->foto_url != null) { ?>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">Foto</label>

                                                    <div class="col-sm-10">
                                                        <div class="row">
                                                            <div class="col-md-4 ">
                                                                <a href="#modalEditarFoto" role="button"
                                                                   data-toggle="modal">
                                                                    <img
                                                                        src="<?php echo base_url() ?>imagensFuncionario/<?php echo $result->foto_url ?> "
                                                                        class="dker img-thumbnail" alt="...">
                                                                </a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php } else { ?>
                                                <div class="form-group" style="">
                                                    <label class="col-sm-2 control-label">Foto</label>

                                                    <div class="col-sm-10">
                                                        <div class="row">
                                                            <div class="col-md-12 ">
                                                                <h4>Não há imagem cadastrata para
                                                                    o(a) <?php echo $result->funcao . "(a) " . $result->nomeFuncionario ?>
                                                                    . Por favor, <a href="#modalCadastrarFoto"
                                                                                    class="sumb" role="button"
                                                                                    data-toggle="modal">clique aqui</a>
                                                                    para cadastrar uma imagem.</h4>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Nome</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="nomeFuncionario" id="nomeFuncionario"
                                                                   type="text" style="" class="form-control"
                                                                   value="<?php echo $result->nomeFuncionario; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Sobrenome</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="sobreNome" id="sobreNome" type="text" style=""
                                                                   class="form-control"
                                                                   value="<?php echo $result->sobreNome; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Endereço</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="endereco" id="endereco" type="text" style=""
                                                                   class="form-control"
                                                                   value="<?php echo $result->endereco; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Bairro</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="bairro" id="bairro" type="text" style=""
                                                                   class="form-control"
                                                                   value="<?php echo $result->bairro; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Nascimento</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="dataNascimento" id="dataNascimento" type="text"
                                                                   style="" class="form-control datepicker"
                                                                   value="<?php echo date(('d/m/Y'), strtotime($result->dataNascimento)); ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">CPF</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <?php $cpfComMascara = substr($result->cpfFuncionario, 0, 3) . "." . substr($result->cpfFuncionario, 3, 3) . "." . substr($result->cpfFuncionario, 6, 3) . "-" . substr($result->cpfFuncionario, -2); ?>
                                                            <input id="cpfFuncionario" name="cpfFuncionario" type="tel"
                                                                   class="form-control"
                                                                   value="<?php echo $cpfComMascara; ?>" maxlength="14"
                                                                   onKeyDown="Mascara(this, Cpf);"
                                                                   onKeyPress="Mascara(this, Cpf);"
                                                                   onKeyUp="Mascara(this, Cpf);">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">RG</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="rgFuncionario" id="rgFuncionario" type="text"
                                                                   style="" class="form-control"
                                                                   value="<?php echo $result->rgFuncionario; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Emissor RG</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="orgaoEmissorRgFuncionario"
                                                                   id="orgaoEmissorRgFuncionario" type="text" style=""
                                                                   class="form-control"
                                                                   value="<?php echo $result->orgaoEmissorRgFuncionario; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Celular</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="telCelular" id="telCelular" type="text"
                                                                   style="" class="form-control"
                                                                   value="<?php echo $result->telCelular; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Residencial</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="telResidencial" id="telResidencial" type="text"
                                                                   style="" class="form-control"
                                                                   value="<?php echo $result->telResidencial; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Tel. Recados</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="telRecados" id="telRecados" type="text"
                                                                   style="" class="form-control"
                                                                   value="<?php echo $result->telRecados; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Sexo</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="sexo" class="form-control ">
                                                                <option
                                                                    value="<?php echo $result->sexo; ?>"><?php echo $result->sexo; ?></option>
                                                                <option value="">--------</option>
                                                                <option value="Masculino">Masculino</option>
                                                                <option value="Feminino">Feminino</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-actions" style="margin-top: 40px;">
                                                <div class="col-sm-10">
                                                    <div class="span6 offset3">
                                                        <a href="<?php echo base_url() ?>funcionario" id=""
                                                           class="btn btn-dark"><i class="icon-arrow-left"></i>
                                                            Voltar</a>
                                                        <a href="<?php echo base_url() ?>funcionario/visualizar/<?php echo $result->idFuncionario ?>"
                                                           id="" class="btn btn-success"><i class="fa fa-search"></i>
                                                            Visualizar</a>
                                                        <button type="submit" class="btn btn-primary"><i
                                                                class="icon-ok icon-white"></i> Alterar
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>

                                        <div class="panel-direita">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Data Entrada</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="dataEntrada" id="dataEntrada" type="text"
                                                                   style="" class="form-control datepicker"
                                                                   value="<?php echo date(('d/m/Y'), strtotime($result->dataEntrada)); ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Próximas Férias</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="dataProximaFerias" id="dataProximaFerias"
                                                                   type="text" style="" class="form-control datepicker"
                                                                   value="<?php echo date(('d/m/Y'), strtotime($result->dataProximaFerias)); ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Função</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="funcao" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->funcao; ?>"><?php echo $result->funcao; ?></option>
                                                                <option value="">-------</option>
                                                                <option value="Porteiro">Porteiro</option>
                                                                <option value="Jardineiro">Jardineiro</option>
                                                                <option value="Manutencao">Manutenção</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Matricula</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input name="matricula" id="matricula" type="text" style=""
                                                                   class="form-control datepicker"
                                                                   value="<?php echo $result->matricula; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Jornada</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="jornada" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->jornada; ?>"><?php echo $result->jornada; ?></option>
                                                                <option value="">---------</option>
                                                                <option value="8">8 Horas/Dia</option>
                                                                <option value="12">12 Horas/Dia</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Cidade</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="cidade" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->cidade; ?>"><?php echo $result->cidade; ?></option>
                                                                <option value="">-------</option>
                                                                <option value="Valparaizo de Goiás">Valparaizo de
                                                                    Goiás
                                                                </option>
                                                                <option value="Cidade Ocidental">Cidade Ocidental
                                                                </option>
                                                                <option value="Luziania">Luziania</option>
                                                                <option value="Cristalina">Cristalina</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Estado</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="uf" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->uf; ?>"><?php echo $result->uf; ?></option>
                                                                <option value="GO">Goiás</option>
                                                                <option value="DF">Distrito Federal</option>
                                                                <option value="MG">Minas Gerais</option>

                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">CEP</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input id="cep" name="cep" type="text" class="form-control"
                                                                   value="<?php echo $result->cep; ?>" maxlength="9"
                                                                   onKeyDown="Mascara(this, Cep);"
                                                                   onKeyPress="Mascara(this, Cep);"
                                                                   onKeyUp="Mascara(this, Cep);">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Estado Civil</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="estadoCivil" class="form-control ">
                                                                <option
                                                                    value="<?php echo $result->estadoCivil; ?>"><?php echo $result->estadoCivil; ?></option>
                                                                <option value="">--------</option>
                                                                <option value="Casado">Casado</option>
                                                                <option value="Solteiro">Solteiro</option>
                                                                <option value="Divorciado">Divorciado</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Situação</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="situacao" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->situacao; ?>"><?php echo $result->situacao; ?></option>
                                                                <option value="">-------</option>
                                                                <option value="Ativo">Ativo</option>
                                                                <option value="Inativo">Inativo</option>

                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Grau de Instruções</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <select name="grauInstrucao" class="form-control">
                                                                <option
                                                                    value="<?php echo $result->grauInstrucao; ?>"><?php echo $result->grauInstrucao; ?></option>
                                                                <option value="">---------</option>

                                                                <option value="Fundamental Completo">Fundamental
                                                                    Completo
                                                                </option>
                                                                <option value="Médio Incompleto">Médio Incompleto
                                                                </option>
                                                                <option value="Médio Completo">Médio Completo</option>
                                                                <option value="Superior Incompleto ">Superior
                                                                    Incompleto
                                                                </option>
                                                                <option value="Superior Completo">Superior Completo
                                                                </option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">Email</label>

                                                <div class="col-sm-10">
                                                    <div class="row">
                                                        <div class="col-md-10">
                                                            <input id="email" name="email" type="tel"
                                                                   class="form-control"
                                                                   value="<?php echo $result->email; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">.</label>
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </section>


                        </div>
                    </div>
                </div>
            </section>

        </div>
    </div>
</div>

<!-- modal editar foto -->

<div class="modal fade" id="modalEditarFoto">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo base_url() ?>funcionario/editarImagemFuncionarioEditar" method="post"
                  enctype="multipart/form-data">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Editar Foto
                        do(a) <?php echo $result->funcao . "(a) " . $result->nomeFuncionario ?></h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idImagem" name="id" value="<?php echo $result->funcionario_id ?>"/>
                    <input type="hidden" id="idImagemBD" name="idImagemBD"
                           value="<?php echo $result->IdImagemFuncionario ?>"/>
                    <input type="hidden" id="categoriaEditarFoto" name="categoriaEditarFoto"
                           value="<?php echo $result->funcao ?>"/>
                    <input type="hidden" id="urlarquivos" name="arquivo" value="<?php echo $result->foto_url ?>"/>
                    <h5 style="text-align: center">Escolha a nova foto</h5>

                    <div class="form-control">
                        <input type="file" id="imagemEditar" name="imagemEditarCorpo" onchange="loadFile(event)"  accept=".png, .jpg, .jpeg">
                        <input type="hidden" id="nomeEditarFoto" name="nomeEditarFoto" class="form-control">
                    </div>
                    <img id="image_previewEditar" style=" margin-top: 10px;"/>

                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                    <button type="submit" class="btn btn-primary" name="submit">Editar</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<!-- modal cadastrar contrato -->

<div class="modal fade" id="modalCadastrarFoto">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo base_url() ?>funcionario/addImagemFuncionarioEditar" method="post"
                  enctype="multipart/form-data">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Adicionar foto para
                        o(a) <?php echo $result->funcao . "(a) " . $result->nomeFuncionario ?></h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idContrato" name="id" value="<?php echo $result->idFuncionario ?>"/>
                    <input type="hidden" id="categoriaEditarFoto" name="categoriaEditarFoto"
                           value="<?php echo $result->funcao ?>"/>
                    <h5 style="text-align: center">Escolha a foto</h5>

                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-control">
                        <input type="file" id="imagemCadastrar" name="imagemEditarCorpo" onchange="loadFile(event)">

                    </div>
                    <img id="image_previewCadastar" style=" margin-top: 10px;"/>

                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                    <button type="submit" class="btn btn-primary" name="submit"><i class="fa fa-save"></i> Cadastrar</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<script type="text/javascript">
    var loadFile = function (event) {
        var reader = new FileReader();
        reader.onload = function () {
            var outputEditar = document.getElementById('image_previewEditar');
            outputEditar.src = reader.result;
            var outputCadastrar = document.getElementById('image_previewCadastar');
            outputCadastrar.src = reader.result;
        };
        reader.readAsDataURL(event.target.files[0]);
    };

    $(document).ready(function () {
        $("#imagemEditar").change(function () {
            $("#image_previewEditar").css({"height": "200px", "width": "200px;"});
        });
        $("#imagemCadastrar").change(function () {
            $("#image_previewCadastar").css({"height": "200px", "width": "200px;"});
        });

        $('input:file').change(function () {
            var nome_arq = $(this).val().split("\\").pop();
            $("#nomeEditarFoto").val(nome_arq);
        });

        $("#formEditarMorador").validate({
            rules: {
                nm_morador: {required: true},
                nr_apartamento: {required: true},
                dataEntrada: {required: true}
            },
            messages: {
                nm_morador: {required: 'Campo Requerido.'},
                nr_apartamento: {required: 'Campo Requerido.'},
                dataEntrada: {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');
            }
        });

        $(".datepicker").datepicker({dateFormat: 'dd/mm/yy'});
        $(".money").maskMoney();
    });

</script>




