<?php require_once ("includes/topo.php");  ?>

<div class="content-body">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xl-12">
                <div class="row">
                    
                
                <div class="col-lg-12">
                    
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Páginas</h4>
                                <a href="pagina_add.php" class="btn btn-primary btn-sm">Adicionar página</a>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-responsive-md">
                                        <thead>
                                            <tr>
                                                <th style="width:50px;">
													<div class="form-check custom-checkbox checkbox-success check-lg me-3">
														<input type="checkbox" class="form-check-input" id="checkAll" required="">
														<label class="form-check-label" for="checkAll"></label>
													</div>
												</th>
                                                <th><strong>ID</strong></th>
                                                <th><strong>Página</strong></th>
                                                <th><strong>Atualizada em</strong></th>
                                                <th><strong>Status</strong></th>
                                                <th><strong></strong></th>
                                            </tr>
                                        </thead>
                                        <tbody>


                                            <?php
                                            //PÁGINAS
                                            $query = $pdo->query("SELECT * FROM paginas order by id desc");
                                            $paginas = $query->fetchAll(PDO::FETCH_ASSOC);
                                            for($i=0; $i < @count($paginas); $i++){
                                                foreach ($paginas[$i] as $key => $value){}

                                            ?>
                                            <tr>
                                                <td>
													<div class="form-check custom-checkbox checkbox-success check-lg me-3">
														<input type="checkbox" class="form-check-input" id="customCheckBox2" required="">
														<label class="form-check-label" for="customCheckBox2"></label>
													</div>
												</td>
                                                <td><strong><?php echo $paginas[$i]['id'] ?></strong></td>
                                                <td>
													<div class="d-flex align-items-center">
                                                        <a href="pagina_update.php?id=<?php echo $paginas[$i]['id'] ?>">
                                                            <span class="w-space-no"><?php echo $paginas[$i]['titulo'] ?></span>
                                                        </a>
													</div>
												</td>
                                                <td><?php echo $paginas[$i]['criada_em'] ?></td>
                                                <td><div class="d-flex align-items-center"><i class="fa fa-circle text-success me-1"></i> Ativo</div></td>
                                                <td>
													<div class="d-flex">
														<a href="pagina_update.php?id=<?php echo $paginas[$i]['id'] ?>" class="btn btn-primary shadow btn-xs sharp me-1"><i class="fa fa-pencil"></i></a>
													</div>
												</td>
                                            </tr>


                                            


                                            <?php } ?>


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

<?php require_once ("includes/rodape.php"); ?>



<?php if(!empty($_GET['adicionado']) == "ok" ) { ?>           		
<script>
	window.onload = function() {
		swal({
			title: 'Sucesso',
			text: ("Página criada com sucesso!"),
			type: 'success',
			confirmButtonText: 'Fechar'
		})
	};
</script>
<?php } ?>

<?php if(!empty($_GET['apagou']) == "ok" ) { ?>           		
<script>
	window.onload = function() {
		swal({
			title: 'Conta apagada!',
			text: ("Conta apagada com sucesso!"),
			type: 'success',
			confirmButtonText: 'Fechar'
		})
	};
</script>
<?php } ?>