<?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 extra");
  $ptcnumber=$tcnumber+1;
	$db->insertAry("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();
	
	$db->updateAry("student", array("status"=>3, "remarks"=>"TC"), "where idno='$_GET[id]' ");
	
}
?>
<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 ="myPrntbtn" value="print" 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:serif;
	color: black;
		font-weight:bold;
	
	}
.content{
	color: #E20A0A;
font-weight: 800;
		}
		table {
 
  margin-top: 190px;
  
}
.span{
	border-bottom:2px  black; 
	display:inline-block;
	font-family:"Courier New", Courier, monospace;
}



<style>
.tc{
	font-size:16px;
	font-family:"Courier New", Courier, monospace;
	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:"Courier New", Courier, monospace;
	color:black;
	margin:2px 5px;
	display:inline-block;
}
.span{
	border-bottom:2px dotted #000; 
	display:inline-block;
	font-family:"Courier New", Courier, monospace;
}


</style>
<div style="width:700px; height:1040px; padding:40px;border:6px solid black">
<table border="0" width="100%" class="tc" style="margin-top:-95px"; >
    <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>TRANSFER CERTIFICATE  </h1>
  </td>
      </tr>
    
  <tr>

        <td style="font-size:16px;"><span style="width:95px style="font-size:16px;">&nbsp;</span> <br /><b>Sr-No.<span  style="width:100px"><b>Tc/<?php echo   $srnumber=$db->getVal("SELECT tc_number FROM extra  where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and type='tc'"); ?></b></td>

    <td style="font-size:16px;"><span style="width:95px style="font-size:16px;">&nbsp;</span> <br /><b>Roll No.<span  style="width:100px"><b><?php echo $res["fincome"] ?></b></span></td>
    <td style="font-size:16px;"><span style="width:95px style="font-size:16px;">&nbsp;</span> <br /><b>Adm. No.<span  style="width:100px"><b><?php echo $res["admissionno"] ?></b></span></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; width:200px; border-bottom:1px doted #333;"><?php echo $res["name"] ?></span><br /> 
    <span class="name" style="font-size:16px;">2- Father's/Guardian's Name : </span><span class="txt"  style="font-size:16px; width:250px; border-bottom:1px doted #333;"><?php echo $res["fname"] ?></span><br/> 
   <span class="name" style="font-size:16px;"> 3- Mother's Name : </span> <span class="txt" style="font-size:16px; width:200px; border-bottom:1px doted #333;"><?php echo $res["mname"] ?></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- Whether SC or ST: </span> <input type="text" style="font-size:16px;" class="txt" name="cast" value="<?php echo $idata["cast"] ?>" /><br />
  <span class="name" style="font-size:16px;"> 6- Admission Class : </span><input type="text"  style="font-size:16px;" class="txt" name="admission_class" value="<?php echo $res["admissionclass"] ?>" /> <span class="name" style="font-size:16px;"><b>Admission Year</b> </span>: <input style="font-size:16px;" type="text" class="txt" name="year" value="<?php echo date("d-M-Y",strtotime($res["doa"]));  ?>" />  <br />
   <span class="name" style="font-size:16px;"> 7- Date of Birth according to admission register: </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):<input style="font-size:16px;  width:400px; border-bottom:1px doted #333;" type="text" class="txt" name="dobininwords" value="<?php echo $idata["dobininwords"] ?>" /><br>
     <span class="name" style="font-size:16px;"> 8- Class in which pupil last studied(in figure): </span><input type="text" class="txt" style="font-size:16px; width:100px; border-bottom:1px doted #333;" name="last_class" value="<?php echo $idata["last_class"] ?>" /><span class="name" style="font-size:16px;"><b>In Words</b> </span>: <input class="txt" style="font-size:16px; width:100px; border-bottom:1px doted #333;" type="text" class="txt" name="last_class_words" value="<?php echo $idata["last_class_words"] ?>" /> <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 $idata["result"] ?>" /><br />
    <span class="name"> 10- Whether failed,if so once/twice,in  the same class : </span><input type="text" style="font-size:16px;" class="txt" name="failds" value="<?php echo $idata["failds"] ?>" /><br />
   <span class="name" style="font-size:16px;"> 11- Subjects Offered : </span><input type="text" style="font-size:16px; width:350px; 	border-bottom:1px doted #333;" class="txt" name="subject" value="<?php echo $idata["subject"] ?>" /><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 $idata["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 $idata["infig"] ?>" /> (In words): <input type="text" style="font-size:16px;" class="txt" name="inwords" value="<?php echo $idata["inwords"] ?>" /> <br />
    <span class="name" style="font-size:16px;"> 13- Month upto which the (pupil has paid) school dues paid : </span><span  style="font-size:16px; width:200px; border-bottom-style: dotted;   #333; class="txt""><input type="text" style="font-size:16px;" class="txt" name="paidmonth" value="<?php echo $idata["paidmonth"] ?>" /> </span><br />
  
  	<span class="name" style="font-size:16px;" > 14- Total no. of working days: </span><input type="text" class="txt" style="font-size:16px; width:80px; border-bottom:1px doted #333;" class="txt" name="totalworking" value="<?php echo $idata["totalworking"] ?>" />Total days present: <input type="text" style="font-size:16px;" class="txt"  name="totalpresent" value="<?php echo $idata["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="ncc" value="<?php echo $idata["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; width:120px; border-bottom:1px doted #333;" class="txt" name="concession" value="<?php echo $idata["concession"] ?>" /> <br />
<span class="name" style="font-size:16px;"> 17- Games played or extra curricular activities in which the pupil has taken part (Details may be given) : </span><input style="font-size:16px;  width:450px; border-bottom:1px doted #333;" type="text" class="txt" name="extra_curriculum" value="<?php echo $idata["extra_curriculum"] ?>" /> <br />     
      <span class="name" style="font-size:16px;"> 18- Date of application for certificate : </span><input type="text" style="font-size:16px;" class="txt" name="date_of_application" value="<?php echo $idata["date_of_application"] ?>" /> <br />
 
     
     
      <span class="name" style="font-size:16px;"> 19- Date of issue of certificate : </span><input type="text" style="font-size:16px;" class="txt" name="issue_date" value="<?php echo $idata["issue_date"] ?>" /> <br />
     <span class="name" style="font-size:16px;"> 20- Reason for leaving the school : </span><input type="text" style="font-size:16px; width:200px; border-bottom-style: dotted;   #333;" class="txt" name="reason" value="<?php echo $idata["reason"] ?>" /> <br />
     <span class="name" style="font-size:16px;"> 21- General Conduct : </span><input type="text" style="font-size:16px;" class="txt" name="Conduct" value="<?php echo $idata["Conduct"] ?>" /> <br />
     <span class="name" style="font-size:16px;"> 22- Any other remark : </span><input type="text" style="font-size:16px;" class="txt" name="remark" value="<?php echo $idata["remark"] ?>" /> <br />
  
  
  
  
</td>
    </tr>
  <tr> <br />
  
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  </br>
  <tr>
    <td> <span class="txt" style="width:95px;">&nbsp;</span> <br /><br /><b>Sign Of Class Teacher</b></td>
    <td><span class="txt" style="width:95px">&nbsp;</span> <br /><br /><b>Checked by Office Incharge</b></td>
    <td><span class="txt" style="width:95px">&nbsp;</span> <br /><br />
   <b> Principal</b>
    </td>
  </tr><br>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;<b>(Full Name & Designation)</b></td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
</table></div>
</center>
<p>&nbsp;</p>
</form>