<?php

    if (isset($_GET['delete'])){

        $use->delete('cards',$_GET['delete']);

        echo "<script>location='./?page=cards'</script>";

    }

?>

<div class="row">

    <div class="col-md-12">

        <div class="card">

            <div class="card-header bg-transparent">

                <div class="row align-items-center">

                    <div class="col">

                        <h6 class="text-uppercase text-muted ls-1 mb-1">List Cards</h6>

                    </div>

                </div>

            </div>
			<div class="card-body">
				<h4><?=isset($_GET['message'])?$_GET['message']:''?></h4>
            
                <table class="table table-striped" id="myTable">

                    <thead>

                    <tr>

                        <th width="50">#</th>

						<th>Card</th>
						<th>Name</th>
						<th>General</th>
						<th>Love</th>
						<th>Finance</th>
						<th>Health</th>

                        <th>Action</th>

                    </tr>

                    </thead>

                    <tbody>

                    <?php foreach ($use->getAllCards() as $card): 

                        

                    ?>

                        <tr>

                            <td>#</td>

                            
                            <td width="150">

                                <img style="width: 30px;" src="<?=$base_url.'tarot-video/images/card/'.$card['slug'].'.png'?>">

                            </td>
							<td><?= ucwords(str_replace('-',' ',$card['slug'])) ?></td>
							<td><a href="<?= $card['general'] ?>" target="_blank">Open</a></td>
							<td><a href="<?= $card['love'] ?>" target="_blank">Open</a></td>
							<td><a href="<?= $card['finance'] ?>" target="_blank">Open</a></td>
							<td><a href="<?= $card['health'] ?>" target="_blank">Open</a></td>

                            <td width="150">

                                <!--<a href="./?page=cards&delete=<?= $card['id'] ?>" class="btn btn-danger btn-sm">Delete</a>-->

                                <a href="./?page=cards-edit&id=<?= $card['id'] ?>" class="btn btn-info btn-sm">Edit</a>

                            </td>

                        </tr>

                    <?php endforeach; ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

</div>