<?php 
    // ini_set("display_error",1);
    session_start();
    include "../modules/Class/autoload.php";
    date_default_timezone_set('Asia/Dushanbe');
    include '../phpqrcode/qrlib.php';

    // Генерация QR-кода
    $tempDir = '../forpay/';
    if (!file_exists($tempDir)){
        mkdir($tempDir);
    }

       $qrText = 'https://pay.dc.tj/pay.php?a='.$_REQUEST['plate'].'&s='.$_REQUEST['summa'].'&c=&f1=346&f2=';
	
    //$fileName = $_REQUEST['plate'].'_'.date('ymdHis').'_'.$_REQUEST['summa'].'.png';
    //$pngAbsoluteFilePath = $tempDir . $fileName;
    //QRcode::png($qrText, $pngAbsoluteFilePath,QR_ECLEVEL_L,10,2);
	$url = 'https://rbda.dc.tj/pages/qr.php?text='.urlencode($qrText);
	//echo $url;
?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>РБДА</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="РБДА" name="description" />
    <meta content="Themesdesign" name="author" />
    <!-- App favicon -->
    <link rel="shortcut icon" href="../assets/images/nerufavicon.png">
    <!-- Bootstrap Css -->
    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- Icons Css -->
    <link href="../assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <!-- App Css-->
    <link href="../assets/css/app.min.css" rel="stylesheet" type="text/css" />
    <style>

        @media print {
            body * {
                visibility: hidden;
            }
            #printableDiv, #printableDiv * {
                visibility: visible;
            }
            #printableDiv {
                position: absolute;
                left: 0;
                top: 0;
            }
        }

        body {
            font-family: Arial, sans-serif;
        }
        .container {
            text-align: center;
            margin-top: 50px;
        }
        .header {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
        }

        .content {
            margin-top: 20px;
        }
        .qr-code {
            margin-top: 20px;
        }
    </style>
</head>

<body data-sidebar="dark">

    <!-- Begin page -->
    <div id="layout-wrapper">

        
        <?php include "header.php";?>
        <!-- ========== Left Sidebar Start ========== -->
        <?php include "menu.php"?>
        <!-- Left Sidebar End -->

        <!-- ============================================================== -->
        <!-- Start right Content here -->
        <!-- ============================================================== -->
        <div class="main-content">

            <div class="page-content">
                
            <div class="container">
                <div class="row">
                    <div class="col">
                        <div class="card">
                            <div class="card-body">
                                <h5 class="card-title">Оплата штрафа</h5>
                                <p class="card-text">
                                    <p>Отсканируйте Qr код и оплатите</p>
                                    <p>Номер автомобиля/ордера: <?=strtoupper($_REQUEST['plate'])?> </p>
                                    <p>Сумма штрафа: <?=$_REQUEST['summa']?> смн </p>
                                    <div class="qr-code">
                                        <img width="450" height="450" src="<?=$url?>" alt="QR Code">
                                    </div>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- End Page-content -->
        </div>
        <!-- end main content-->

    </div>
    <!-- END layout-wrapper -->

    <!-- JAVASCRIPT -->
    <script src="../assets/libs/jquery/jquery.min.js"></script>
    <script src="../assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="../assets/libs/metismenu/metisMenu.min.js"></script>
    <script src="../assets/libs/simplebar/simplebar.min.js"></script>
    <script src="../assets/libs/node-waves/waves.min.js"></script>
    <script src="../assets/js/app.js"></script>
    <script>
        function printDiv(divId) {
            var printContents = document.getElementById(divId).innerHTML;
            var originalContents = document.body.innerHTML;

            document.body.innerHTML = printContents;
            window.print();
            document.body.innerHTML = originalContents;
        }

        // Запускаем печать при загрузке страницы
        window.onload = function() {
            printDiv('printableDiv');
        };
    </script>

</body>

</html>