<?php
if($_POST){
	$data=json_encode($_POST);
	$flgIn=$db->insertAry("newtc",$value);
	echo $db->getErMsg();
}
?>
<form method="post" action="" >
<?php 
$detail=$db->getVal("select data from extra where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and type='tc'");
if($detail!=""){
	$idata=json_decode($detail,true);
?>
<input type="button" id="print"  value="print" onclick="window.print()" />
<?php
}else{
	?>

	<?php
}
$res=$db->getRow("select * from newtc where tc_number='".$_GET["id"]."'");
//echo $ss="select * from newtc where adminno='".$_GET["id"]."' and nameofpupil='".$_GET["name"]."'";
//print_r($res);
?>
<script src="<?php echo URL_ROOT ?>js/jquery.min.js"></script>
<!--<script>
$('#print').click(function(){
	this.hide();
	});
</script>-->
<style>
.colored {
  background: #000;
  border: 1px solid #ccc;
  width: 8px;
  height: 8px;
}

@media print {
  .colored div {
    border: 4px solid #000;
    width: 0;
    height: 0;
  }
}

</style>
<script>
var th = ['', 'thousand', 'million', 'billion', 'trillion'];
var dg = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
var tn = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
var tw = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
function toWords(s) {
    s = s.toString();
    s = s.replace(/[\, ]/g, '');
    if (s != parseFloat(s)) return 'not a number';
    var x = s.indexOf('.');
    if (x == -1) x = s.length;
    if (x > 15) return 'too big';
    var n = s.split('');
    var str = '';
    var sk = 0;
    for (var i = 0; i < x; i++) {
        if ((x - i) % 3 == 2) {
            if (n[i] == '1') {
                str += tn[Number(n[i + 1])] + ' ';
                i++;
                sk = 1;
            } else if (n[i] != 0) {
                str += tw[n[i] - 2] + ' ';
                sk = 1;
            }
        } else if (n[i] != 0) {
            str += dg[n[i]] + ' ';
            if ((x - i) % 3 == 0) str += 'hundred ';
            sk = 1;
        }
        if ((x - i) % 3 == 1) {
            if (sk) str += th[(x - i - 1) / 3] + ' ';
            sk = 0;
        }
    }
    if (x != s.length) {
        var y = s.length;
        str += 'point ';
        for (var i = x + 1; i < y; i++) str += dg[n[i]] + ' ';
    }
    return str.replace(/\s+/g, ' ');

}
$(document).ready(function(e) {
	$('#date').html(" "+toWords('<?php echo date('d', strtotime($res["dob"])); ?>')+" ");
	$('#year').html(" "+toWords('<?php echo date('Y', strtotime($res["dob"])); ?>')+" ");    
});
function printme(){
	window.print();
  $('#print').hide();
	window.onfocus=function(){ window.close();}
}
</script>

<style>
.tc{
	font-size:14px;
	font-family:"Courier New", Courier, monospace;
	color:#333;
	padding: 1px 20px;
}
.tc .txt{
	border:0px;
	border-bottom:1px solid #333;
	width:125px;
	font-family:"Courier New", Courier, monospace;
	color:green;
	margin:2px 5px;
	display:inline-block;
}

.header{
	/*border-bottom:2px solid gray;*/
	margin:-8px 0px;
	padding:0px;
}
.name{
	font-family:serif;
	color: green;
	}
.content{
	color: #E20A0A;
font-weight: 800;
		}
		table {
 
  margin-top: 190px;
  
}
.span{
	border-bottom:2px  blue; 
	display:inline-block;
	font-family:"Courier New", Courier, monospace;
}
@media print {
body {-webkit-print-color-adjust: exact;}
}

</style>

