<!--Cabecalho -->
<?php $this->load->view('commons/cabecalho'); ?>
<!--Header -->
<?php $this->load->view('commons/header'); ?>

<div id="containers" style="height: auto; min-height: 80%;">
<div class="col-md-3" >
    <div class="box box-solid">
        <div class="box-header with-border">
            <h3 class="box-title">Menu</h3>

        </div>
        <div class="box-body no-padding">
            <ul class="nav nav-pills nav-stacked">
                <li><a href="<?php echo base_url('saldo'); ?>"><i class="fa fa-usd" aria-hidden="true"></i> Saldo</a></li>
                <li><a href="<?php echo base_url('adicionarsaldo'); ?>"><i class="fa fa-plus-square" aria-hidden="true"></i>Adicionar Saldo</a></li>
                <li><a href="<?php echo base_url('transferencia'); ?>"><i class="fa fa-money" aria-hidden="true"></i>Realizar Transferência</a></li>
                <li class="active"><a href="<?php echo base_url('extrato'); ?>"><i class="fa fa-bar-chart" aria-hidden="true"></i> Minhas Transações</a></li>
                <li><a href="<?= base_url('termo') ?>"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Termo de Uso</a></li>
                <li><a href="<?= base_url('logout') ?>"><i  class="fa fa-sign-out"></i>Sair</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-9 animate fadeIn">
            <?php echo $this->session->flashdata('erro-form'); ?>    

            <p style="font-size: 20pt;">Resumo da Conta</p>
            <?php if ( ($cliente['nome_negocio']) == "") {  ?>
            <p>ESTE EXTRATO REFERE-SE À CONTA: &nbsp;<strong><?php echo $cliente['id_negocio'] ?> </strong> - Nome do Cliente: <strong><?php echo strtoupper($cliente['nome']) ?> </strong></p>
            <?php } else { ?>
            <p>ESTE EXTRATO REFERE-SE À CONTA: &nbsp;<strong><?php echo $cliente['id_negocio'] ?> </strong> - Nome do Cliente: <strong><?php echo strtoupper($cliente['nome']) ?> </strong> - Nome do Negócio: <strong><?php echo strtoupper($cliente['nome_negocio']) ?> </strong></p>
            <?php }?>
            <div class="table-responsive animated fadeIn">
                <table class="table">
                    <thead class="thead-inverse">
                        <tr>
                            <th>SALDO ANTERIOR</th>
                            <th>BONIFICAÇÃO RECEBIDA</th>
                            <th>SALDO ATUAL</th>
                            <th>DATA DA ÚLTIMA MOVIMENTAÇÃO</th>
                            <th>ÚLTIMA MOVIMENTAÇÃO</th>
                        </tr>
                    </thead>
                    <?php if ($transacao != NULL) { ?>
                        <?php if ($data['tipo_transacao_movimentacao'] == 'Transferência de Saldo') { ?>
                            <tbody>
                                <tr>                    
                                    <td><?php echo number_format($cliente['saldo_anterior'], 2, ',', '.') ?></td>
                                    <td><?php echo number_format($data['bonificacao'], 2, ',', '.'); ?></td>
                                    <td><?php echo number_format($cliente['saldo'], 2, ',', '.') ?></td>
                                    <td><?php echo date("d/m/Y", strtotime($data['data'])) . ' as ' . date("H:i:s", strtotime($data['data'])); ?></td>
                                    <td><?php echo $data['tipo_transacao_movimentacao']; ?></td>
                                </tr>
                            </tbody>
                        <?php } else { ?>
                            <tbody>
                                <tr>                    
                                    <td><?php echo number_format($cliente['saldo_anterior'], 2, ',', '.') ?></td>
                                    <td>-</td>
                                    <td><?php echo number_format($cliente['saldo'], 2, ',', '.') ?></td>
                                    <td><?php echo date("d/m/Y", strtotime($data['data'])) . ' as ' . date("H:i:s", strtotime($data['data'])); ?></td>
                                    <td><?php echo $data['tipo_transacao_movimentacao']; ?></td>
                                </tr>
                            </tbody>
                        <?php } ?>

                    <?php } else { ?>
                        <tbody>
                            <tr>                    
                                <td><?php echo number_format($cliente['saldo_anterior'], 2, ',', '.') ?></td>
                                <td>-</td>
                                <td>R$ <?php echo number_format($cliente['saldo'], 2, ',', '.') ?></td>
                                <td>-</td>
                                <td>Nenhuma movimentação realizada</td>
                            </tr>
                        </tbody>
                    <?php } ?>
                </table>
            </div>
            <hr>
            
            <div class="box box-success alert-desliz">
                <div class="box-header with-border">
                    <p class="box-title" style="font-size: 12px;"> Deslize para o lado para navegar </p>

                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool btn-alert-deslize" data-widget="remove"><i class="fa fa-times"></i></button>
                    </div>
                    <!-- /.box-tools -->
                </div>

            </div>
            
            <br>
            <form name="" method="GET" action="<?= base_url('extrato/resultado') ?>">

                <ul class="list-inline">
                    <li>
                        <label for="mes">Mês</label>
                        <select class="form-control form-control-sm" name="mes" required="">
                            <?php $mes_selecionado = $this->input->post('list'); ?>
                            <?php
                            foreach ($arr_meses as $mes => $meses) {
                                print("<option value=\"$mes\"");
                                if ($mes == $mes_selecionado) {
                                    print("selected");
                                }
                                print(">$meses ");
                            }
                            ?>
                        </select>
                    </li>    
                    <li>
                        <label for="ano">Ano</label>
                        <select class="form-control form-control-sm" name="ano" required="">

                            <?php
                            $ano_atual = date("Y");
                            for ($i = 2018; $i <= $ano_atual; $i++) {
                                echo "<option value=\"$i\">$i</option>\n";
                            }
                            ?>

                        </select>
                    </li>    
                    <li><button  class="btn btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin '></i> Aguarde " autocomplete="off"><i class="fa fa-check-circle"></i> Confirmar</button></li>
                </ul>
            </form>

            <div class="table-responsive animated fadeIn">
                <table class="table">
                    <thead class="thead-inverse">
                        <tr>
                            <th>CONTA ORIGEM</th>
                            <th>CONTA DESTINO</th>
                            <th>MOVIMENTAÇÃO</th>
                            <th>BONIFICAÇÃO RECEBIDA</th>
                            <th>VALOR</th>
                            <th>DATA</th>
                        </tr>
                    </thead>
                    <?php if ($extratos != NULL) { ?>
                        <?php foreach ($extratos as $extrato) { ?>
                            <tbody>
                                <tr>                    
                                    <td><?php echo $extrato->id_negocio_conta_origem ?></td>
                                    <td><?php echo $extrato->id_negocio_conta_destino ?></td>
                                    <td><?php echo $extrato->tipo_transacao_movimentacao ?></td>
                                    <?php if (($extrato->bonificacao) != 0 && $extrato->id_negocio_conta_destino != $_SESSION['id_negocio'] ) { ?>
                                    <td><?php echo number_format($extrato->bonificacao, 2, ',', '.'); ?> </td>
                                    <?php } else { ?>
                                    <td>-</td>
                                    <?php } ?>
                                    <td><?php echo number_format($extrato->valor, 2, ',', '.'); ?></td>
                                    <td><?php echo date("d/m/Y", strtotime($extrato->data)) . ' as ' . date("H:i:s", strtotime($extrato->data)); ?></td>
                                </tr>
                            </tbody>
                        <?php } ?>
                    <?php } else { ?>
                        <tbody>
                            <tr>  
                                <td>Nenhum resultado encontrado</td>
                            </tr>
                        </tbody>
                    <?php } ?>

                </table>
               <?php if ($extratos != NULL) { ?> 
               <?php echo $pagination ?>
               <?php } ?> 
            </div>
            <div class="box box-success alert-deslize">
                <div class="box-header with-border">
                    <p class="box-title" style="font-size: 12px;"> A <strong>bonificação recebida</strong> e o <strong>valor</strong> estão expressos em reais (R$)</p>

                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool btn-alert-deslize" data-widget="remove"></button>
                    </div>
                    <!-- /.box-tools -->
                </div>

            </div>                    

        </div>
    </div>
</div>
</div>
<?php $this->load->view('commons/rodape'); ?>

