<?php
$musteri_no = $_GET['musteri_no'] ?? '';
$islem_tarih = $_GET['islem_tarih'] ?? date('Y-m-d');
$tc = $_GET['tc'] ?? '';
$gonderen_iban = $_GET['gonderen_iban'] ?? '';
$gonderen_adsoyad = $_GET['gonderen_adsoyad'] ?? '';
$alacakli_adsoyad = $_GET['alacakli_adsoyad'] ?? '';
$alacakli_iban = $_GET['alacakli_iban'] ?? '';
$alacakli_banka = $_GET['alacakli_banka'] ?? '';
$gonderen_sube = $_GET['gonderen_sube'] ?? 'FAST';
$tutar = $_GET['tutar'] ?? '0';

$islem_tarihi_fmt = date('d.m.Y', strtotime($islem_tarih));
$sira_no = rand(1000000000000, 9999999999999);
$belge_no = 'SYE' . date('Y') . rand(100000000, 999999999);
$ettn = sprintf('%08x-%04x-%04x-%04x-%012x', rand(), rand(0, 0xffff), rand(0, 0xffff), rand(0, 0xffff), rand());
$sorgu_no = rand(1000000, 9999999);
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <title>YapıKredi e-Dekont</title>
    <style>
        @media print { .no-print { display: none !important; } }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: Arial, sans-serif; font-size: 10px; padding: 20px; max-width: 210mm; margin: 0 auto; background: #fff; }
        .header { border-bottom: 3px solid #0066b3; padding-bottom: 15px; margin-bottom: 20px; }
        .logo { color: #0066b3; font-size: 22px; font-weight: bold; }
        .title { color: #0066b3; font-size: 18px; font-weight: bold; }
        .subtitle { text-align: center; margin-top: 10px; }
        .info-table { width: 100%; border-collapse: collapse; margin: 15px 0; }
        .info-table td { padding: 6px 10px; border: 1px solid #ddd; }
        .footer { margin-top: 30px; border-top: 1px solid #ccc; padding-top: 15px; font-size: 9px; }
        .print-btn { position: fixed; top: 20px; right: 20px; background: #0066b3; color: #fff; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px; font-weight: bold; }
    </style>
</head>
<body>
    <button class="print-btn no-print" onclick="window.print()">PDF Kaydet</button>
    
    <table width="100%" class="header">
        <tr>
            <td width="30%"><div class="logo">●● YapıKredi</div></td>
            <td width="40%" style="text-align:center;"><div class="title">e-Dekont</div></td>
            <td width="30%" style="text-align:right; font-size:8px;">
                <div>Yapı ve Kredi Bankası A.ş.</div>
                <div>Büyük Mükellefler VD: 9370020892</div>
            </td>
        </tr>
    </table>
    
    <div class="subtitle"><strong>FAST GELEN MESAJLARI</strong></div>
    
    <table class="info-table">
        <tr>
            <td width="15%">MÜŞTERİ NO</td>
            <td width="35%">: <?php echo htmlspecialchars($musteri_no); ?></td>
            <td width="15%">İŞLEM REF</td>
            <td width="35%">: bireysel ödeme</td>
        </tr>
        <tr>
            <td>VKN/TCKN/YKN</td>
            <td>: <?php echo htmlspecialchars($tc); ?></td>
            <td>SIRA NO/ID</td>
            <td>: - / <?php echo $sira_no; ?></td>
        </tr>
        <tr>
            <td>IBAN NO</td>
            <td>: <?php echo htmlspecialchars($gonderen_iban); ?></td>
            <td>PERSONEL SİCİL</td>
            <td>: SİSTEM</td>
        </tr>
        <tr>
            <td>İŞLEM TARİHİ</td>
            <td>: <?php echo $islem_tarihi_fmt; ?></td>
            <td>BELGE NUMARASI</td>
            <td>: <?php echo $belge_no; ?></td>
        </tr>
        <tr>
            <td>VALÖR</td>
            <td>: <?php echo $islem_tarihi_fmt; ?></td>
            <td>ETTN</td>
            <td>: <?php echo $ettn; ?></td>
        </tr>
    </table>
    
    <table class="info-table">
        <tr><td width="20%">ALICI HESAP</td><td>: <?php echo htmlspecialchars($alacakli_iban); ?></td></tr>
        <tr><td>İŞLEM TUTARI</td><td>: <?php echo htmlspecialchars($tutar); ?></td></tr>
        <tr><td>DÖVİZ CİNSİ</td><td>: Türk Lirası</td></tr>
        <tr><td>GÖNDEREN BANKA</td><td>: <?php echo htmlspecialchars($alacakli_banka); ?></td></tr>
        <tr><td>GÖNDEREN ŞUBE</td><td>: <?php echo htmlspecialchars($gonderen_sube); ?></td></tr>
        <tr><td>GÖNDEREN ADI</td><td>: <?php echo htmlspecialchars($gonderen_adsoyad); ?></td></tr>
        <tr><td>ÖDEME TÜRÜ</td><td>: Bireysel Ödeme</td></tr>
        <tr><td>SORGU NO</td><td>: <?php echo $sorgu_no; ?></td></tr>
    </table>
    
    <div style="text-align:center; margin:25px 0; font-weight:bold; text-decoration:underline;">
        YUKARIDAKİ TUTAR HESABINIZA BORÇ/ALACAK KAYDEDİLMİŞTİR.
    </div>
    
    <div class="footer">
        <table width="100%">
            <tr>
                <td>e-Dekont izni kapsamında elektronik ortamda üretilmiştir.</td>
                <td style="text-align:right;">
                    <div>Yapı ve Kredi Bankası A.ş.</div>
                    <div>Levent - İstanbul</div>
                    <div>Mersis No: 0937002089200741</div>
                    <div><strong>SİSTEM</strong></div>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
