<?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"]."'");
//print_r($res);
?>

<!--<script>
$('#print').click(function(){
	this.hide();
	});
</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();
  $('#print').hide();
	window.onfocus=function(){ window.close();}
}
</script>

<style>
.rect{
  display: inline-block;
  height: 62px; /*sets height of element*/
  background: cornflowerblue; /*sets the background of this element (here a solid colour)*/
  transition: all 0.6s; /*sets a transition (for hover effect)*/
  padding-left: 8px; /*sets 'padding'*/
  padding-right: 0px; /*sets 'padding'*/
  line-height: 21px; /*for this, it sets vertical alignment*/
}

.tc{
	font-size:14px;
	font-family: Agency FB;
	color:black;
	padding: 1px 20px;
	 font-weight: bold;
}
.tc .txt{
	border:0px;
	border-bottom:1px solid #333;
	width:125px;
	font-family: Agency FB;
	color:black;
	margin:2px 5px;
	display:inline-block;
	 font-weight: bold;
	 	color: black;
	
}

.header{
	/*border-bottom:2px solid gray;*/
	margin:-8px 0px;
	padding:0px;
}
.name{
	font-family:Agency FB;
	color: black;
	 font-weight: bold;
	}
.content{
	color: #E20A0A;
font-weight: 800;
		}
		table {
 
  margin-top: 190px;
  
}
.span{
	border-bottom:2px  blue; 
	display:inline-block;
	font-family: Agency FB;
}
@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:220px"; >


  
	
  <tr>
    <td colspan="3">
	 <div style="margin:3px; padding:5px; color: black; font-size:23px; margin-top:-30px; width:200px;  font-weight: bold;" "><b> Sr-No. </b>
      <b><?php echo $res["tc_number"] ?></b></div>
    <div style="margin:3px; color: blue; padding:5px; width:235px; float:right" >
   
	

</div>
</br>
<div style="color: black;">
	   Admission No. <span class="span" style="color: black;  font-weight: bold;"><?php echo $res["adminno"] ?></span></br>
