<div class="panel panel-default" id="painelSelecaoLista">
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-9 col-sm-9">
                <div class="row">
                    <div class="col-lg-12">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <td></td>
                                <td>Fila</td>
                                <td>Paciente</td>
                                <td>Hora Retirada</td>
                                <td>Tempo Espera</td>
                            </tr>
                            </thead>
                            <tbody style="height: 500px">
                            <?php
                            $contador;
                            $filaAnterior = "";
                            foreach ($listaPacienteEspera as $key => $data) {
                                if($filaAnterior != $data->NOMEFILA)
                                    $contador = 0;
                                $contador++;
                                $dataRetirada = new DateTime($data->HORARETIRADA);
                                $tempoEspera = $dataRetirada->diff(new DateTime())->format('%H:%I');
                                ?>
                                <tr>
                                    <td>
                                        <?= $contador ?>
                                    </td>
                                    <td>
                                        <?= $data->NOMEFILA ?>
                                    </td>
                                    <td>
                                        <?= $data->NOMEPACIENTE ?>
                                    </td>
                                    <td>
                                        <?= date('H:i', $dataRetirada->getTimestamp()) ?>
                                    </td>
                                    <td>
                                        <?= ($tempoEspera) ?>
                                    </td>
                                </tr>
                            <?php
                                $filaAnterior = $data->NOMEFILA;
                            } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-sm-3" align="center" id="panelButtonLista">
                <div class="row">
                    <div class="col-md-12" id="btnActionGroup">
                        <div id="btnControleDefault" align="left">
                            <button type="submit" name="VOLTAR" id="btnAction" onClick="history.go(-1)"
                                    class="btn btn-primary">
                                <img src="assets/img/VOLTAR.png" class="img-circle">
                                VOLTAR
                            </button>
                        </div>
                    </div>

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