<?php  $il=$db->getVal("select id from extra where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and type='tc'"); 
if(isset($_GET["action"]) && $_GET["action"]=="cc"){
?>

<div style="width:700px;padding:20px;border:1px solid">
	<div style="text-align:center">
		<h1 style="margin:0; padding:0"><?php echo $LinksDetails["site_name"] ?></h1>
        <img src="<?php echo $LinksDetails["logo"] ?>" style="height:65px" />
        <div>Affi. No. 330483 School No. 50395</div>
        <div><?php echo nl2br($LinksDetails["contact_content"]) ?></div>
        <div style="display: inline-block;border-top: 5px solid #000;border-bottom: 5px solid #000;border-right: 15px solid #000;border-left: 15px solid #000;border-radius: 15px;font-size: 24px;font-weight: bold;padding: 5px 15px;margin: 45px 0;">CHARACTER CERTIFICATE</div>
    </div>
    <div style="font-family: Brush Script MT;font-size: 22px;">
    This is to certify that Master/Miss <span style="font-family: serif;font-size: 14px;border-bottom: dashed 1px;width: 380px;display: inline-block;"><h3><?php echo $res["name"] ?></h3></span><br />
Son/Daughter of shri <span style="font-family: serif;font-size: 14px;border-bottom: dashed 1px;width: 280px;display: inline-block;"><h3><?php echo $res["fname"] ?></h3></span> Roll No <span style="font-family: serif;font-size: 14px;border-bottom: dashed 1px;width: 120px;display: inline-block;"><h3><?php echo $res["admissionno"] ?></h3></span><br />
has been a bonafide student of this school. He/She has passed All India Secondary <br />
/ Senior Secondary School Examination held in the month of <span style="font-family: serif;font-size: 14px;border-bottom: dashed 1px;width: 200px;display: inline-block;"></span><br />
<span style="font-family: serif;font-size: 14px;border-bottom: dashed 1px;width: 340px;display: inline-block;"></span> to the best of my knowledge, he/she bears a<br />
good moral character, during the session.<br />
<br />
We wish him/her every success in life.    <br /><br />
    </div>
    <div>
    <div style="display:inline-block; width:30%">Date ............................ </div>
    <div style="display:inline-block; width:30%; text-align:center"> Class Teacher </div>
    <div style="display:inline-block; width:30%; text-align:right"> Principal</div>
    </div>
</div>

<?php }else{ ?>

<table border="0" width="100%" class="tc" style="margin-top:-900px;  " >
<div style="width:700px;   background-color: #ADCC4D; height:1000px; padding:40px; border:6px dotted green    ">

<div class="headPrint" style="border: none;text-align:center;">
			 
			<div style="margin-bottom:18px;"> <center><h1 style="font-size:32px;margin:5px 0px 0px 0px; color: green; font-family:Palatino; text-align: center; "><?php echo ucfirst($LinksDetails["site_name"]) ?></h1></center>
			 			 
			 </div>
			 
			  <img src="<?php echo $LinksDetails["logo"] ?>" height="80px" width="100px" style="margin-left:-50px; position: relative; top: -12px;"> 
			 <span style="font-size:21px;font-weight:800; margin-left:10px; margin-top:10px; position: relative; top: -75px; color: green;"> <?php echo ucfirst(nl2br($LinksDetails["contact_content"])) ?></span>
			 
			 
			 
		  </div>
 
    <tr>
	
        <td colspan="3" align="center" style="color:green;  "><h1>TRANSFER CERTIFICATE  </h1>
  </td>
      </tr>
	
  <tr>
    <td colspan="3">
	 <div style="margin:3px; padding:5px; font-size:23px; margin-top:-30px; width:200px" ><b> Cr-No. </b>
      <b><?php echo $res["tc_number"] ?></b></div>
    
	<div style="margin:3px; color:black; padding:5px; width:235px; float:right" >
	 <b> Date </b><span class="span" style="color: black;"><?php echo date("d-M-Y",strtotime($res["admindate"])); ?></span>

</div>
</br>
<div style="color: black; padding:5px; font-size:17px;">
	  <b> Institute Registration  No.</b> <span class="span" style="color: black;"><?php echo $res["adminno"] ?></span></br>
	 <b>University Enrollment No.</b><span class="span"  style= "font-size:17px; color: black; "><?php echo $res["rollno"] ?>
</div>
    </td>
    </tr>
  
  <tr >
  
    <td colspan="3"> 
	</br></br></br>
   <span class="name"  style="font-size:26px; font-family:  Script MT;">This is certified that Mr./Mrs./Miss.</span> <span  style="font-size:24px; font-family:  Script MT; width:170px; color: green; border-bottom:1px solid #333;"><?php echo $res["nameofpupil"] ?></span>
    <span class="name" style="font-size:26px; font-family:  Script MT;">Son/Wife/Daughter of shri&nbsp; </span><span  style="font-size:24px; font-family:  Script MT; width:170px; color: green; border-bottom:1px solid #333;"><?php echo $res["nameofGuardien"] ?></span>
    <span class="name" style="font-size:26px; font-family:  Script MT;">Whose date of birth  is</span> <span class="txt" style="font-size:20px; font-family:  Script MT;"><?php echo date("d-M-Y",strtotime($res["DOB"]));  ?></span>
   <span class="name" style="font-size:26px; font-family:  Script MT;">Was a Student of this institute from/during academic session</span> <span class="txt" style="font-size:26px; font-family:  Script MT;"><?php echo $res["year"] ?></span> <span class="name" style="font-size:26px; font-family:  Script MT;">to session</span> <span class="txt" style="font-size:26px; font-family:  Script MT;"><?php echo $res["qualified"] ?></span><span class="name" style="font-size:26px; font-family:  Script MT;">having passed/failed the </span> <span class="txt" style="font-size:26px; font-family:  Script MT;"><?php echo $res["result"] ?></span><span class="name" style="font-size:26px; font-family:  Script MT;">examination </span> <span class="txt" style="font-size:26px; font-family:  Script MT;"><?php echo $res["admission_class"] ?></span><span class="name" style="font-size:26px; font-family:  Script MT;">in division  </span> <span class="txt" style="font-size:26px; font-family:  Script MT;"><?php echo $res["failds"] ?></span><span class="name" style="font-size:26px; font-family:  Script MT;">.He/She IS learing this institute. To the best of my Knowledge and belief he she bears a good moral character and conduct.There are no outstanding dues against him. 
   
</br></br></br></br></br></br>

</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  
  <tr>
    <td> <span  style="width:95px">&nbsp;</span> <br /><br /></td>
    <td><span  style="width:95px">&nbsp;</span> <br /><br /></td>
    <td><span style="width:95px">&nbsp;</span> <br /><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Principal
    </td>
  </tr>
  </div>
</table>
<?php } ?>
</form>
<script>window.print() </script>