<?php
$galeriasDao = new \Dao\Galerias();
$galeriasDao->getGaleriaPorId($conecta, base64_decode(filter_input(INPUT_GET, 'id')));
?>
<div class="breadcrumb-holder">
    <div class="container-fluid">
        <ul class="breadcrumb">
            <li class="breadcrumb-item"><a href="./">Home</a></li>
            <li class="breadcrumb-item active">Fotos | <?php echo $galeriasDao->nome; ?></li>
        </ul><!--/.breadcrumb -->
    </div><!---/.container-fluid -->
</div><!--/.breadcrumb-holder -->
<section class="dashboard-counts section-padding">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header d-flex align-items-center">
                        <h2 class="h5 display">Lista Fotos | <?php echo $galeriasDao->nome; ?></h2>
                    </div><!--/.card-header -->
                    <div class="card-footer">
                        <a href="?p=fotos-upload&id=<?php echo base64_encode($galeriasDao->id); ?>" class="btn btn-sm btn-success"><i class="fa fa-plus"></i> Upload</a>
                        <a href="?p=fotos-ordenar&id=<?php echo base64_encode($galeriasDao->id); ?>" class="btn btn-sm btn-warning"><i class="fa fa-plus"></i> Ordenar</a>
                    </div>
                    <div class="card-body">
                        <table class="table table-striped" id="dataTables">
                            <thead>
                                <tr>
                                    <th class="col-60">Nº</th>
                                    <th class="col-60">Imagem</th>
                                    <th>Legenda</th>
                                    <th class="no-sort col-30"></th>
                                    <th class="no-sort col-30"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $imagesDao = new \Dao\GaleriasImages();
                                $lst_images = $imagesDao->getLista($conecta, $galeriasDao->id, 'ORDER BY ordem ASC');
                                foreach ($lst_images as $item) {
                                    echo '
                                        <tr>
                                            <td>' . $item->ordem . '</td>
                                            <td align="center"><img src="' . aUrl . '/uploads/galerias/' . $item->fk_id_galeria . '/' . $item->image . '" height="50" alt="" /></td>
                                            <td>' . $item->legenda . '</td>
                                            <td><a href="?p=fotos-editar&id=' . base64_encode($item->id) . '" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></a></td>
                                            <td><a href="?p=fotos-excluir&id=' . base64_encode($item->id) . '" class="btn btn-sm btn-danger btn-delete"><i class="fa fa-trash"></i></a></td>
                                        </tr>
                                    ';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div><!--/.card-body -->
                </div><!--/.card -->
            </div><!--/.col-lg-12 -->
        </div><!--/.row -->
    </div><!--/.container-fluid -->
</section><!--/.dashboard-counts -->