<?php 
include ('includes/header.php');
$table_name = 'autolayout';
$page_name = 'auto_layout';
$data = ['layout' => 'layout_0'];
$db->insertIfEmpty($table_name, $data);
$res = $db->select($table_name, '*', '', '');

if(isset($_POST['submit'])){
	unset($_POST['submit']);
	$updateData = $_POST;
	$db->update($table_name, $updateData, 'id = :id',[':id' => 1]);
	echo "<script>window.location.href='". $page_name.".php?status=1'</script>";
}


?>

        <div class="col-md-12 mx-auto ctmain-table">
            <div class="card-body">
                <div class="card text-white ctcard">
                    <div class="card-header card-header-warning">
                        <center>
                            <h2><i class="icon icon-bullhorn"></i> Auto Ads layout</h2>
                        </center>
                    </div>
                    
           <div class="card-body">
                <form method="post">
                    <div class="form-group ctinput">
                        <label class="form-label"> Current layout :</label>
                    </div>
                    <div class="form-group ctinput">
                        <label class="form-label">Choose layout </label>
                        <select id="layout" name="layout">
                            <option value="layout_0"<?=$res[0]['layout']=='layout_0'?'selected':'' ?>>Layout 0</option>
                            <option value="layout_1"<?=$res[0]['layout']=='layout_1'?'selected':'' ?>>Layout 1</option>
                            <option value="layout_2"<?=$res[0]['layout']=='layout_2'?'selected':'' ?>>Layout 2</option>
                            <option value="layout_3"<?=$res[0]['layout']=='layout_3'?'selected':'' ?>>Layout 3</option>
                            <option value="layout_4"<?=$res[0]['layout']=='layout_4'?'selected':'' ?>>Layout 4</option>
                            <option value="layout_5"<?=$res[0]['layout']=='layout_5'?'selected':'' ?>>Layout 5</option>
                        	<option value="layout_6"<?=$res[0]['layout']=='layout_6'?'selected':'' ?>>Layout 6</option>
                        	<option value="layout_7"<?=$res[0]['layout']=='layout_7'?'selected':'' ?>>Layout 7</option>>
                        	<option value="layout_8"<?=$res[0]['layout']=='layout_8'?'selected':'' ?>>Layout 8</option>
                        	<option value="layout_9"<?=$res[0]['layout']=='layout_9'?'selected':'' ?>>Layout 9</option>
                        	<option value="layout_10"<?=$res[0]['layout']=='layout_10'?'selected':'' ?>>Layout 10</option>
                        	<option value="layout_11"<?=$res[0]['layout']=='layout_11'?'selected':'' ?>>Layout 11</option>
                        	<option value="layout_12"<?=$res[0]['layout']=='layout_12'?'selected':'' ?>>Layout 12</option>
                        	<option value="layout_13"<?=$res[0]['layout']=='layout_13'?'selected':'' ?>>Layout 13</option>
                        	<option value="layout_14"<?=$res[0]['layout']=='layout_14'?'selected':'' ?>>Layout 14</option>
                        </select>
                    </div>
                    <div class="form-group ctinputform-group">
                        <center>
                            <button class="btn btn-info" name="submit" type="submit">
                                <i class="icon icon-check"></i> Submit
                            </button>
                        </center>
                    </div>
                </form>
            </div>       


	<div class="grid-container">
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_0.resized.png" alt="Image 1">
            <div class="image-text">layout 0 [By RTX]</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_1.resized.png" alt="Image 2">
            <div class="image-text">layout 1</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_2.resized.png" alt="Image 3">
            <div class="image-text">layout 2</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_3.resized.png" alt="Image 1">
            <div class="image-text">layout 3</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_4.resized.png" alt="Image 2">
            <div class="image-text">layout 4</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_5.resized.png" alt="Image 3">
            <div class="image-text">layout 5</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_6.resized.png" alt="Image 1">
            <div class="image-text">layout 6</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_7.resized.png" alt="Image 2">
            <div class="image-text">layout 7</div>
        </div>   
         <div class="grid-item">
            <img src="./ads/auto_ads_lay_8.resized.png" alt="Image 3">
            <div class="image-text">layout 8</div>
        </div>          
         <div class="grid-item">
            <img src="./ads/auto_ads_lay_9.resized.png" alt="Image 1">
            <div class="image-text">layout 9</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_10.resized.png" alt="Image 2">
            <div class="image-text">layout 10</div>
        </div>   
         <div class="grid-item">
            <img src="./ads/auto_ads_lay_11.resized.png" alt="Image 3">
            <div class="image-text">layout 11</div>
        </div>  
                        
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_12.resized.png" alt="Image 1">
            <div class="image-text">layout 12</div>
        </div>
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_13.resized.png" alt="Image 2">
            <div class="image-text">layout 13</div>
        </div>                 
        <div class="grid-item">
            <img src="./ads/auto_ads_lay_14.resized.png" alt="Image 3">
            <div class="image-text">layout 14</div>
        </div>   
    </div>


                    </div>
                </div>
            </div>
        </div>
<style>
        .grid-container {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px; /* Adjust the gap between images */
            padding: 10px;
        }
        .grid-item {
            text-align: center;
        }
        .grid-item img {
            max-width: 100%;
            height: auto;
        }
        .image-text {
            margin-top: 5px;
            font-size: 16px;
            color: #fff;
        }
    </style>
<?php include ('includes/footer.php');?>