<div class="widget-box">
    <?php //var_dump($result); ?>
    <div class="widget-title">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#tab0">Dados
                    do(a) <?php echo $result->funcao . "(a) " . $result->nomeFuncionario ?></a></li>
            <div class="buttons">
                <a title="Voltar para Funcionários" class="btn btn-dark btn-xs"
                   href="<?php echo base_url() ?>funcionario/"><i class="icon-arrow-left icon-white"></i>
                    Voltar</a>
                <a title="Editar Funcionário" class="btn btn-primary btn-xs"
                   href="<?php echo base_url() ?>funcionario/editar/<?php echo $result->idFuncionario ?>"><i
                        class="fa fa-pencil-square-o icon-white"></i> Editar</a>
                <a id="fichaCadastral" title="Visualizar Ficha Cadastral" class="btn btn-mini btn-inverse" href=""
                   style="  color: white;  padding: 1px 8px;  font-size: 12px;   background: #363636;"><i
                        class="fa fa-print icon-white"></i> Imprimir Ficha</a>
            </div>
        </ul>
    </div>

    <div class="widget-content tab-content">
        <div id="tab1" class="tab-pane active" style="min-height: 300px">
            <div class="accordion" id="collapse-group">


                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGTwo" data-toggle="collapse">
                                <span class="icon"><i class="icon-list"></i></span><h5>Dados Pessoais</h5>
                            </a>
                        </div>
                    </div>
                    <div class="collapse accordion-body" id="collapseGTwo">
                        <div class="widget-content">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Código</strong></td>
                                    <td>
                                        <a href="<?php echo base_url() ?>clientes/visualizar/<?php echo $result->idFuncionario ?>"><?php echo $result->idFuncionario ?></a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Nome</strong></td>
                                    <td><?php echo $result->nomeFuncionario ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Sobre Nome</strong></td>
                                    <td><?php echo $result->sobreNome ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Data Nascimento</strong></td>

                                    <td><?php echo date(('d/m/Y'), strtotime($result->dataNascimento)); ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Endereço</strong></td>
                                    <td><?php echo $result->endereco ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Bairro</strong></td>
                                    <td><?php echo $result->bairro ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Cidade</strong></td>
                                    <td><?php echo $result->cidade ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>CPF</strong></td>
                                    <?php $cpfComMascara = substr($result->cpfFuncionario, 0, 3) . "." . substr($result->cpfFuncionario, 3, 3) . "." . substr($result->cpfFuncionario, 6, 3) . "-" . substr($result->cpfFuncionario, -2); ?>
                                    <td><?php echo $cpfComMascara ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>UF</strong></td>
                                    <td><?php echo $result->uf ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Sexo</strong></td>
                                    <td><?php echo $result->sexo ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Telefone Celular</strong></td>
                                    <td><?php echo $result->telCelular ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Telefone Residencial</strong></td>
                                    <td><?php echo $result->telResidencial ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Grau de Instrução</strong></td>
                                    <td><?php echo $result->grauInstrucao ?></td>
                                </tr>

                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Email</strong></td>
                                    <td><?php echo $result->email ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right"><strong>Imagem</strong></td>
                                    <td><?php if ($result->foto_url != NULL) {
                                            echo $documento = '<img src="' . base_url() . 'imagensFuncionario/' . $result->foto_url . '"  class="dker img-thumbnail tamanho-foto" alt="...">';
                                        } else {
                                            echo "Não há nenhuma imagem cadastrada para o(a) $result->funcao(a) $result->nomeFuncionario. Por favor, <a href='#modalCadastrarFoto' rule='button' data-toggle='modal' class='sumb'>clique aqui</a> para cadastrar uma imagem.";
                                        } ?></td>
                                </tr>


                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>


                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGThree" data-toggle="collapse">
                                <span class="icon"><i class="icon-list"></i></span><h5>Dados Profissionais</h5>
                            </a>
                        </div>
                    </div>
                    <div class="collapse accordion-body" id="collapseGThree">
                        <div class="widget-content">
                            <table class="table table-bordered">

                                <tbody>

                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Situação</strong></td>
                                    <td><?php echo $result->situacao ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Função</strong></td>
                                    <td><?php echo $result->funcao ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Matricula</strong></td>
                                    <td><?php echo $result->matricula ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Jornada</strong></td>
                                    <td><?php echo $result->jornada ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Data Entrada Condominio</strong>
                                    </td>
                                    <td><?php echo date(('d/m/Y'), strtotime($result->dataEntrada)) ?></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; width: 30%"><strong>Data Próximas Férias</strong></td>
                                    <td><?php echo date(('d/m/Y'), strtotime($result->dataProximaFerias)) ?></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </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/addImagemFuncionarioVisualizar"
                      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 imagem para
                            o <?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 imagem</h5>

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

                        </div>
                        <img id="image_preview" 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>
        var loadFile = function (event) {
            var reader = new FileReader();
            reader.onload = function () {
                var output = document.getElementById('image_preview');
                output.src = reader.result;
            };
            reader.readAsDataURL(event.target.files[0]);
        };
    </script>
    <script>
        $(document).ready(function () {
            $("#imagem").change(function () {
                $("#image_preview").css({"height": "200px", "width": "200px;"});
            });
        });
    </script>


    <script type="text/javascript">
        function abreFichaCadastral() {
            var url = "<?php echo base_url() ?>morador/visualizarFichaCadastral/<?php echo $result->idMorador ?>";
            var win = window.open(url, name = "_blank", "left=400,top=300,width=700,height=500,location=no,menubar=no,toolbar=no");

            win.print();
        }


        $(document).ready(function () {
            $("#fichaCadastral").click(function () {
                abreFichaCadastral();
                return false;
            })
        });


    </script>