<?php

include('nav-master.php');
include('response.php');








?>

<div style="margin-top: 15px; padding-left: 12px; "  class="hp-main-layout-content">
<div class="row mb-32 gy-32">
				<div class="col-12">
        <div class="page-header-modern">
            <h2 class="header-modern">Master</h2>

    <div class="user-dropdown dropdown">
        <button class="btn btn-user" type="button" data-toggle="dropdown">
            <i class=""></i>
             <img src="images/icon/invoice360-user.png" height=30px; width=30px;>
            <span class="caret"></span>
        </button>

        <ul class="dropdown-menu user-menu" aria-labelledby="userDropdown">
            <li>
                <a class="dropdown-item" href="">
                    <i class="fa fa-user me-2"></i> <?php echo strtok($_SESSION['user_name'], ' ');?> (<?php echo $_SESSION['role']; ?>)
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/payment-details.php">
                    <i class="fa fa-credit-card"></i> Billing history
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/company-profile.php">
                    <i class="fa fa-cog me-2"></i> Settings
                </a>
            </li>

            <li><hr class="dropdown-divider"></li>

            <li>
                <a class="dropdown-item text-danger" href="logout.php">
                    <i class="fa fa-sign-out me-2"></i> Sign Out
                </a>
            </li>
        </ul>
        </div>
    </div>
</div>


				
            <div class="col-lg-12">
                <div class="card">
                    
                            
        <div class="card-body">
		<!-- <hr> -->

		<div id="response" class="alert alert-success" style="display:none;">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<div class="message"></div>
		</div>


 <?php

$ref = $_GET['ref'] ?? '';
if ($ref === '') die("Invalid reference");

$stmt = $conn->prepare("
    SELECT 
        p.*,
        c.company_name,
        c.company_email
    FROM payments p
    JOIN company c ON c.id = p.company_id
    WHERE p.reference = ?
    LIMIT 1
");
$stmt->bind_param("s", $ref);
$stmt->execute();
$payment = $stmt->get_result()->fetch_assoc();

if (!$payment) die("Receipt not found");
?>



<h4 class="mb-3">Payment Receipt</h4>

<p><strong>Company:</strong> <?= htmlspecialchars($payment['company_name']) ?></p>
<p><strong>Email:</strong> <?= htmlspecialchars($payment['company_email']) ?></p>
<p><strong>Reference:</strong> <?= htmlspecialchars($payment['reference']) ?></p>
<p><strong>Amount:</strong> <?= $payment['currency'] ?> <?= number_format($payment['amount'],2) ?></p>
<p><strong>Status:</strong> <?= ucfirst($payment['status']) ?></p>
<p><strong>Gateway:</strong> <?= ucfirst($payment['gateway']) ?></p>
<p><strong>Paid At:</strong> <?= date('d M Y H:i', strtotime($payment['paid_at'])) ?></p>

<hr>

<button onclick="window.print()" class="btn btn-primary">
    Print Receipt
</button>
<a href="master-receiptpdf.php?ref=<?= urlencode($payment['reference']) ?>"
   class="btn btn-success ms-2">
    Download PDF
</a>


</div>
</div>

       


                                   

		


		
             
		
 <!-- Plugin -->
 	
 	
    <script src="app-assets/js/plugin/swiper-bundle.min.js"></script>
    <script src="app-assets/js/plugin/jquery.mask.min.js"></script>
    <script src="app-assets/js/plugin/autocomplete.min.js"></script>
    <script src="app-assets/js/plugin/moment.min.js"></script>

    <!-- Layouts -->
    <script src="app-assets/js/layouts/header-search.js"></script>
    <script src="app-assets/js/layouts/sider.js"></script>
    <script src="app-assets/js/components/input-number.js"></script>

    <!-- Base -->
    <script src="app-assets/js/base/index.js"></script>
    <!-- Customizer -->
    <script src="app-assets/js/customizer.js"></script>

    <!-- Charts -->
    <script src="app-assets/js/plugin/apexcharts.min.js"></script>
    <script src="app-assets/js/charts/apex-chart.js"></script>

    <!-- Cards -->
    <script src="app-assets/js/cards/card-advance.js"></script>
    <script src="app-assets/js/cards/card-analytic.js"></script>
    <script src="app-assets/js/cards/card-statistic.js"></script>

    <!-- Pages -->
    <script src="app-assets/js/pages/dashboard-ecommerce.js"></script>

    <!-- Custom -->
    <script src="assets/js/main.js"></script>  
	
	
	<script> 
	const textarea = document.getElementById('auto-resize-textarea');

textarea.addEventListener('input', () => {
  textarea.style.height = 'auto'; // Reset height to recalculate
  textarea.style.height = textarea.scrollHeight + 'px'; // Set height based on scrollHeight
});

// Optional: Initial resize if content is pre-filled
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
</script>
</body>


</html>