<?php 
include ('includes/header.php');

$table_name = 'app_image';

$data = ['app_img' => 'false','app_video' => '','app_logo' => 'https://panel.purpletv.app/uploads/app_images/3e6aec81-2845-45a1-a5c2-ec1a9b487a5e.png','app_mobile_icon' => 'https://panel.purpletv.app/uploads/app_images/6f3ad260-1780-4675-a03d-7fb15fe3ac82.png','app_tv_banner' => 'https://panel.purpletv.app/uploads/app_images/94cb4681-e764-497c-8674-723779a767f0.png','splash_image' => 'https://panel.purpletv.app/uploads/app_images/d523100f-251c-4032-a208-f1cd4a44b6b0.png','back_image' => 'https://panel.purpletv.app/uploads/app_images/25befbb3-3d1d-4584-9deb-b8c966649362.png',];
$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='". basename($_SERVER["SCRIPT_NAME"])."?status=1'</script>";
}

?>

    	<div class="col-md-6 mx-auto">
			<div class="card-body">
				<div class="card bg-primary text-white">
	                    <div class="card-header card-header-warning">
                        <center>
                            <h2><i class="icon icon-bullhorn"></i> App Background</h2>
                        </center>
                    </div>


					<div class="card-body">
						<form  method="post">
 
                    <div class="form-group">
                        <label for="back_image" class="form-label">Background Image</label>
                        <input class="form-control" name="back_image" id="back_image" value="<?= htmlspecialchars($res[0]['back_image']) ?>" type="text"/>
                    </div>

                
                <!-- Submit Button -->
                <div class="col-12 text-center">
                    <button type="submit" name="submit" class="btn btn-info mt-3">
                        <i class="icon icon-check"></i> Submit
                    </button>
                </div>
            </form>

            <!-- Image Previews Row -->
            <div class="row mt-4">


        <div class="col text-center">
            <img src="<?= htmlspecialchars($res[0]['back_image']) ?>" class="img-thumbnail image-preview" alt="Back Image">
        </div>
            </div>
        </div>
    </div>
</div>

<?php include('includes/footer.php'); ?>