</div>
    </td>
    </tr>
  
  <tr >
  
    <td colspan="3"> 
	</br>
    <span class="name" style="font-size:16px;">1- Name Of Pupil :</span> <span class="txt" style="font-size:16px;"><?php echo $res["nameofpupil"] ?></span><br /> 
    <span class="name" style="font-size:16px;"> 2- Mother's Name : </span> <span class="txt" style="font-size:16px;"><?php echo $res["nameofmother"] ?></span><br />
    <span class="name" style="font-size:16px;">3- Father's/Guardian's Name : </span><span class="txt" style="font-size:16px; width:200px; 	border-bottom:1px solid #333;"><?php echo $res["nameofGuardien"] ?></span><br/> 
   
   <span class="name" style="font-size:16px;"> 4- Nationality : </span> <span class="txt" style="font-size:16px;">INDIAN</span><br /> 
   <span class="name" style="font-size:16px;"> 5- Category : </span> <span class="txt" style="font-size:16px;"><?php echo $res["cast"] ?></span><br />
   <span class="name" style="font-size:16px;"> 6- First  Admission in the Class : </span><input type="text"  style="font-size:16px;" class="txt" name="admission_class" value="<?php echo $res["admission_class"] ?>" /> <span class="name">Date Of Admission </span> : <input style="font-size:16px;" type="text" class="txt" name="year" value="<?php echo $res["year"] ?>" />  <br />
   <span class="name" style="font-size:16px;"> 7- Date Of Birth : </span> <span class="txt" style="font-size:16px;"><?php echo date("d-M-Y",strtotime($res["DOB"]));  ?></span><br />
    <span class="name" style="font-size:16px;">(In words): <span  style="font-size:16px; 	width:350px; 	border-bottom:1px solid #333; "><?php echo $res["dobininwords"] ?></span><br />
   <span class="name" style="font-size:16px;"> 8- Class in which pupil last studied : </span><input type="text" style="font-size:16px;" class="txt" name="last_class" value="<?php echo $res["last_class"] ?>" /> Roll.No : <input style="font-size:16px;" type="text" class="txt" name="roll" value="<?php echo $res["rollno"] ?>" />  <br /><br />
    <span class="name" style="font-size:16px;"> 9- School/board annual examination last taken with result: </span><input type="text"  style="font-size:16px;" class="txt" name="result" value="<?php echo $res["result"] ?>" /><br />
    <span class="name"> 10- Whether failed,if so once/twice,in same class : </span><input type="text" style="font-size:16px;" class="txt" name="failds" value="<?php echo $res["failds"] ?>" /><br />
   <span class="name" style="font-size:16px;"> 11- Subjects Studied : </span><u><?php echo $res["subject"] ?></u>  <br />
    <span class="name" style="font-size:16px;"> 12- Whether qualified for promotion to the higher class : </span><input type="text"style="font-size:16px;"   class="txt" name="qualified" value="<?php echo $res["qualified"] ?>" /> <br />
    <span class="name" style="font-size:16px;"> If so to which class(In Fig) : </span><input type="text" style="font-size:16px;" class="txt" name="infig" value="<?php echo $res["infig"] ?>" /> (In words): <input type="text" style="font-size:16px;" class="txt" name="inwords" value="<?php echo $res["inwords"] ?>" /> <br />
    <span class="name" style="font-size:16px;"> 13- Month upto which the pupil has paid school Fee  : </span><input type="text" style="font-size:16px;" class="txt" name="dues" value="<?php echo $res["dues"] ?>" /> <br />
	<span class="name" style="font-size:16px;" > 14- Total no. of school working days: </span><input type="text" style="font-size:16px;" class="txt" name="totalworking" value="<?php echo $res["totalworking"] ?>" />Total days present: <input type="text" style="font-size:16px;" class="txt"  name="totalpresent" value="<?php echo $res["totalpresent"] ?>" />  <br />
	<span class="name" style="font-size:16px;"> 15- Whether NCC cadet/boy scout/girl scout(detail may be given) : </span><input type="text" style="font-size:16px;" class="txt" name="qualified" value="<?php echo $res["ncc"] ?>" /> <br />
    <span class="name" style="font-size:16px;"> 16- Any Fee Concession availed of : if so, the nature of such concession : </span><input type="text" style="font-size:16px;" class="txt" name="concession" value="<?php echo $res["concession"] ?>" /> <br />
    <span class="name" style="font-size:16px;"> 17- Games played or extra curricular activities in which the pupil took part (Details may be given) : </span><input type="text" style="font-size:16px;" class="txt" name="activities" value="<?php echo $res["activities"] ?>" /> <br />
              <span class="name" style="font-size:16px;"> 18- General Conduct : </span><u><?php echo $res["Conduct"] ?></u> <br />
              
                   <span class="name" style="font-size:16px;"> 19- Any other Remark : </span><u><?php echo $res["remark"] ?></u> <br />

     <span class="name" style="font-size:16px;"> 20- Reason for leaving the school : </span><u><?php echo $res["reason"] ?></u> <br />
   
     
     <span class="name" style="font-size:16px;"> 21- Date of application of certificate : </span><input type="text" style="font-size:16px;" class="txt" name="date_of_application" value="<?php echo $res["date_of_application"] ?>" /> <br />
      <span class="name" style="font-size:16px;"> 22- Date of issue of certificate : </span><input type="text" style="font-size:16px;" class="txt" name="issue_date" value="<?php echo $res["issue_date"] ?>" /> <br />
     


</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  
  <tr>
    <td class="name"> <span class="txt"  style="  width:95px; 	color: black;" >&nbsp;</span> <br /><br />Date</td>
    <td class="name"><span class="txt" style="width:95px" 	color: black; >&nbsp;</span> <br /><br />Checked by Office Incharge</td>
    <td class="name"><span class="txt" style="width:95px; 	color: black; " >&nbsp;</span> <br /><br />
    Principal
    </td>
  </tr>
</table>
<?php } ?>
</form>
<script>window.print() </script>