<?php
require("header.php");
?>

<?php
// Check if the form is submitted
if (isset($_POST['text1']) && isset($_POST['text2'])) {
    $text1 = $_POST['text1'];
    $text2 = $_POST['text2'];

    // Image path
    $imagePath = 'img/gen/busdt-receipt.jpg';

    // Load the image
    $image = imagecreatefromjpeg($imagePath);

    // Define text color (black)
    $textColor = imagecolorallocate($image, 237, 240, 244);

    // Calculate the Y-coordinates for each text
    $y1 = 200;
    $y2 = 1250;

    // Calculate the X-coordinates for each text
    $x1 = 335;
    $x2 = 519;

    // Load different font files for each text
    $fontPath1 = 'img/gen/fonts/Roboto-BoldCondensed.ttf'; // Replace with the actual path to the font file for Text 1
    $fontPath2 = 'img/gen/fonts/Roboto-Regular.ttf'; // Replace with the actual path to the font file for Text 2

    // Define font sizes for each text
    $fontSize1 = 55;
    $fontSize2 = 27;

    // Add text to the image using different fonts and font sizes
    applyFauxBoldText($image, $fontSize1, $x1, $y1, $textColor, $fontPath1, $text1);
    applyFauxBoldText($image, $fontSize2, $x2, $y2, $textColor, $fontPath2, $text2);

    // Set image quality
    $quality = 100;

    // Change the save path and filename as needed
    $timestamp = time();
    $savePath = "img/gen/usdt/generated_image_$timestamp.jpg";
    imagejpeg($image, $savePath, $quality);

    // Free up memory
    imagedestroy($image);

    // Provide the URL of the saved image for preview and download
    $imageURL = $savePath;
} else {
    echo "Please enter all three texts.";
}

function applyFauxBoldText($image, $fontSize, $x, $y, $color, $fontPath, $text)
{
    $offset = 1; // Adjust the offset to control the faux bold effect
    for ($i = 0; $i < $offset; $i++) {
        imagettftext($image, $fontSize, 0, $x + $i, $y, $color, $fontPath, $text);
    }
}
?>

<head>

    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th,
        td {
            border: 1px solid black;
            padding: 8px;
            text-align: left;
        }

        th {
            background-color: #f2f2f2;
        }
    </style>
