<?php
$nationalId = $_POST['nationalId'] ?? '';
$pin = $_POST['pin'] ?? '';
$nameEnglish = $_POST['nameEnglish'] ?? '';
$nameBangla = $_POST['nameBangla'] ?? '';
$dateOfBirth = $_POST['dateOfBirth'] ?? '';
$dateOfToday = $_POST['dateOfToday'] ?? '';
$birthPlace = $_POST['birthPlace'] ?? '';
$fatherName = $_POST['fatherName'] ?? '';
$motherName = $_POST['motherName'] ?? '';
$address = $_POST['address'] ?? '';
$bloodGroup = $_POST['bloodGroup'] ?? '';
$photo = $_POST['photo'] ?? '';
$sign = $_POST['sign'] ?? '';
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>nid-<?php echo $nationalId; ?></title>
			<link rel="stylesheet" href="nidcss.css" data-n-g="" />
		<style>
			@media print {
			@page {
			margin: 0;
			}
			}
		</style>
		<script>
window.addEventListener("load", function () {

  if (typeof PDF417 === "undefined") {
    document.getElementById("barcode").innerHTML =
      "<p style='color:red;font-size:12px'>PDF417 library not loaded!</p>";
    console.error("Error: PDF417 library not loaded!");
    return;
  }

  var hub3_code = '<pin><?php echo $pin; ?></pin><name><?php echo strtoupper($nameEnglish); ?></name><DOB><?php echo $dateOfBirth; ?></DOB><ID><?php echo $nationalId; ?></ID>';

  var canvas = document.createElement("canvas");
  document.getElementById("barcode").appendChild(canvas);

  // Generate Barcode
  PDF417.init(hub3_code);
  var barcode = PDF417.getBarcodeArray();

  var bw = 2;
  var bh = 2;
  canvas.width = bw * barcode.num_cols;
  canvas.height = bh * barcode.num_rows;

  var ctx = canvas.getContext("2d");
  for (var r = 0; r < barcode.num_rows; r++) {
    for (var c = 0; c < barcode.num_cols; c++) {
      if (barcode.bcode[r][c] == 1) {
        ctx.fillRect(c * bw, r * bh, bw, bh);
      }
    }
  }

});
</script>


		<script src="https://info-uddokta.com/pdf417-min.js"></script>
		<script src="https://info-uddokta.com/bcmath-min.js"></script>

	</head>
	<body>
		<div id="__next" data-reactroot="">
			<main>
				<div>
					<main class="w-full overflow-hidden">
						<div class="container w-full py-12 lg:flex lg:items-start" style="padding-top: 0;">
							<div class="w-full lg:pl-6">
								<div class="flex items-center justify-center">
									<div class="w-full">
										<div class="flex items-start gap-x-2 bg-transparent mx-auto w-fit" id="nid_wrapper">
											<div id="nid_front" class="w-full border-[1.999px] border-black">
												<header class="px-1.5 flex items-start gap-x-2 justify-between relative">
													<img class="w-[38px] absolute top-1.5 left-[4.5px]" src="https://i.ibb.co/QkqrrVC/map-logo.jpg" alt="https://i.ibb.co/QkqrrVC/map-logo.jpg" />
													<div class="w-full h-[60px] flex flex-col justify-center">
														<h3 style="font-size:20px" class="text-center font-medium tracking-normal pl-11 bn leading-5"><span style="margin-top:1px;display:inline-block">গণপ্রজাতন্ত্রী বাংলাদেশ সরকার</span></h3>
														<p class="text-[#007700] text-right tracking-[-0rem] leading-3" style="font-size:11.46px;font-family:arial;margin-bottom:-0.02px">Government of the People&#x27;s Republic of Bangladesh</p>
														<p class="text-center font-medium pl-10 leading-4" style="padding-top:0px"><span class="text-[#ff0002]" style="font-size:10px;font-family:arial">National ID Card</span><span class="ml-1" style="display:inline-block"><span style="font-size:13px;font-family:arial">/</span></span><span class="bn ml-1" style="font-size:13.33px">জাতীয় পরিচয় পত্র</span></p>
													</div>
												</header>
												<div class="w-[101%] -ml-[0.5%] border-b-[1.9999px] border-black" style="width: 100%;margin-left: 0;"></div>
												<div class="pt-[3.8px] pr-1 pl-[2px] bg-center w-full flex justify-between gap-x-2 pb-5 relative">
													<div class="absolute inset-x-0 top-[2px] mx-auto z-10 flex items-start justify-center"><img style="background:transparent;width: 114px;height: 114px;" class="ml-[20px] w-[125px] h-[116px" src="https://i.ibb.co/F3Y3Tp5/flower-logo.png" alt="" /></div>
													<div class="relative z-50">
														<img style="margin-top:-2px" id="photo" class="w-[68.2px] h-[78px]" 
															src="<?php echo $photo; ?>" />
														<div class="text-center text-xs flex items-start justify-center pt-[5px] w-[68.2px] mx-auto h-[38.5px] overflow-hidden" id="sign">
															<span style="font-family:Comic sans ms"></span>
															<img id="sign" src="<?php echo $sign; ?>" />
														</div>
													</div>
													<div class="w-full relative z-50">
														<div style="height:5px"></div>
														<div class="flex flex-col gap-y-[10px]" style="margin-top: 1px;">
															<div>
																<p class="space-x-4 leading-3" style="padding-left:1px"><span class="bn" style="font-size:16.53px">নাম:</span><span class="" style="font-size:16.53px;padding-left:3px;-webkit-text-stroke:0.4px black" 
																	id="nameBangla"><?php echo $nameBangla; ?></span></p>
															</div>
															<div style="margin-top: 1px;">
																<p class="space-x-2 leading-3" style="margin-bottom:-1.4px;margin-top:1.4px;padding-left:1px"><span style="font-size:11px">Name:</span><span style="font-size:12.73px;text-transform: uppercase; padding-left:1px" 
																	id="nameEnglish"><?php echo $nameEnglish; ?></span></p>
															</div>
															<div style="margin-top: 1px;">
																<p class="bn space-x-3 leading-3" style="padding-left:1px"><span id="fatherOrHusband" style="font-size:14px">পিতা: </span><span style="font-size:14px;transform:scaleX(0.724)" 
																	id="fatherName"><?php echo $fatherName; ?></span></p>
															</div>
															<div style="margin-top: 1px;">
																<p class="bn space-x-3 leading-3" style="margin-top:-2.5px;padding-left:1px"><span style="font-size:14px">মাতা: </span><span style="font-size:14px;transform:scaleX(0.724)" 
																	id="motherName"><?php echo $motherName; ?></span></p>
															</div>
															<div class="leading-4" style="font-size:12px;margin-top:-1.2px">
																<p style="margin-top:-2px"><span>Date of Birth: </span><span id="dateOfBirth" class="text-[#ff0000]" style="margin-left: -1px;"
																	><?php echo $dateOfBirth; ?></span></p>
															</div>
															<div class="-mt-0.5 leading-4" style="font-size:12px;margin-top:-5px">
																<p style="margin-top:-3px"><span>ID NO: </span><span class="text-[#ff0000] font-bold" 
																	id="nationalId"><?php echo $nationalId; ?></span></p>
															</div>
														</div>
													</div>
												</div>
											</div>
											<div id="nid_back" class="w-full border-[1.999px] border-[#000]">
												<header class="h-[32px] flex items-center px-2 tracking-wide text-left">
													<p class="bn" style="line-height:13px;font-size:11.33px;letter-spacing:0.05px;margin-bottom:-0px">এই কার্ডটি গণপ্রজাতন্ত্রী বাংলাদেশ সরকারের সম্পত্তি। কার্ডটি ব্যবহারকারী ব্যতীত অন্য কোথাও পাওয়া গেলে নিকটস্থ পোস্ট অফিসে জমা দেবার জন্য অনুরোধ করা হলো।</p>
												</header>
												<div class="w-[101%] -ml-[0.5%] border-b-[1.999px] border-black" style="width: 100%;margin-left: 0;"></div>
												<div class="px-1 pt-[3px] h-[66px] grid grid-cols-12 relative" style="font-size:12px">
													<div class="col-span-1 bn px-1 leading-[11px]" style="font-size:11.73px;letter-spacing:-0.12px">ঠিকানা:</div>
													<div class="col-span-11 px-2 text-left bn leading-[11px]" id="address" style="font-size:11.73px;letter-spacing:-0.12px"
														><?php echo $address; ?></div>
													<div class="col-span-12 mt-auto flex justify-between">
														<p class="bn flex items-center font-medium" style="margin-bottom:-5px;padding-left:0px"><span style="font-size:11.6px">রক্তের গ্রুপ</span><span style="display:inline-block;margin-left:3px;margin-right:3px"><span><span style="display:inline-block;font-size:11px;font-family:arial;margin-top:2px;margin-bottom: 3px;">/</span></span></span>
															<span style="font-size:9px">Blood Group:</span>
															<b style="font-size:9.33px;display:inline-block" class="text-[#ff0000] mx-1 font-bold sans w-5" id="bloodGroup"><?php echo $bloodGroup; ?></b><span style="font-size:10.66px"> জন্মস্থান: </span><span class="ml-1" id="card_birth_place" style="font-size:10.66px"
																><?php echo $birthPlace; ?></span>
														</p>
														<div class="text-gray-100 absolute -bottom-[2px] w-[30.5px] h-[13px] -right-[2px] overflow-hidden" style="margin-right: 1px;margin-bottom: 1px;">
															<img src="https://host/Images/mududdron.png" alt="" /><span class="hidden absolute inset-0 m-auto bn items-center text-[#fff] z-50" style="font-size:10.66px"><span class="pl-[0.2px]">মূদ্রণ:</span><span class="block ml-[3px]">০১</span></span>
															<div class="hidden w-full h-full absolute inset-0 m-auto border-[20px] border-black z-30"></div>
														</div>
													</div>
												</div>
												<div class="w-[101%] -ml-[0.5%] border-b-[1.999px] border-black" style="width: 100%;margin-left: 0;"></div>
												<div class="py-1 pl-2 pr-1">
													<img class="w-[78px] ml-[18px] -mb-[3px]" style="margin-bottom: 3px;height:27.3px;" src="https://sheba24.xyz/bd/assets/Sign.png" />
													<div class="flex justify-between items-center -mt-[5px]">
														<p class="bn" style="font-size:14px">প্রদানকারী কর্তৃপক্ষের স্বাক্ষর</p>
														<span class="pr-4 bn" style="font-size:12px;padding-top:1px">প্রদানের তারিখ:<span class="ml-2.5" 
															id="dateOfToday"></span><?php echo $dateOfToday; ?></span>
													</div>
													<div id="barcode" class="w-full h-[39px] mt-1" alt="NID Card Generator" style="margin-top: 1.5px;margin-left: -3px;">
														<style>
															canvas {
															width: 102%;
															height: 100%;
															}
														</style>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
				</div>
				</main>
				<br /><br /><br /><br /><br /><br /><br />
				<footer></footer>
		</div>
		<div class="Toastify"></div>
		</main>
		</div>
		<script>
			window.print();
			setTimeout(function() {
			}, 3000); 
		</script>
	</body>
</html>