<?php
	//$ary_class= array('NURSERY','L.K.G','U.K.G','I','II','III','IV','V','VI','VII');
if($_POST){
	$data=json_encode($_POST);

	 $tcnumber=$db->getVal("SELECT max(tc_number) FROM cc_extra");
  $ptcnumber=$tcnumber+1;
	$db->insertAry("cc_extra",array("data"=>$data,"school_id"=>$_SESSION["admin"]["school_id"],"tc_number"=>$ptcnumber, "added_by"=>$_SESSION["admin"]["uid"],
"idno"=>$_GET["id"],"type"=>"tc"));
	echo $db->getErMsg();
}
?>
<form method="post" action="">
<?php 
$detail=$db->getVal("select data from cc_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" value="print" id ="myPrntbtn" onclick="window.print()" />
<?php
}else{
	?>
<input type="submit" value="save"  />
	<?php
}
$res=$db->getRow("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and idno=".$_GET["id"]);
//print_r($res);
?>

<style type="text/css">
@media print {
    #myPrntbtn {
        display :  none;
    }
}
</style>
<script src="<?php echo URL_ROOT ?>js/jquery.min.js"></script>
<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();
	window.onfocus=function(){ window.close();}
}
</script>

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

.header{
	/*border-bottom:2px solid gray;*/
	margin:-8px 0px;
	padding:0px;
}
.name{
	font-family:Arial, Helvetica, sans-serif;
	color: black;
		font-weight:bold;
			font-size:31px;
	
	}
.content{
	color: #E20A0A;
font-weight: 800;
		}
		table {
 
  margin-top: 190px;
  
}
.span{
	border-bottom:2px  black; 
	display:inline-block;
	font-family:"serif;
}



<style>
.tc{
	font-size:16px;
	font-family:"serif;
	color:#333;
	border:1px solid #333;
	font-weight:bold;
	width:658px;
	padding: 33px 44px;
}
.tc .txt{
    font-weight:bold;
	border:0px;
	border-bottom:2px dotted black;
	font-family:"serif;
	color:black;
	margin:2px 5px;
	display:inline-block;
}
.span{
	border-bottom:2px dotted #000; 
	display:inline-block;
	font-family:"serif;
}


</style>
<div style="width:700px; height:995px; padding:40px;border:6px solid black">
<table border="0" width="100%" class="tc" style="margin-top:-120px"; >
  <div class="headPrint" style="border: none;text-align:center; ">
			 
			<div style="margin-bottom:50px;"> <center><h1 style="font-size:45px;margin:0px 0px 0px 0px;color: black; font-family:Palatino; text-align: center; "><?php if(in_array($res["class"],$ary_class)){echo "PM ";} echo ucfirst($LinksDetails["site_name"]) ?></h1></center>
			 </div>
			 	<?PHP	if(in_array($res["class"],$ary_class))	
	{
	?> 
			  <img src="<?php echo $LinksDetails["logo"] ?>" height="90px;" width="100px" style="margin-left:-185px; position: relative; top: -55px;"> 
			  
<span style="font-size:21px;font-weight:800; margin-left:10px; margin-top:10px; position: relative; top: -125px; color: black; font-family:Times New Roman;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(Ashok Nagar Gaya 823001 ) <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;Govt Regn No. G-0074/PVTS/2014 
<?PHP }
else
{
?> 
			  <img src="<?php echo $LinksDetails["logo"] ?>" height="100px" width="110px" style="margin-left:-185px; position: relative; top: -55px;"> 

<span style="font-size:21px;font-weight:800; margin-left:40px; margin-top:10px; position: relative; top: -120px; color: black; font-family:Times New Roman;"><?php  echo ucfirst(nl2br($LinksDetails["contact_content"])) ?> </span><?php // echo ucfirst(nl2br($LinksDetails["contact_content"])) ?> 

<?php }


?>			 
		
		  </div>
		
  		 
 
    <tr>
	
        <td colspan="3" align="center" style="color:black;  "><h1>CHARACTER CERTIFICATE  </h1>
  </td>
      </tr>

  <tr>
 
    
         <td style="font-size:16px; font-family: serif;"><span style="width:95px style="font-size:16px;">&nbsp;</span> <br /><b>Sr-No.<span  style="width:100px; font-family: Arial, Helvetica, sans-serif;"><b>cc/<?php echo   $srnumber=$db->getVal("SELECT tc_number FROM cc_extra  where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and type='tc'"); ?></b></td>
   
    
    
    </tr>
  <br>
  <tr >
    <br><br>  
    <td colspan="3"> 
<br /> <br /> 
        <span class="name" style="font-size:18px;">This is to certify that Master/Miss:</span> <span class="txt" style="font-size:18px; width:280px; border-bottom:1px doted #333;"><?php echo $res["name"] ?></span></br></br>
        
  <span class="name" style="font-size:18px;">Son/Daughter Of Shri: </span><span class="txt"  style="font-size:18px; width:250px; border-bottom:1px doted #333;"><?php echo $res["fname"] ?></span> 
  <span class="name" style="font-size:19px;"> Roll No. :</span> </br></br><span class="txt" style="font-size:18px; width:100px; border-bottom:1px doted #333;"><?php echo $res["feducation"] ?></span>
    <span class="name" style="font-size:19px;"> has been a bonafide Student of this school.&nbsp;He/She has</br></br> passed All India Secondary /Senior Secondary School Examination</br></br> held in the month of <span><b><input type="text" style="font-size:16px;" class="txt" name="paidmonth" value="<?php echo $idata["paidmonth"] ?>" />.</b></span>&nbsp;<span class="name" style="font-size:18px;">to the best of my knowledge, </br></br>he/she bear a good moral character, during the session .<br /><br />  
    
    
  
       <span class="name" style="font-size:19px;"> We wish him/her every success in life.</span></br> </br></br>

  
</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  <br /></br></br> 
  <tr>
    <td style="font-size:16px; font-family: Arial, Helvetica, sans-serif;"> <span class="txt" style="width:95px; style="font-size:16px;">&nbsp;</span> <br /><br /><b>Sign Of Class Teacher</b></td>
    <td ><span  style="width:95px; ">&nbsp;</span> <br /><br /></td>
    <td style="font-size:16px; font-family: Arial, Helvetica, sans-serif;"><span class="txt" style="width:95px">&nbsp;</span> <br /><br />
   <b>&nbsp;Principal</b>
  </tr>
</br>
<tr>

        <td style="font-size:16px; font-family: serif;"><span style="width:95px style="font-size:16px; font-family: serif; 	font-weight:bold;">&nbsp;</span> <br /><b>Date.<input type="text" style="font-size:16px;" class="txt" name="cdate" value="<?php echo $idata["cdate"] ?>" /></b></td>


  </tr> 
    
  
</table></div>
</center>
<p>&nbsp;</p>
</form>