<?php
session_start();
$_main_root = '../';
include($_main_root."config/enum.php");

if (!isset($_login_page) || !$_login_page) {
    
    if (!User::Login()) {
        header("Location: " . $_main_root . "index.php");
        exit();
    }
}

$_page_title = "Pending Event List";

include($_main_root . "config/config.php");
include($_main_root . "db/model.php");
$obj = new Model();

if(isset($_GET['id'])){
	$payId=$_GET['id'];
	if($payId>0){
		$pay = $obj->GetEventPaymentById($payId);
		$event=$obj->GetEventById($_GET['eid']);
	}
}else if(isset($_GET['lp'])){
	$eventId=$_GET['lp'];
	if($eventId>0){
		$pay = $obj->LastEventPayByEventId($eventId);
		$event=$obj->GetEventById($eventId);
	}
}



?>

<!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">
			<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;">INVOICE</h3><br /><br />
						<p style="margin-right: 15px; font-size:20px;">Date : <?php echo $pay['payment_date'];?></p>
						<p style="margin-right: 15px; font-size:22px;"><strong>Invoice No: <?php echo InvoicePrefix::EVENT_PAY.$pay['invoice']; ?></strong></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>

			<!-- 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 -->
			<table class="table table-bordered border-dark mt-1">
				<thead class="table-dark">
					<tr class="text-center" style="font-size: 20px;">
						<th>Event Date</th>
						<th >Package</th>
						<th style="width:300px">Description</th>
						<th >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><?php echo $pay['comment'];?></td>
						<td style="text-align:right"><?php echo $pay['payment_amt'];?></td>
					</tr>
					
					<tr class="text-center border-0">
						<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>
						<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="mt-4 ms-4" src="raihan_signature.jpg" style="height: 120px; " />
					</td>
					<td style="text-align: right">
						<?php if($event['due_amount']==0){
							echo '<img class="mt-4 me-5" src="paid.png" style="height: 200px; " />';
						} ?>
					</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_invoice()">
	</div>

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

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

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

</html>