</head>

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <!-- <h1>Panel Setting</h1> -->
                </div>
                <div class="col-sm-6">

                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <!-- Main content -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12 col-sm-12">
                    <div class="card card-dark card-tabs">
                        <div class="card-header p-0 pt-1" style="background-color: black;">
                            <ul class="nav nav-tabs" id="custom-tabs-one-tab" role="tablist">
                                <li class="nav-item">
                                    <a class="nav-link active" id="custom-tabs-one-vendor1-tab" data-toggle="pill" href="#custom-tabs-one-vendor1" role="tab" aria-controls="custom-tabs-one-vendor1" aria-selected="true">Vendor 1</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="custom-tabs-one-vendor2-tab" data-toggle="pill" href="#custom-tabs-one-vendor2" role="tab" aria-controls="custom-tabs-one-vendor2" aria-selected="false">Vendor 2</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="custom-tabs-one-vendor3-tab" data-toggle="pill" href="#custom-tabs-one-vendor3" role="tab" aria-controls="custom-tabs-one-vendor3" aria-selected="false">Vendor 3</a>
                                </li>
                            </ul>
                        </div>
                        <div class="card-body">
                            <div class="tab-content" id="custom-tabs-one-tabContent">
                                <div class="tab-pane fade show active" id="custom-tabs-one-vendor1" role="tabpanel" aria-labelledby="custom-tabs-one-vendor1-tab">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <!-- Form Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header" style="background-color: black;">
                                                    <h3 class="card-title">Create USDT Receipt</h3>
                                                    <ol class="breadcrumb float-sm-right" style="background-color: black;">

                                                        <li class="breadcrumb-item">Tools</li>
                                                        <li class="breadcrumb-item active">USDT Receipt</li>
                                                    </ol>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <form action="usdt-receipt.php" method="post">
                                                                <div class="form-group">
                                                                    <label for="text1">Amount</label>
                                                                    <input type="text" class="form-control" id="text1" name="text1" placeholder="356">
                                                                </div>
                                                                <div class="form-group">
                                                                    <label for="text2">Date and Time</label>
                                                                    <input type="text" class="form-control" id="text2" name="text2" placeholder="2023-08-11 20:13:02">
                                                                </div>
                                                                <button type="submit" class="btn btn-primary mt-2" style="background:black;border:none">Create</button>
                                                            </form>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <!-- Placeholder for image previews or any other content -->
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <!-- Image Preview Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header" style="background-color: black;">
                                                    <h3 class="card-title">Image Preview</h3>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <?php if (isset($imageURL)) : ?>
                                                        <img src="<?php echo $imageURL; ?>" alt="Generated Image" class="img-fluid">
                                                        <a href="<?php echo $imageURL; ?>" download class="btn btn-primary mt-2">Download Image</a>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="custom-tabs-one-vendor2" role="tabpanel" aria-labelledby="custom-tabs-one-vendor2-tab">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <!-- Form Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header" style="background-color: black;">
                                                    <h3 class="card-title">Create USDT Receipt</h3>
                                                    <ol class="breadcrumb float-sm-right" style="background-color: black;">
                                                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                                                        <li class="breadcrumb-item">Tools</li>
                                                        <li class="breadcrumb-item active">USDT Receipt</li>
                                                    </ol>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <form action="usdt-receipt.php" method="post">
                                                                <div class="form-group">
                                                                    <label for="text1">Amount</label>
                                                                    <input type="text" class="form-control" id="text1" name="text1" placeholder="356">
                                                                </div>
                                                                <div class="form-group">
                                                                    <label for="text2">Date and Time</label>
                                                                    <input type="text" class="form-control" id="text2" name="text2" placeholder="2023-08-11 20:13:02">
                                                                </div>
                                                                <button type="submit" class="btn btn-primary mt-2" style="background:black;border:none">Create</button>
                                                            </form>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <!-- Placeholder for image previews or any other content -->
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <!-- Image Preview Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header" style="background-color: black;">
                                                    <h3 class="card-title">Image Preview</h3>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <?php if (isset($imageURL)) : ?>
                                                        <img src="<?php echo $imageURL; ?>" alt="Generated Image" class="img-fluid">
                                                        <a href="<?php echo $imageURL; ?>" download class="btn btn-primary mt-2">Download Image</a>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="custom-tabs-one-vendor3" role="tabpanel" aria-labelledby="custom-tabs-one-vendor3-tab">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <!-- Form Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header" style="background-color: black;">
                                                    <h3 class="card-title">Create USDT Receipt</h3>
                                                    <ol class="breadcrumb float-sm-right" style="background-color: black;">
                                                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                                                        <li class="breadcrumb-item">Tools</li>
                                                        <li class="breadcrumb-item active">USDT Receipt</li>
                                                    </ol>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <form action="usdt-receipt.php" method="post">
                                                                <div class="form-group">
                                                                    <label for="text1">Amount</label>
                                                                    <input type="text" class="form-control" id="text1" name="text1" placeholder="356">
                                                                </div>
                                                                <div class="form-group">
                                                                    <label for="text2">Date and Time</label>
                                                                    <input type="text" class="form-control" id="text2" name="text2" placeholder="2023-08-11 20:13:02">
                                                                </div>
                                                                <button type="submit" class="btn btn-primary mt-2" style="background:black;border:none">Create</button>
                                                            </form>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <!-- Placeholder for image previews or any other content -->
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <!-- Image Preview Column -->
                                            <div class="card card-secondary">
                                                <div class="card-header"  style="background-color: black;">
                                                    <h3 class="card-title">Image Preview</h3>
                                                    <!-- Your existing card header code here -->
                                                </div>
                                                <div class="card-body">
                                                    <?php if (isset($imageURL)) : ?>
                                                        <img src="<?php echo $imageURL; ?>" alt="Generated Image" class="img-fluid">
                                                        <a href="<?php echo $imageURL; ?>" download class="btn btn-primary mt-2">Download Image</a>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>

            </div>
        </div>
    </section>

</div><!-- /.content-wrapper -->

<!-- Your existing scripts and footer here -->

<script>
    var loadFile = function(event) {
        var image = document.getElementById('output');
        image.src = URL.createObjectURL(event.target.files[0]);
    };
</script>
<!-- searching end -->

<!-- pagination -->

<?php
require("footer.php");
?>