File: /var/www/html/video-rental/wp-content/themes/video-rental/invoices/transaction_invoice.php
<?php
require_once('../../../../wp-load.php');
$transid = isset($_GET['transid']) ? sanitize_text_field($_GET['transid']) : '';
global $wpdb;
$transactions = $wpdb->get_results(
$wpdb->prepare(
"SELECT t.*, r.*
FROM wp_video_transactions t
LEFT JOIN wp_video_rentals r ON t.rental_id = r.id
WHERE r.id = %d",
(int) $transid
)
);
$total = 0;
$rows = '';
$sl = 1;
foreach ($transactions as $txn) {
$total += floatval($txn->amount);
$post = get_post($txn->video_id);
$title = $post ? $post->post_title : 'Untitled';
$rented_from = new DateTime($txn->rented_at);
$rented_to = clone $rented_from;
$rented_to->modify("+{$txn->duration_days} days");
$rows .= "<tr>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>{$sl}</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>{$txn->transaction_id}</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>{$title}</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>" . date('M d, Y h:i a', strtotime($txn->rented_at)) . "</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>" . $rented_to->format('M d, Y h:i a') . "</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>{$txn->license}</td>
<td style='color: #ffffff; font-family: Ubuntu, sans-serif; font-size: 11px; font-weight: 400; padding: 19px 20px; background-color: #0E0E0E;'>$ " . number_format($txn->amount, 2) . "</td>
</tr>";
$sl++;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no">
<title>Invoice</title>
<link
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap"
rel="stylesheet">
<style>
@page {
size: A4;
margin: 0;
}
</style>
</head>
<body style="margin: 0; background: #000000 !important;">
<div class="pdf-wrp" style="width: 100%; background-color: #000000 !important; padding:50px 0px;">
<header class="header" style="width: 100%;text-align: center;padding-top: 30px;padding-bottom: 20px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td
style="text-align: left; font-family: Arial, Helvetica, sans-serif; color: #F9B548; font-size: 30px; font-weight: bold; padding: 0 30px;">
Invoice
</td>
<td style="text-align: right; padding: 0 30px;">
<img style="width:81px; margin: 0; border: none; display: inline-block;"
src="<?php echo get_template_directory_uri(); ?>/img/logo.svg" alt="">
</td>
</tr>
</table>
</header>
<div class="inner-wrp" style="padding: 0 30px;">
<div class="invoice-table"
style="background-color: #000; border-radius: 12px 12px 0px 0px; display: block; margin-top: 50px; padding-bottom: 60px; border-bottom: 1px solid #10357630; margin-bottom: 40px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="40px"
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E; border-top-left-radius: 12px;">
Sl
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E;">
Transaction ID
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E;">
Purchase title
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E;">
Transaction date and time
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E; ">
Rented till date and time
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E; border-top-right-radius: 12px;">
License
</th>
<th
style="font-size: 10px; font-weight: 600;font-family: 'Ubuntu', sans-serif; color: #ffffff;; border-bottom: 1px solid #F6E1E4; padding: 19px 20px; text-align: left; background-color: #0E0E0E;">
Amount</th>
</tr>
<tr>
</tr>
<tr>
<?php echo $rows ?: '<tr><td colspan="7">No transactions found</td></tr>'; ?>
</tr>
</table>
</div>
<div style="width: 100%; padding: 20px 0 60px;">
<table width="200px" align="right">
<tr>
<td style="color: #F9B548; font-size: 11px; text-align: right;">SubTotal:</td>
<td style="color: #fff; font-size: 11px; text-align: right;">$
<?php echo number_format($total, 2); ?>
</td>
</tr>
<tr>
<td style="color: #F9B548; font-size: 11px; font-weight: 700; text-align: right;">Total:</td>
<td style="color: #fff; font-size: 11px; font-weight: 700; text-align: right;">$
<?php echo number_format($total, 2); ?>
</td>
</tr>
</table>
<!-- <div style="clear: both;"></div>
<div style="margin-top: 40px;">
<p style="border-bottom: 1px solid #fff; width: 371px;"></p>
<p style="font-size: 12px;">Authorized sign</p>
</div> -->
</div>
</div>
</div>
</body>
</html>