<?php
session_start();

if (!isset($_login_page) || !$_login_page) {
    
    if (!isset($_SESSION['username'])) {
        header("Location: " . $_main_root . "index.php");
        exit();
    }
}

$_page_title = "Pending Event List";
$_main_root = '../';
include($_main_root . "config/config.php");
include($_main_root . "db/model.php");
$db = new Model();

if (isset($_GET['id'])) {
	$payId = $_GET['id'];
	if ($payId > 0) {
		$payList = $db->EventPayListByEventId($payId);
		$event = $db->GetEventById($payId);
	}
}



?>

<!DOCTYPE html>
<html>

<head>
	<!-- Required meta tags -->
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<!-- Bootstrap CSS -->
	<link rel="stylesheet" href="<?php echo $_main_root; ?>vendor/bootstrap-5.3.0/css/bootstrap.min.css">

	<title> Payment Summary </title>

	<style>
		body {
			font-family: 'Times New Roman', Times, serif;
		}

		.invoice-box {
			max-width: 900px;
			margin: auto;
			font-size: 16px;
			line-height: 24px;
			/* font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; */
			color: #000;
		}

		@media print {
			body * {
				visibility: hidden;
			}

			@page {
				size: A4 portrait
			}

			.container_content,
			.container_content * {
				visibility: visible;
			}
		}
	</style>

</head>

<body>

	<div class="container_content">
		<div class="invoice-box">

			<!-- report header section -->
			<table class="w-100" style="background-color:#E6E6E6;">
				<tr>
					<td>
						<img src="snapmoment_logo.png" style="width: 100%; max-width: 300px; margin-top: 20px !important; margin-left: -22px !important; " />
					</td>
					<td style="text-align: right;">
						<h3 style="margin-top: 20px; margin-right: 15px;">PAYMENT SUMMARY</h3><br /><br />
						<p style="margin-right: 15px; font-size:20px;">Print Date : <?php echo sDate(date(""))?></p>
					</td>
				</tr>
			</table>

			<!-- company address and client contact -->
			<table class="my-3 w-100">
				<tr>
					<td></td>
					<td style="text-align: right; margin-right: 10px;">
						Contact: +8801673-157878 <br />
						Location: House #478, Road-7, Block- H, <br />
						Bashundhara R/A, Dhaka
					</td>
				</tr>
				<tr>
					<td>
						To ,<br />
						<h5>
							<strong><?php echo strtoupper($event['client_name']); ?></strong>
						</h5>
						Contact: <?php echo $event['phone']; ?> <br />
						Email: <?php echo $event['email']; ?>
					</td>

				</tr>
			</table>



			<!-- packege details table -->
			<strong>Package Details : </strong>
			<table class="table table-bordered border-dark mt-1">
				<thead class="table-dark">
					<tr class="text-center" style="font-size: 20px;">
						<th style="width:150px">Event Date</th>
						<th>Package</th>
						<th style="width:150px">Amount</th>
					</tr>
				</thead>
				<tbody>
					<tr class="text-center">
						<td><?php echo sDate($event['event_date_time']); ?></td>
						<td><?php echo $event['package_name']; ?></td>
						<td style="text-align: right;"><?php echo $event['total_amt']; ?></td>
					</tr>
				</tbody>
			</table>

			<!-- Watermart logo -->

			<!-- <div style="position: relative;">
			<img src="logo_watermark.png" style="margin-left:-10px; height:300px; z-index: -1; position: absolute;" alt="">
			</div> -->

			<!-- Payment details table -->
			<strong>Payment Details :</strong>
			<table class="table table-bordered border-dark mt-1">
				<thead class="table-dark">
					<tr class="text-center" style="font-size: 20px;">
						<th>#</th>
						<th style="width:150px">Date</th>
						<th>Invoice</th>
						<th style="width:300px">Comments</th>
						<th style="width:150px">Amount</th>
					</tr>
				</thead>
				<tbody>

					<?php $sl = 1;
					foreach ($payList as $row) { ?>
						<tr class="text-center">
							<td><?php echo $sl++ ?></td>
							<td><?php echo sDate($row['payment_date']); ?></td>
							<td><?php echo InvoicePrefix::EVENT_PAY . $row['invoice']; ?></td>
							<td><?php echo $row['comment']; ?></td>
							<td style="text-align: right;"><?php echo $row['payment_amt']; ?></td>
						</tr>
					<?php } ?>


					<tr class="text-center border-0">
						<td class="border-0"></td>
						<td class="border-0"></td>
						<td class="border-0"></td>
						<th class="border-0" style="text-align: right;">Total Payment : </th>
						<th class="border-1" style="text-align: right; background-color:#E6E6E6;"><?php echo $event['total_pay']; ?></th>
					</tr>
					<tr class="text-center border-0">
						<td class="border-0"></td>
						<td class="border-0"></td>
						<td class="border-0"></td>
						<th class="border-0" style="text-align: right;">Due : </th>
						<th class="border-1" style="text-align: right; background-color:#E6E6E6;"><?php echo $event['due_amount']; ?></th>
					</tr>

				</tbody>
			</table>

			<!-- signature and paid logo -->

			<table class="w-100">
				<tr>
					<td>
						<img class="ms-4" src="raihan_signature.jpg" style="height: 110px;" />
					</td>
					<td style="text-align: right">
						<?php if ($event['due_amount'] == 0) {
							echo '<img class="me-5" src="paid.png" style="height: 135px; " />';
						} ?>
					</td>
				</tr>
			</table>
		</div>
	</div>

	<div class="text-center" style="padding:20px;">
		<input type="button" value="Download" class="btn btn-success btn_print" onclick="print_summary()">
	</div>

	<script src="<?php echo $_main_root; ?>style/DataTables/jQuery-3.6.0/jquery-3.6.0.min.js"></script>
	<script src="<?php echo $_main_root; ?>style/bootstrap-5.3.0/js/bootstrap.bundle.min.js"></script>

	<script>
		$(document).ready(function() {
			window.print();
		});

		function print_summary() {
			window.print();
		}
	</script>

</body>

</html>