<?php
session_start();
include('header.php');
require_once('../includes/database.php');

// Assuming $webdata and $udata are defined somewhere in your code
$color_obj = json_decode($webdata['color_json']);

// Default color values
$main_color = isset($color_obj->{'main_color'}) ? $color_obj->{'main_color'} : '#3498db';
$supportive_color = isset($color_obj->{'supportive_color'}) ? $color_obj->{'supportive_color'} : '#2ecc71';
$text_color = isset($color_obj->{'text_color'}) ? $color_obj->{'text_color'} : '#ffffff';
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Certificate">
    <title>Certificate</title>

    <link href="../bootstrap/css/sb-admin-2.min.css" rel="stylesheet">
    <style>
        @media print {
            body {
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
        }

        #certificate {
            width: 800px;
            height: 500px;
            padding: 20px;
            text-align: center;
            border: 10px solid white;
        }

        .bg-gradient-primary {
            background-image: linear-gradient(180deg, <?php echo $main_color; ?> 10%, <?php echo $supportive_color; ?> 100%);
        }

        .text-white {
            color: <?php echo $text_color; ?>;
        }
    </style>
</head>

<body>
    

    <script>
        window.onload = function () {
            document.addEventListener("contextmenu", function (e) {
                e.preventDefault();
            }, false);

            document.addEventListener("keydown", function (e) {
                if (e.ctrlKey && e.keyCode == 80) { // "Ctrl + P" for printing
                    printCertificate();
                }
            }, false);

            function printCertificate() {
                var printWindow = window.open('', '_blank');
                printWindow.document.write('<html><head><title>Certificate</title></head><body>');
                printWindow.document.write(document.getElementById('certificate').innerHTML);
               
                printWindow.document.close();
                printWindow.print();
            }
        };
    </script>
<script language="JavaScript">
  /**
    * Disable right-click of mouse, F12 key, and save key combinations on page
    * By Nirmal Singh (nsdausa@gmail.com)
    * For full source code, visit http://www.mycyberuniverse.com
    */
  window.onload = function() {
    document.addEventListener("contextmenu", function(e){
      e.preventDefault();
    }, false);
    document.addEventListener("keydown", function(e) {
    //document.onkeydown = function(e) {
       // "I" key
      if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
        disabledEvent(e);
      }
      // "J" key
      if (e.ctrlKey && e.shiftKey && e.keyCode == 74) {
        disabledEvent(e);
      }
      // "S" key + macOS
      if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        disabledEvent(e);
      }
      // "R" key
      if (e.ctrlKey && e.keyCode == 82) {
        disabledEvent(e);
      }
      // "N" key
      if (e.ctrlKey && e.keyCode == 78) {
        disabledEvent(e);
      }
      // "T" key
      if (e.ctrlKey && e.keyCode == 84) {
        disabledEvent(e);
      }
      

      // "O" key
      if (e.ctrlKey && e.keyCode == 79) {
        disabledEvent(e);
      }
      // "P" key
      if (e.ctrlKey && e.keyCode == 80) {
        disabledEvent(e);
      }

      // "A" key
      if (e.ctrlKey && e.keyCode == 65) {
        disabledEvent(e);
      }
      // "F" key
      if (e.ctrlKey && e.keyCode == 70) {
        disabledEvent(e);
      }
      // "G" key
      if (e.ctrlKey && e.keyCode == 71) {
        disabledEvent(e);
      }
      // "H" key
      if (e.ctrlKey && e.keyCode == 72) {
        disabledEvent(e);
      }
      // "J" key
      if (e.ctrlKey && e.keyCode == 74) {
        disabledEvent(e);
      }
      // "U" key
      if (e.ctrlKey && e.keyCode == 85) {
        disabledEvent(e);
      }
      // "F12" key
      if (event.keyCode == 123) {
        disabledEvent(e);
      }
      if (event.keyCode == 116) {
        disabledEvent(e);
      }
    }, false);
    function disabledEvent(e){
      if (e.stopPropagation){
        e.stopPropagation();
      } else if (window.event){
        window.event.cancelBubble = true;
      }
      e.preventDefault();
      return false;
    }
  };
</script>
  <link href="../bootstrap/css/sb-admin-2.min.css" rel="stylesheet">
<?php
$color_obj = json_decode($webdata['color_json']);
?>
<link href="../bootstrap/css/sb-admin-2.min.css" rel="stylesheet">

<style>
  .bg-gradient-primary {
    background-image: linear-gradient(180deg, <?php echo $main_color; ?> 10%, <?php echo $supportive_color; ?> 100%);
  }

  .text-white {
    color: <?php echo $text_color; ?>;
  }

  /* Add more styles as needed */
</style>

<body onload="window.print()" oncontextmenu="return false;">
  <div style="width:930px; height:610px; padding:20px; text-align:center; border: 10px solid white;" class="bg-dark">
    <div style="width:870px; height:545px; padding:20px; text-align:center; border: 4px solid white">
       <img src="https://upload.wikimedia.org/wikipedia/hi/thumb/c/cf/Aadhaar_Logo.svg/1200px-Aadhaar_Logo.svg.png" class="mx-auto d-block" width="170" height="100"><span style="font-size:50px; font-weight:bold" class="text-white">AADHAAR UCL CERTIFICATE</span>
      <<hr style="border: 0.9px solid <?php echo $main_color; ?>; border-radius: 5px;">
      <span style="font-size:25px" class="text-white"><i>This is to certify that Mr/Ms</i></span>
      <span style="font-size:25px" class="text-white"><i> <?php echo ucwords($udata['name']); ?>, Our website is CONNECTED with CSC API, using this certificate you can also start Aadhaar work at your shop.</i></span> <br/><br/>
      <span style="font-size:25px" class="text-white"><i>Appointed as AADHAAR <?php echo ucwords($udata['usertype']); ?></i></span> <br/><br/>
      
      <span style="font-size:20px" class="text-white"><b>CSC has brought the best Aadhaar Seva Kendra for all of you.</span></b></span>
      <!-----------------<span style="font-size:20px" class="text-white"><b>In <?php echo ucwords($ahkweb['name']); ?></span></b></span><br/>------------------>
      <hr style="border: 0.4px solid <?php echo $supportive_color; ?>; border-radius: 1px;">
      <div class="row">
        <div class="col-sm-6 text-right">
    <!-----------<img src="https://upload.wikimedia.org/wikipedia/hi/thumb/c/cf/Aadhaar_Logo.svg/1200px-Aadhaar_Logo.svg.png" class="mx-auto d-block" width="300" height="50">----------->
</div><span style="font-size:15px" class="text-white">THIS IS COMPUTER GENERATED CERTIFICATE DOES NOT REQUIRE SIGNATURE. (UIDAI is mandated to issue an easily verifiable 12 digit random number as Unique Identity - Aadhaar to all Residents of India).</span><br/><br><b><span style="font-size:12px" class="text-white">Help Line No- 1947 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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as: " . ucwords($udata['usertype']) . ", Shop: " . strtoupper(str_replace('&', ' ', $ahkweb['name'])) . "";
        ?>
        
        
        
      </div>
      <hr>
      
    </div>
  </div>
</body>
