<style>
.top-bar-minimize { display: none; }
thead, tfoot { display: table-header-group; }
.top-bar+.well, .accordion .accordion-heading+.accordion-body { display: inline-block !important; width: 100% !important; overflow: inherit !important; }
</style>
<script type="text/javascript">
function getType(id){
	$.post( "ajax.php", { type: "exmtype" ,class: id } , function( data ) {
	  	$("#extype").html(data);
	});
}
function smsDivNoHeader(){
	var id=$("#smsTXT").val();
	var examtype=$("#examtype").val();
	$.post( "ajax.php", { type: "sendsmsexamcbse" ,AllData: id, examtype: examtype } , function( data ) {
	  	alert(data);
	});
}
function findStudent(t){
	var cls=$("#class").val();
	var section=$("#section").val();
	$.post( "ExamCBSE/ajax.php", { type: "findStudent" ,cls: cls, section: section } , function( data ) {
	  	$("#findStudent").html(data);
	});
}
</script>
<style>
.headPrint { display: none }
table{font-size:10px;}
</style>

<div id="printableDiv">
<?php 
include("../../db.php"); 

SESSION_START();
		 //$sqldate=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_SESSION["admin"]["uid"]."'");
		 
						 // $_SESSION["admin"]["school_id"]=$_SESSION['school_id'];
                          $aryForm["idno"]=$_REQUEST["idno"];
                          
               
					 
		                $_POST["idno"]=$_REQUEST["idno"];
		    
			            $_POST["class"]=$_REQUEST["class"];
		             
		                $_POST["term"]='term1';
						$_SESSION["admin"]["school_id"]=$_REQUEST["school_id"];
						$_SESSION["admin"]["session"]=$_REQUEST["session"];
		                 $_GET["id"]=$aryForm["idno"];


?>

  <?php
   // if($_POST){
$mss=0; $smsAry="";$where="";$stsearch="";

if(isset($_POST["section"]) && $_POST["section"]!="")
			$where=" AND section='".$_POST["section"]."' ";
if(isset($_POST["idno"]) && $_POST["idno"]!="")
	$stsearch=" and idno='".$_POST["idno"]."' ";
	
 //if(isset($_POST['fee'])){
	
		$allStudent=$db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$_POST["class"]."' $where $stsearch and status=1 and issue_TC=0 order by name");
		
		//echo $ss="select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$_POST["class"]."' $where $stsearch and status=1 and issue_TC=0 order by name";
	//echo $db->getLastQuery();
	$examtype=$db->getRows("select name,id,total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' order by lorder");
	if(is_array($allStudent) && count($allStudent)>=0){ $he=0;
		
		foreach($allStudent as $aryForm){$mss++;$he++;
			
	  if($_POST["term"]=="term1" || $_POST["term"]=="term2"){ ?>
	  <!--one page <div style="height:942px">end --> 
	  <!--two page-->
	  <div style="height:1030px;margin-bottom:20px;">
	  <div style="height:1020px;border:8px solid #D5DA13;">
		<?php
		$_GET['id']=$aryForm["idno"];
		error_reporting(55);
		$_REQUEST["class"]=$db->getVal("select class from student where school_id='".$_SESSION["admin"]["school_id"]."' and idno=".$aryForm["idno"]);
		$exam=$db->getVal("select idno from student where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' limit 0,1");
		
		$termWhere="";if($_POST["term"]!="final") $termWhere=" and term='".$_POST["term"]."' ";
		$examtype=$db->getRows("select name,id,total from examterm  where school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by lorder");
		//echo $db->getLastQuery();print_r($examtype);
		if(count($exam)>0){
		?>
		<?php $aryForm=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm['idno']."'");$overallTotalGrade=0; ?>
		<form method="post" action="">
		  <input type="hidden" name="class" value="<?php echo $_REQUEST["class"] ?>" />
		  <input type="hidden" name="idno" value="<?php echo $aryForm["idno"] ?>" />
		  <div class="row-fluid">
			<div class="span12">
			  <div class="well" >
			  <div  style="border: none;">
			 
			  
			 <div style="margin-left:80px"> <img src="<?php echo $LinksDetails["logo"] ?>" height="90px" width="110px" style="margin:0px 0px 3px 10px;"></div>
			 <div style="float:left;text-align:center;margin-bottom:18px;"> <h1 style="font-size:30px;margin:-60px 0px 0px 400px;color: #EC1E1E;"><?php echo ucfirst($LinksDetails["site_name"]) ?></h1>
			   <span style="font-size:16px;font-weight:800;  color: #186916; margin-left:400px;"> <?php echo ucfirst(nl2br($LinksDetails["contact_content"])) ?></span>
			 </div> 
		  </div>
				
				<div style="font-size: 16px;clear: both;background-color: #D5DA13;font-weight: bold;padding: 5px;color: #000;text-align: center;  border-top: 1px solid #000;border-bottom: 1px solid #000;"> ACADEMIC PERFORMANCE (<?php echo ucwords($_POST['term']); ?> : <?php echo $_SESSION["admin"]["session"];?>)</div>
				<table style="width:100%;font-size:13px;font-weight: bold;color:#1224A5;" cellpadding="5" cellspacing="2">
				  <tr>
					<td width="20%">Name</td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["name"] ?></td>
					<td width="20%">Class</td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["class"] ?>-<?php echo $aryForm["section"] ?></td>
					<td width="20%"><strong class="st">Admission No.</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["admissionno"] ?></td>
				   
				  </tr>
				  <tr>
					<td width="20%"><strong class="st">Father's Name</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["fname"] ?></td>
				
                    <td width="21%"><strong class="st">Mother's Name</strong></td><td width="2%">:</td>
					<td width="30%"><?php echo $aryForm["mname"] ?></td>
					<td width="21%"><strong class="st">Contact</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["mobile"] ?></td>
					
				  </tr>
				  
				 
				</table>
				<table style="width:100%; font-size:14px;border-top:1px solid #000;border-bottom:1px solid #000;text-align: center;color: #1224A5;
	font-weight: 800;" cellpadding="3" cellspacing="0">
						
						<tr style="background-color: #D5DA13;font-weight: 800;padding: 5px;color: #000;">
							<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="22%">SUBJECTS</td>
							<?php 
							
							if(is_array($examtype) && count($examtype)>0){
								 $finalObtain=0;$finalTotal=0;
								foreach($examtype as $eytpe){ //echo "<pre>";print_r($eytpe);echo "</pre>";?>
								<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="10%">
								<input type="hidden" name="type[]" style="width:80px" class="total" value="<?php echo $eytpe['name'] ?>" placeholder="Exam type" /><?php 
								
								if($eytpe['name']=='PT1' OR $eytpe['name']=='PT2') 
									
								 //echo "PERIODIC TEST(".$eytpe[2].")"
                                 echo "PERIODIC TEST(10)";
								else if($eytpe['name']=='NOTE1' OR $eytpe['name']=='NOTE2') 
								//echo "NOTE <br> BOOK(".$eytpe[2].")"	
								echo "NOTE <br> BOOK(5)" ;
								
								else if($eytpe['name']=='SUBEN1' OR $eytpe['name']=='SUBEN2') 
									//echo "SUB ENRIC HMENT(".$eytpe[2].")";
								echo "SUB ENRIC HMENT(5)";
								
								else if($eytpe['name']=='HALFYEARLY') 
									//echo "HALF YEARLY(".$eytpe[2].")";
									echo "HALF YEARLY(80)"; 
								
								else if($eytpe['name']=='FINAL') 
									
								//echo "FINAL(".$eytpe[2].")";
								echo "FINAL(80)";
												
								
								 ?>
	                       </td>
							<?php }
							
							}?>
							<?php 
							$total_number=$db->getRow("select sum(total) from examterm  where school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by lorder");
							if($_POST["term"]=="term1"){ 

							?>
							<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="10%">TOTAL (100 <?php //echo $total_number[0]; ?>)</td>
							<?php }elseif($_POST["term"]=="term2"){ ?>
							<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="10%">TOTAL (100<?php //echo $total_number[0]; ?>)</td>
							<?php } ?>
							<td style="border-bottom: 1px solid #000;" width="10%">Grade</td>
						</tr>
						
						<?php $x=0;
						$detail=$db->getRows("select * from subject where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' order by id");
						foreach($detail as $d){ $fsAry=array();$final="";
						?><tr>
								<td style="border-right:2px solid #FA0606"><?php echo ucfirst($d["subject"]) ?><input type="hidden" name="subject[]" value="<?php echo $d["subject"] ?>" /></td>
								<?php 
								for($i=1; $i<=count($examtype);$i++){ 
								$examResultData=$db->getRow("select * from exammarks where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1]['name']."' and subject='".$d["subject"]."'");
								?>
								<td style="border-right:2px solid #FA0606">
								<input readonly="readonly" type="hidden" style="width:40px" name="<?php echo $d["subject"]."_".$examtype[$i-1]['name'];?>[]" class="<?php echo $examtype[$i-1]['name'];?>_total_marks total" value="<?php
								echo $total=$db->getVal("select total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$examtype[$i-1]['id']."'"); ?>" placeholder="Total Maks" />
								 <input required type="hidden" style="width:70px" name="<?php echo $examtype[$i-1]['name'];?>_student[]" class="onlyZero obtain <?php echo $examtype[$i-1]['name'];?>_obtain_marks" value="<?php echo (int)$examResultData["obtain"]; ?>" placeholder="Obtain Maks" />
								 <?php
								 $fs=$examtype[$i-1]['name'];
							//print($fs);
								 $fsAry[$fs."_Obtain"]=$examResultData["obtain"];
								 $fsAry[$fs."_Total"]=$total;
								 
								 //$t=$db->getVal("select total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$examtype[$i-1][1]."'");
								
								 if($i==1) echo number_format($examResultData["obtain"]*10/$total,1)+0;
								 if($i==2) echo number_format($examResultData["obtain"]*5/$total,1)+0;
								 if($i==3) echo number_format($examResultData["obtain"]*5/$total,1)+0;
								 if($i==4) echo number_format($examResultData["obtain"]*80/$total,1)+0;
								 
							 //else echo 1;
								 //echo 1;
								  //echo FindGrade($examResultData["obtain"],$total);//."/".$examResultData["obtain"]."-".$total; ?>
								 </td>
								<?php }$x++;

								?>
								<?php if($_POST["term"]=="term1"){ ?>
								<td style="border-right:2px solid #FA0606"><?php $fa1Obtain=$fa2Obtain=0;
								
								    $PT1Obtain=number_format($fsAry["PT1_Obtain"]*10/$fsAry["PT1_Total"],1)+0;
								    $NOTE1_obtain=number_format($fsAry["NOTE1_Obtain"]*5/$fsAry["NOTE1_Total"],1)+0;
									$SUBEN1=number_format($fsAry["SUBEN1_Obtain"]*5/$fsAry["SUBEN1_Total"],1)+0;
									$HALFYEARLY=number_format($fsAry["HALFYEARLY_Obtain"]*80/$fsAry["HALFYEARLY_Total"],1)+0;
									
									/*$fa1Obtain=($fsAry["FA1_Obtain"]*100)/$fsAry["FA1_Total"];		
									//$fa2Obtain=($fsAry["FA2_Obtain"]*100)/$fsAry["FA2_Total"];
									$saObtain=($fsAry["SA1_Obtain"]*100)/$fsAry["SA1_Total"];
									$fa1Obtain=(10*$fa1Obtain)/100;
									$fa2Obtain=(10*$fa2Obtain)/100;
									$saObtain=(30*$saObtain)/100;
									
									$faObtain=$fa1Obtain + $fa2Obtain;
									$AllObtain = $saObtain + $faObtain;*/
									$AllTotal =100;
									//$AllObtain=$fsAry["PT1_Obtain"]+$fsAry["NOTE1_Obtain"]+$fsAry["SUBEN1_Obtain"]+$fsAry["HALFYEARLY_Obtain"];
									
									$AllObtain=$PT1Obtain+$NOTE1_obtain+$SUBEN1+$HALFYEARLY;
									
									
										echo $AllObtain;
									$final=FindGrade($AllObtain,$AllTotal);//."/".$AllObtain."-".$AllTotal;
									//echo $final;
									$finalObtain+=$AllObtain;
									$finalTotal+=$AllTotal;
								?></td>
								<?php }elseif($_POST["term"]=="term2"){ ?>
								<td style="border-right:2px solid #FA0606"><?php 
								
								
								        $PT2Obtain=number_format($fsAry["PT2_Obtain"]*10/$fsAry["PT2_Total"],1)+0;
										$NOTE2obtain=number_format($fsAry["NOTE2_Obtain"]*5/$fsAry["NOTE2_Total"],1)+0;
										$SUBEN2=number_format($fsAry["SUBEN2_Obtain"]*5/$fsAry["SUBEN2_Total"],1)+0;
									    $final=number_format($fsAry["FINAL_Obtain"]*80/$fsAry["FINAL_Total"],1)+0;
									/*	
									$fa1Obtain=($fsAry["FA3_Obtain"]*100)/$fsAry["FA3_Total"];
									$fa2Obtain=($fsAry["FA4_Obtain"]*100)/$fsAry["FA4_Total"];
									$saObtain=($fsAry["SA2_Obtain"]*100)/$fsAry["SA2_Total"];
									$fa1Obtain=(10*$fa1Obtain)/100;
									$fa2Obtain=(10*$fa2Obtain)/100;
									$saObtain=(30*$saObtain)/100;
									
									$faObtain=$fa1Obtain + $fa2Obtain;
									$AllTotal =50;
									//$faObtain=$fsAry["FA3_Obtain"]+$fsAry["FA4_Obtain"];
									//$faTotal=$fsAry["FA3_Total"]+$fsAry["FA4_Total"];
									//$saObtain=$fsAry["SA2_Obtain"];
									//$saTotal=$fsAry["SA2_Total"];
									$AllObtain = $saObtain + $faObtain;
									//$AllTotal = $saTotal + $faTotal;*/
									$AllTotal =100;
									//$AllObtain=$fsAry["PT2_Obtain"]+$fsAry["NOTE2_Obtain"]+$fsAry["SUBEN2_Obtain"]+$fsAry["FINAL_Obtain"];
									
									$AllObtain=$PT2Obtain+$NOTE2obtain+$SUBEN2+$final;
										echo $AllObtain;
									 $final=FindGrade($AllObtain,$AllTotal);//."/".$AllObtain."-".$AllTotal;
									$finalObtain+=$AllObtain;
									
									$finalTotal+=$AllTotal;
								?></td>
								<?php } ?>
								<td><?php 
								
								//$tgrade=$db->getVal("select point from examgrade where grade='".$final."'"); echo (float)$tgrade; $overallTotalGrade+=$tgrade;
								
								//$grade= $db->getVal("SELECT grade FROM examgrade WHERE '$AllObtain' BETWEEN minrange AND maxrange");
								
								echo $final;
								
								?></td>
							</tr>
						<?php
						 $stid=$_GET["id"];$subj1=$d["subject"];
						$smsAry.="$stid~$subj1~".$final."<br/>";
						} 
						?>
                        <?php $x=0;
						$detail1=$db->getRows("select * from subject_extra where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' order by id");
						foreach($detail1 as $d){$x++;
						?>
						<!--<tr>
								<td style="font-size:12px;border-right:2px solid #FA0606;<?php if($x==1) echo 'border-top:2px solid #FA0606;';?>"><?php echo ucfirst($d["subject"]) ?><input type="hidden" name="subject[]" value="<?php echo $d["subject"] ?>" /></td>
								<?php 
								for($i=1; $i<=count($examtype);$i++){$examResultData="";
								$examResultData=$db->getVal("select grade from exammarks_extra where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1]['name']."' and subject='".$d["subject"]."'");
								?>
								<td style="font-size:12px;border-right:2px solid #FA0606;<?php if($x==1) echo 'border-top:2px solid #FA0606;';?>">
						<?php	if($examResultData=="") echo "-";
						
						
						$alltotal=$db->getVal("select total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$examtype[$i-1]['id']."'");

                     echo FindGrade($examResultData,$alltotal);
					 
						
								//else echo $examResultData;//."/".$examResultData["obtain"]."-".$total; ?>
								 </td>
								 <?php }?>
                              <td style="border-right:2px solid #FA0606;<?php if($x==1) echo 'border-top:2px solid #FA0606;';?>"> <?php echo "-";?> </td> 
                              <td style=" <?php if($x==1) echo 'border-top:2px solid #FA0606;';?>"> <?php echo "-";?> </td> 				
							</tr>-->
						<?php
						 $stid=$_GET["id"];$subj1=$d["subject"];
						$smsAry.="$stid~$subj1~".$final."<br/>";
						} 
						?>
						</table>
				<div style="width:100%;height:52px;border-bottom: 2px solid #F71111;text-align:center;font-weight:800;color: #1224A5;">        
				 <div style="float:left;width:49%;">
					 <div style="width:100%;background:#D5DA13;padding:5px;border-bottom:1px solid #000;color:#000;">REMARKS BY CLASS TEACHER</div>
					 <span></span>
				 </div>
				 <div style="font-size:16px;float:left;width:50%;border-left:2px solid #F71111;text-align:left;">
					<div style="width:100%;background:#D5DA13;border-bottom:1px solid #000;padding:5px;color:#000;">PERCENTAGE </div> 
					<span style="padding:5px;font-size:17px">
					<?php $c=$overallTotalGrade/count($detail); 
					//echo $cgpa=number_format((float)$c, 2, '.', ''); 
				
					echo number_format(($finalObtain*100/ $finalTotal),2)."%";
					//echo $finalTotal;
					?></span>
				    <?php $attr=$db->getRow("select * from allattandence where idno='".$aryForm["idno"]."' and session='".$_SESSION["admin"]["session"]."'"); 
				 
				?>
					<div style="margin-top:4px;">
                   <?php if($attr!=NULL){?>
						 <div style="background:#D5DA13;color:#000;width:100%;float:left;padding:4px;border-top:1px solid #000;border-bottom:1px solid #000;">ATTENDANCE</div>
						<span style="padding:5px;">Total Attendance of the student : <?php if($_POST["term"]=="term1")echo $attr['term1_att'];elseif($_POST["term"]=="term2") $attr['term2_att'];?></span><br/>
						<span style="padding:5px">Total working days : <?php if($_POST["term"]=="term1")echo $LinksDetails['term1_all_day'];elseif($_POST["term"]=="term2") $LinksDetails['term2_all_day']?></span>
                    <?php } ?>    
					</div>
                   
					</div>
				</div>
				
				<?php
				$smsAry.="$stid~-------~<br/>";
				$smsAry.="$stid~FINAL CGPA~".$cgpa."<br/>";
			//	echo $db->getErMsg();
					$type=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' group by type order by id");
					if(is_array($type) && count($type)>0){
						?>
			  	<?php
							//echo $db->getErMsg();
						}
						?>
						
					
			
			<?php 
			$type=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' group by type order by id");
			
			$ijk=0;
						foreach($type as $t){$ijk++;
							//if($ijk%4==0)echo '</div>';
			
			?>
			
			 <!--   <table border="1" style="width:30% !important;margin-top:-195px;margin-left:400px;font-size:11px;font-weight:800;text-align:center;display:inline-table" cellpadding="8" cellspacing="0">  -->
			 
		<table align="center" border="1" cellpadding="3" cellspacing="0" style=" width:90%;height:52px;  margin-top:20px;margin-left:25px;text-align:center; color:#1224A5; font-size: 13px;font-weight: 800;">
                   <thead>
                    	<?php
                                     $lifeskill=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' and type='".$t["type"]."'");
                                    // echo $db->getErMsg(); $i=1;
                                     //echo"<pre>";print_r($all_product);echo"</pre>";
                                      if(is_array($lifeskill) && count($lifeskill))
                                      {
										   ?>
                      <tr style="background:#D5DA13;">
                        <th><?php echo $t["type"]; if($t["type"]=="2-A") echo ": LIFE SKILS";elseif($t["type"]=="2-B") echo ":    WORK EDUCATION";elseif($t["type"]=="2-C") echo ": VISUAL & PERFORMING ARTS";elseif($t["type"]=="2-D") echo ": ATTITUDES & VALUES";elseif($t["type"]=="3-A") echo ": ACTIVITIES"; ?></th>
                        <!--<th>Descriptive_	Indicators</th>-->
                        <th>Grade</th>
                      </tr>
                      </thead>
                    <tbody >
                      <?php
                                        foreach($lifeskill as $iSkill)
                                        {
											$grade=$db->getVal("select grade from examcriteriarecord where idno='".$_GET['id']."' and term='".$_POST["term"]."' and criteria='".$t["type"]."' and subcriteria='".$iSkill["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'");
											//echo $db->getLastQuery();
                                     ?>
                      <tr>
                        <td style="color:blue;" ><?php echo $iSkill["name"]; ?></td>
                    
                        <td style="color:blue;" ><?php echo $grade; ?></td>
                      </tr>
                      <?php $i++;
                                        } 
                                    }
                                     ?>
                    </tbody>
                  </table>
				  
				  
						<?php } ?> 
						
							<div style="width:34%;float:left;margin-top:8px;">
			<table border="1" cellpadding="3" cellspacing="0" style="text-align:center; margin-left:25px;color:#1224A5;font-size: 13px;font-weight: 800;">
				<tr>
					<td colspan="3">GRADING SYSTEM - SCHOLASTIC</td>
				</tr>
				<tr>
					<td>MARK RANGE</td><td>GRADE</td><td>GRADE POINT</td>
				</tr>
				<tr>
					<td>91 - 100</td><td>A1</td><td>10.0</td>
				</tr>
				<tr>
					<td>81 - 90</td><td>A2</td><td>9.0</td>
				</tr>
				<tr>
					<td>71 - 80</td><td>B1</td><td>8.0</td>
				</tr>
				
				<tr>
					<td>61 - 70</td><td>B2</td><td>7.0</td>
				</tr>
				<tr>
					<td>51 - 60</td><td>C1</td><td>6.0</td>
				</tr>
				
				<tr>
					<td>41 - 50</td><td>C2</td><td>5.0</td>
				</tr>
				<tr>
					<td>33 - 40</td><td>D</td><td>4.0</td>
				</tr>
				
				<tr>
					<td>32 & Below</td><td>E</td><td>3.0</td>
				</tr>
				
			</table><br>
			</div>
			<div style="width:34%;float:right;margin-top:8px;">
			<table border="1" cellpadding="3" cellspacing="0" style="text-align:center; margin-left:25px;color:#1224A5;font-size: 13px;font-weight: 800;">
			<!--<table align="left" border="1" cellpadding="6" cellspacing="0" style="text-align:center;width:29%;color:#1224A5;font-size:10px;font-weight:800;line-height:29px;float:left">-->
                                    <tr>
                                        <td colspan="3">CO - SCHOLASTIC</td>
                                    </tr>
                                    <tr>
                                        <td>GRADE</td><td>GRADE POINTS</td>
                                    </tr>
                                    <tr>
                                        <td>A</td><td>Outstanding</td>
                                    </tr>
                                    <tr>
                                        <td>B</td><td>Very Good</td>
                                    </tr>
                                    <tr>
                                        <td>C</td><td>Fair</td>
                                    </tr>                                    
                    </table>
			
			
			</div>
						
						 <div>
							   <table style="width:100%; text-align:center;font-size:14px;border-bottom: 2px solid #F71111;height: 90px;font-weight: 800;color: #1224A5;" cellpadding="0" cellspacing="2" >
								<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
								</tr>
								<tr style="vertical-align: bottom;">
								  <td width="25%">Date</td>
								  <td>Class teacher</td>
								  <td>Principal</td>
								  <td>Parents/Guardian</td>
								</tr>
							  </table>
						</div>
						 <div style="margin-left: 5px;">
			<!--<div style="width:65%;float:left;  margin-top: 10px;color:#1224A5;font-size: 13px;font-weight: 800;">
				Subject wise Indicative percentage of marks = 9.5 x GP of the subject <br/><br/>
			   First Term - FA1(10%)+FA2(10%)+SA1(30%) = 50%  <br/><br/>
				Second Term - FA3(10%)+FA4(10%)+SA2(30%) = 50% <br/><br />
				FORMATIVE ASSESSMENT(FA) 1 + 2 + 3 + 4 = 40%   <br/><br />
				SUMMATIVE ASSESSMENT(SA) 1 + 2 = 60%           <br/><br />
				CGPA is calculated excluding 3rd language.
			</div>-->
			
		</div>
			  </div>
			</div>
		  </div>
		</form>
		<?php
		}
			?>
	   
	  </div>
	  </div>
	<?php }
	  // my code start
	  
	  
	  	   elseif($_POST["term"]=="final")
	   { 
	   ?>
		  
		  <div style="height:767px;margin-bottom:20px; <?php if($he!=1){?> padding-top: 10px;<?php } ?>">
	  <div style="height:707px;border:8px solid #D5DA13;font-size:14px;"><!--end --> 
		<!--three page <div style="height:2826px">end -->
		<?php
		$_GET['id']=$aryForm["idno"];
		error_reporting(55);
		$_REQUEST["class"]=$db->getVal("select class from student where school_id='".$_SESSION["admin"]["school_id"]."' and idno=".$aryForm["idno"]);
		$exam=$db->getVal("select idno from student where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' limit 0,1");
		
		$termWhere="";if($_POST["term"]!="final") $termWhere=" and term='".$_POST["term"]."' ";
		$examtype=$db->getRows("select name,id,total from examterm  where school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by lorder");
		//echo $db->getLastQuery();print_r($examtype);
		if(count($exam)>0){
		?>
		<?php $aryForm=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm['idno']."'");$overallTotalGrade=0; ?>
		<form method="post" action="">
		  <input type="hidden" name="class" value="<?php echo $_REQUEST["class"] ?>" />
		  <input type="hidden" name="idno" value="<?php echo $aryForm["idno"] ?>" />
		  <div class="row-fluid">
			<div class="span12">
			  <div class="well" >
			  <div class="headPrint hide" style="border: none;">
			 
			  
			 <div style="margin-left:280px"> <img src="<?php echo $LinksDetails["logo"] ?>" height="80px" width="100px" style="margin:12px 0px 0px 10px;"></div>
			 <div style="float:left;text-align:center;margin-bottom:17px;"> <h1 style="font-size:38px;margin:5px 0px 0px 0px;color: #EC1E1E;"><?php echo ucfirst($LinksDetails["site_name"]) ?></h1>
			   <span style="font-size:17px;font-weight:800;  color: #186916;"> <?php //echo ucfirst(nl2br($LinksDetails["contact_content"])) ?>
			   
			   
			    Senior Secondary School<br>
CBSE Affiliation No. 1030483
			   
			   
			   </span>
			 </div> 
		  </div>
				
				<div style="font-size: 16px;clear: both;background-color: #D5DA13;font-weight: bold;padding: 5px;color: #000;text-align: center;  border-top: 1px solid #000;border-bottom: 1px solid #000;"> PERFORMANCE PROFILE [C. C. E.] FINAL (SESSION : <?php echo $_SESSION["admin"]["session"];?>)</div>
				<?php $attr=$db->getRow("select * from allattandence where idno='".$aryForm["idno"]."' and session='".$_SESSION["admin"]["session"]."'"); 
				  if($attr!=NULL){
				?>
                <table style="width:50%;font-size:13px;font-weight: bold;color:#1224A5;float:left" cellpadding="5" cellspacing="2">
				  <tr>
					<td width="20%">Name</td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["name"] ?></td>
					<td width="20%"><strong class="st">Admission No.</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["admissionno"] ?></td>
				  </tr>
				  <tr>
					<td width="20%">Class</td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["class"] ?></td>
					<td width="20%">Section</td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["section"] ?></td>
				   </tr>
				 <tr>
					<td width="20%"><strong class="st">Father's Name</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["fname"] ?></td>
					<td width="20%"><strong class="st">D.O.B</strong></td><td width="2%">:</td>
					<td width="21%"><?php if($aryForm["dob"]!="")echo date("d-M-Y",strtotime($aryForm["dob"])); ?></td>
					
				 </tr>
				 <tr>
					<td width="21%"><strong class="st">Mother's Name</strong></td><td width="2%">:</td>
					<td width="38%"><?php echo $aryForm["mname"] ?></td>
					<td width="21%"><strong class="st">Contact</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["mobile"] ?></td>
				 </tr>
				</table>
               	<table border="1" <?php if($aryForm['photo']==""){ echo "width='40%'"; }?> style="float:left;margin:29px 40px 5px 40px;font-weight: bold;color:#1224A5;text-align:center;" cellpadding="3" cellspacing="0">
					<tr>
						<td>Attendance</td><td>Overall</td>
					</tr>
					<tr>
						<td>Total Present Days</td><td><?php echo $attr['term1_att']+$attr['term2_att']?></td>
					</tr>
					<tr>
						<td>Total Working Days</td><td><?php echo $LinksDetails['overallday']?></td>
					</tr>
				</table>
				<?php if($aryForm['photo']!=""){ ?> 
					<div style="float:right;margin:5px 30px 0px 0px;  border: 4px solid #6B6868;">
					<img src="media/photo/<?php echo $aryForm["photo"]; ?>" style="height:96px;width:90px" />
				   
					 </div>     
				 <?php } } else{ 
				 ?> <table style="width:100%;font-size:13px;font-weight: bold;color:#1224A5;float:left" cellpadding="5" cellspacing="2">
				  <tr>
					<td width="8%">Name</td><td width="2%">:</td>
					<td width="15%"><?php echo $aryForm["name"] ?></td>
                    <td width="10%"><strong class="st">Father's Name</strong></td><td width="2%">:</td>
					<td width="11%"><?php echo $aryForm["fname"] ?></td>
                    <td width="15%"><strong class="st">Mother's Name</strong></td><td width="2%">:</td>
					<td width="11%"><?php echo $aryForm["mname"] ?></td>
					<td width="10%"><strong class="st">Admission No.</strong></td><td width="2%">:</td>
					<td width="11%"><?php echo $aryForm["admissionno"] ?></td>
                 </tr>
				 <tr>
					<td width="8%"><strong class="st">D.O.B</strong></td><td width="2%">:</td>
					<td width="15%"><?php if($aryForm["dob"]!="")echo date("d-M-Y",strtotime($aryForm["dob"])); ?></td>
					<td width="10%"><strong class="st">Contact</strong></td><td width="2%">:</td>
					<td width="15%"><?php echo $aryForm["mobile"] ?></td>
                    <td width="8%">Class</td><td width="2%">:</td>
					<td width="10%"><?php echo $aryForm["class"] ?></td>
					<td width="10%">Section</td><td width="2%">:</td>
					<td width="8%"><?php echo $aryForm["section"] ?></td>
				 </tr>
				</table>
                 <?php } ?> 
				 <div style="font-size: 16px;clear: both;background-color: #D5DA13;font-weight: bold;padding: 5px;color: #000;text-align: center;  border-top: 1px solid #000;border-bottom: 1px solid #FA0606;"> ACADEMIC PERFORMANCE - SCHOLASTIC AREAS</div>  
				<table style="width:100%; font-size:13px;margin:0;border-top:1px solid #FA0606 ;border-bottom:1px solid #000;text-align: center;color: #1224A5;font-weight: 800;" cellpadding="5" cellspacing="0">
						
						<tr  style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
							<td rowspan="2" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606;padding:5px;" width="16%">SUBJECTS</td>
							<td colspan="6" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">TERM-I</td>
							<td colspan="6" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">TERM-II</td>
							<!--<td colspan="4" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">(OVERALL GRADE)</td>-->
						</tr>
						<tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
							
							<?php 
							
							if(is_array($examtype) && count($examtype)>0){
								 $finalObtain=0;$finalTotal=0;$f=0;
								foreach($examtype as $eytpe){ $f++; //echo "<pre>";print_r($eytpe);echo "</pre>";
								?>
								<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="7%">
								<input type="hidden" name="type[]" style="width:80px" class="total" value="<?php echo $eytpe['name'] ?>" placeholder="Exam type" /><?php

                                if($eytpe[0]=='PT1' OR $eytpe[0]=='PT2') 
									
								//echo "PERIODIC TEST <br> (". $eytpe[2].")";
								echo "PERIODIC TEST <br> (10)";
								else if($eytpe[0]=='NOTE1' OR $eytpe[0]=='NOTE2')

									//echo "NOTE BOOK (". $eytpe[2].")";
									
									echo "NOTE BOOK (5)";
									
									
								else if($eytpe[0]=='SUBEN1' OR $eytpe[0]=='SUBEN2') 
									//echo "SUB ENRIC HMENT (". $eytpe[2].")";
									echo "SUB ENRIC HMENT (5)";
									
								else if($eytpe[0]=='HALFYEARLY') 
									//echo "HALF YEARLY (". $eytpe[2].")";
								echo "HALF YEARLY(80)";
								
								else if($eytpe[0]=='FINAL') 
									//echo "FINAL (". $eytpe[2].")";
								echo "FINAL(80)";
								


								 ?>
	</td>
						<?php 	if($f==4  ){
$total_number=$db->getRow("select sum(total) from examterm  where school_id='".$_SESSION["admin"]["school_id"]."' and term= 'term1' order by lorder");	?>					
						<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="7%">TOTAL (100<?php //echo $total_number[0]; ?>) </td>
						<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" width="7%">Grade</td> 
						
								<?php }  
								if($f==8  ){ 
								$total_number=$db->getRow("select sum(total) from examterm  where school_id='".$_SESSION["admin"]["school_id"]."' and term= 'term2' order by lorder");
								?>
										
								<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="7%">TOTAL (100<?php //echo $total_number[0]; ?>) </td>
								 <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" width="7%">Grade</td> 
								<?php }  ?>
							<?php }
							} ?>
						</tr>
						
						<?php $x=0;
						$detail=$db->getRows("select * from subject where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' order by id");
						foreach($detail as $d){ $fsAry=array();$final="";
						?>
						
						<tr>
								<td style="border-right:2px solid #FA0606"><?php echo ucfirst($d["subject"]) ?><input type="hidden" name="subject[]" value="<?php echo $d["subject"] ?>" /></td>
								<?php 
								
								for($i=1; $i<=count($examtype);$i++){ 
								$examResultData=$db->getRow("select * from exammarks where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1][0]."' and subject='".$d["subject"]."'"); 
								//$q="select * from exammarks where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1][0]."' and subject='".$d["subject"]."'";
								//echo $q;
								//print_r($examResultData);
								?>
								<td style="border-right:2px solid #FA0606">
								<!--<input readonly="readonly" type="hidden" style="width:40px" name="<?php echo $d["subject"]."_".$examtype[$i-1][0];?>[]" class="<?php echo $examtype[$i-1][0];?>_total_marks total" value="<?php
								 $total=$db->getVal("select total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$examtype[$i-1]['id']."'"); ?>" placeholder="Total Maks" />
								 <input required type="text" style="width:70px" name="<?php echo $examtype[$i-1][0];?>_student[]" class="onlyZero obtain <?php echo $examtype[$i-1][0];?>_obtain_marks" value="<?php echo (int)$examResultData["obtain"]; ?>" placeholder="Obtain Maks" /> -->
								 <?php
								 $fs=$examtype[$i-1][0];
								
								 $fsAry[$fs."_Obtain"]=$examResultData["obtain"];
								 $fsAry[$fs."_Total"]=$total;
								 /* echo FindGrade($examResultData["obtain"],$total);//."/".$examResultData["obtain"]."-".$total; */
								  
								  
								   //echo $examResultData[obtain]; 
						if($i==1) echo number_format($examResultData["obtain"]*10/$total,1)+0;
						 if($i==2) echo number_format($examResultData["obtain"]*5/$total,1)+0;
						 if($i==3) echo number_format($examResultData["obtain"]*5/$total,1)+0;
						 if($i==4) echo number_format($examResultData["obtain"]*80/$total,1)+0;
						 
						 if($i==5) echo number_format($examResultData["obtain"]*10/$total,1)+0;
						 if($i==6) echo number_format($examResultData["obtain"]*5/$total,1)+0;
						 if($i==7) echo number_format($examResultData["obtain"]*5/$total,1)+0;
						 if($i==8) echo number_format($examResultData["obtain"]*80/$total,1)+0;
								
								
								
								
								?>
								 </td>
								<?php  if($i==4){?>
										 <td style="border-right:2px solid #FA0606"><?php 
								/*
								$fa1Obtain=number_format($fsAry["PT1_Obtain"]*10/30,1)+0;
							    $note1Obtain=number_format($fsAry["NOTE1_Obtain"]*5/5)+0;
							    $sa1Obtain=number_format($fsAry["SUBEN1_Obtain"]*5/5)+0;
							    $half=number_format($fsAry["HALFYEARLY_Obtain"]*80/80)+0;*/
												
																						
			  $PT1Obtain=number_format($fsAry["PT1_Obtain"]*10/$fsAry["PT1_Total"],1)+0;
			$NOTE1_obtain=number_format($fsAry["NOTE1_Obtain"]*5/$fsAry["NOTE1_Total"],1)+0;
			$SUBEN1=number_format($fsAry["SUBEN1_Obtain"]*5/$fsAry["SUBEN1_Total"],1)+0;
			$HALFYEARLY=number_format($fsAry["HALFYEARLY_Obtain"]*80/$fsAry["HALFYEARLY_Total"],1)+0;																						
											
												$AllTotal =100;
												
									//echo $AllObtain=$fsAry["PT1_Obtain"]+$fsAry["NOTE1_Obtain"]+$fsAry["SUBEN1_Obtain"]+$fsAry["HALFYEARLY_Obtain"];
									
									//echo $AllObtain=$fa1Obtain+$note1Obtain+$sa1Obtain+$half;
									
									echo $AllObtain=$PT1Obtain+$NOTE1_obtain+$SUBEN1+$HALFYEARLY;
									
										//echo $AllObtain;
										$final=FindGrade($AllObtain,$AllTotal);
											$finalObtain1+=$AllObtain;
											$finalTotal1+=$AllTotal;
											
										?></td>
										<td style="border-right:2px solid #FA0606"><?php echo $final; ?></td>
								<?php  } ?>
								
								
								
								<?php  if($i==8){?>
										 <td style="border-right:2px solid #FA0606"><?php 
								/*			
								$PT2_Obtain=number_format($fsAry["PT2_Obtain"]*10/30,1)+0;
								$NOTE2_Obtain=number_format($fsAry["NOTE2_Obtain"]*5/5)+0;
								$SUBEN2_Obtain=number_format($fsAry["SUBEN2_Obtain"]*5/5)+0;
								$FINAL_Obtain=number_format($fsAry["FINAL_Obtain"]*80/80)+0;*/
								
								
			$PT2Obtain=number_format($fsAry["PT2_Obtain"]*10/$fsAry["PT2_Total"],1)+0;
			$NOTE2obtain=number_format($fsAry["NOTE2_Obtain"]*5/$fsAry["NOTE2_Total"],1)+0;
			$SUBEN2=number_format($fsAry["SUBEN2_Obtain"]*5/$fsAry["SUBEN2_Total"],1)+0;
			$final=number_format($fsAry["FINAL_Obtain"]*80/$fsAry["FINAL_Total"],1)+0;
			
			
																		
											
											
												$AllTotal =100;
							//echo $AllObtain=$PT2_Obtain+$NOTE2_Obtain+$SUBEN2_Obtain+$FINAL_Obtain;
							
							echo $AllObtain=$PT2Obtain+$NOTE2obtain+$SUBEN2+$final;
							
									$final=FindGrade($AllObtain,$AllTotal);
										//echo $AllObtain;
											$finalObtain2+=$AllObtain;
											
											$finalTotal2+=$AllTotal;
										?></td>
										<td style="border-right:2px solid #FA0606"><?php echo $final; ?></td>
								<?php  } ?>
								
								
								
								<?php }$x++; ?>
								<?php if($_POST["term"]=="final"){?> 
									<!-- overall term1 FA+SA1 -->
							   
									  <!-- overall term2 FA+SA -->
								<!--<td style="border-right:2px solid #FA0606"><?php 
									$fa3Obtain=($fsAry["FA3_Obtain"]*100)/$fsAry["FA3_Total"];
									$fa4Obtain=($fsAry["FA4_Obtain"]*100)/$fsAry["FA4_Total"];
									$sa2Obtain=($fsAry["SA2_Obtain"]*100)/$fsAry["SA2_Total"];
									$fa3Obtain=(10*$fa3Obtain)/100;
									$fa4Obtain=(10*$fa4Obtain)/100;
									$sa2Obtain=(30*$sa2Obtain)/100;
									
									$faObtain=$fa3Obtain + $fa4Obtain;
									$AllTotal =50;
									$AllObtain = $sa2Obtain + $faObtain;
									//$AllTotal = $saTotal + $faTotal;
									echo $final=FindGrade($AllObtain,$AllTotal);//."/".$AllObtain."-".$AllTotal;
									$finalObtain+=$AllObtain;
									
									$finalTotal+=$AllTotal;
								?></td>
								 <!-- overall final term FA+SA+Overall Grade -->
								<!--<td style="border-right:2px solid #FA0606"><?php 
											$fa1Obtain=($fsAry["FA1_Obtain"]*100)/$fsAry["FA1_Total"];
											$fa2Obtain=($fsAry["FA2_Obtain"]*100)/$fsAry["FA2_Total"];
											$fa3Obtain=($fsAry["FA3_Obtain"]*100)/$fsAry["FA3_Total"];
											$fa4Obtain=($fsAry["FA4_Obtain"]*100)/$fsAry["FA4_Total"];
											$fa1Obtain=(10*$fa1Obtain)/100;
											$fa2Obtain=(10*$fa2Obtain)/100;
											$fa3Obtain=(10*$fa3Obtain)/100;
											$fa4Obtain=(10*$fa4Obtain)/100;
											$faObtain=$fa1Obtain + $fa2Obtain + $fa3Obtain + $fa4Obtain;
											$faTotal=40;
//$faObtain=$fsAry["FA1_Obtain"]+$fsAry["FA2_Obtain"]+$fsAry["FA3_Obtain"]+$fsAry["FA4_Obtain"];$faTotal=$fsAry["FA1_Total"]+$fsAry["FA2_Total"]+$fsAry["FA3_Total"]+$fsAry["FA4_Total"];
								echo FindGrade($faObtain,$faTotal);//."/".$faObtain."-".$faTotal; ?></td>
								<td style="border-right:2px solid #FA0606"><?php
									$sa1Obtain=($fsAry["SA1_Obtain"]*100)/$fsAry["SA1_Total"];
									$sa2Obtain=($fsAry["SA2_Obtain"]*100)/$fsAry["SA2_Total"];
									$sa1Obtain=(30*$sa1Obtain)/100;
									$sa2Obtain=(30*$sa2Obtain)/100;
									$saObtain=$sa1Obtain + $sa2Obtain;
									$saTotal=60;
								 //$saObtain=$fsAry["SA1_Obtain"]+$fsAry["SA2_Obtain"];$saTotal=$fsAry["SA1_Total"]+$fsAry["SA2_Total"];
								 echo FindGrade($saObtain,$saTotal);//."/".$saObtain."-".$saTotal; ?></td>
								<td style="border-right:2px solid #FA0606">
								<?php 
								$AllObtain = $saObtain + $faObtain;
								$AllTotal = $saTotal + $faTotal;
								echo $final=FindGrade($AllObtain,$AllTotal);//."/".$AllObtain."-".$AllTotal;
								$finalObtain+=$AllObtain;
								$finalTotal+=$AllTotal;
								$ary[]=$final;
								?>
								</td>-->
								<?php } ?>
								
								<td><?php //$tgrade=$db->getVal("select point from examgrade where grade='".$final."'"); echo (float)$tgrade; $overallTotalGrade+=$tgrade;?></td>
							</tr>
						<?php
						 $stid=$_GET["id"];$subj1=$d["subject"];
						$smsAry.="$stid~$subj1~".$final."<br/>";
						} 
						?>
						</table>
				<div style="width:100%;height:48px;border-bottom: 2px solid #F71111;text-align:center;font-weight:800;color: #1224A5;">        
				 <div style="float:left;width:49%;">
					 <div style="width:100%;background:#D5DA13;padding:5px;border-bottom:1px solid #000;color:#000;margin-bottom: 5px;">
							REMARKS BY CLASS TEACHER</div>
					 <span><?php //echo $rmks=$db->getVal("SELECT remarks FROM `naz_remark` WHERE idno='".$aryForm["idno"]."'"); ?></span>
				 </div>
				 <div style="font-size:14px;float:left;width:50%;border-left:2px solid #F71111;text-align:left;">
					<div style="width:100%;background:#D5DA13;border-bottom:1px solid #000;padding:5px;color:#000;">TERM-I PERCENTAGE :  <?PHP echo (number_format($finalObtain1*100/ $finalTotal1,2)+0)."%";?>
					
					| TERM-II PERCENTAGE :  <?PHP echo (number_format($finalObtain2*100/ $finalTotal2,2)+0)."%";;?>
					</div> 
					<div style="width:100%;padding: 5px 5px 0px 5px;font-size:14px;background:#FFEA15;">RESULT : Promoted
					</div>
				 
					<!--<div style="margin-top:4px;">
						 <div style="background:#FFEA15;color:#000;width:100%;float:left;padding:4px;border-top:1px solid #000;border-bottom:1px solid #000;">ATTENDANCE</div>
						<span style="padding:5px;">Total Attendance of the student : 70</span><br/>
						<span style="padding:5px">Total working days : 95</span>
					</div>-->
					</div>
				</div>
				
				<?php
				$smsAry.="$stid~-------~<br/>";
				$smsAry.="$stid~CGPA~".$cgpa."<br/>";
				//echo $db->getErMsg();
					$type=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' group by type order by id");
					if(is_array($type) && count($type)>0){
						?>
			  <!--  <div style="font-size:12px;  clear:both; background-color: #ccc; margin-top:20px; padding: 3px; color: #000;">Part–II :  Co-Scholastic Areas </div>
				<div style="width:48%; display:inline-block; vertical-align:top; margin:0 2% 2% 0">
				  <?php $ijk=0;
							foreach($type as $t){$ijk++;
								if($ijk%4==0)echo '</div><div style="width:48%; display:inline-block;  vertical-align:top;  margin:0 2% 2% 0">';
								?>
								
								<table border="1" style="width:100%;font-size:11px; margin-top:10px; display:inline-table" cellpadding="0" cellspacing="0">
						<tbody id="tbodyskill">
							<tr><th colspan="3"><?php echo $t["type"] ?></th></tr>
						  <?php
										 $lifeskill=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' and type='".$t["type"]."'");
										// echo $db->getErMsg(); $i=1;
										 //echo"<pre>";print_r($all_product);echo"</pre>";
										  if(is_array($lifeskill) && count($lifeskill))
										  {
											   ?>
						  <tr>
							<th>Trait</th>
							<th>Descriptive_	Indicators</th>
							<th>Grade</th>
						  </tr>
						  <?php
											  
											foreach($lifeskill as $iSkill)
											{
												$grade=$db->getVal("select grade from examcriteriarecord where idno='".$_GET['id']."' and term='".$_POST["term"]."' and criteria='".$t["type"]."' and subcriteria='".$iSkill["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'");
										 ?>
						  <tr>
							<td width="200px"><?php echo $iSkill["name"]; ?></td>
							<td ><?php echo $db->getVal("select detail from grade where grade='".$grade."' and  school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'  and criteria='".$t["type"]."' ");//echo $db->getLastQuery() ?></td>
							<td width="55px"><?php echo $grade; ?></td>
						  </tr>
						  <?php $i++;
											} 
										}
										 ?>
						</tbody>
					  </table>
					  
				  <?php
							}
							?>
			   </div>-->
				<?php
							//echo $db->getErMsg();
						}
						?>
						 <div style="border-bottom:2px solid #F71111;height: 80px;">
								<!--<div style="float:left;font-size:12px;font-weight:800;color: #1224A5;">
									<ul>
										<li>Subject wise Indicative percentage of marks = 9.5 x GP of the subject </li>
										<li>CGPA is calculated excluding 3rd language</li>
										<li>Student must obtain the qualifying Grade (min grade-D) in all subjects.</li>
										<li>Overall indicative % of marks = 9.5 x CGPA</li>
									</ul>
								</div>-->
							   <table style="width:60%;margin:0;text-align:center;font-size:13px;border-left:2px solid #F71111;height: 80px;font-weight: 800;color: #1224A5;float:right;" cellpadding="0" cellspacing="2" >
								<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
								</tr>
								<tr style="vertical-align: bottom;">
								  <td width="25%">Student</td>
								  <td>Class teacher</td>
								  <td>Principal</td>
								  <td>Parents/Guardian</td>
								</tr>
							  </table>
						</div>
						<!--<div style="margin-left: 5px;">
			<div style="width:65%;float:left;  margin-top: 10px;color:#1224A5;font-size: 13px;font-weight: 800;">
				Subject wise Indicative percentage of marks = 9.5 x GP of the subject <br/><br/>
			   First Term - FA1(10%)+FA2(10%)+SA1(30%) = 50%  <br/><br/>
				Second Term - FA3(10%)+FA4(10%)+SA2(30%) = 50% <br/><br />
				FORMATIVE ASSESSMENT(FA) 1 + 2 + 3 + 4 = 40%   <br/><br />
				SUMMATIVE ASSESSMENT(SA) 1 + 2 = 60%           <br/><br />
				CGPA is calculated excluding 3rd language.
			</div>
			<div style="width:34%;float:left;margin-top:8px;">
			<table border="1" cellpadding="1" cellspacing="0" style="text-align:center;color:#1224A5;font-size: 13px;font-weight: 800;">
				<tr>
					<td colspan="3">GRADING SYSTEM - SCHOLASTIC</td>
				</tr>
				<tr>
					<td>MARK RANGE</td><td>GRADE</td><td>GRADE POINT</td>
				</tr>
				<tr>
					<td>91 - 100</td><td>A1</td><td>10.0</td>
				</tr>
				<tr>
					<td>81 - 90</td><td>A2</td><td>9.0</td>
				</tr>
				<tr>
					<td>71 - 80</td><td>B1</td><td>8.0</td>
				</tr>
				<tr>
					<td>61 - 70</td><td>B2</td><td>7.0</td>
				</tr>
				<tr>
					<td>51 - 60</td><td>C1</td><td>6.0</td>
				</tr>
				<tr>
					<td>41 - 50</td><td>C2</td><td>5.0</td>
				</tr>
				<tr>
					<td>33 - 40</td><td>D</td><td>4.0</td>
				</tr>
				<tr>
					<td>21 - 32</td><td>E1</td><td>3.0</td>
				</tr>
				<tr>
					<td>0 - 20</td><td>E2</td><td>2.0</td>
				</tr>
			</table>
			</div>
		</div>-->
		
							 
			  </div>
			 <center><p><span style=" margin:0 auto;font-size:17px;font-weight:800;  color: #186916;"> <?php //echo ucfirst(nl2br($LinksDetails["contact_content"])) ?></span></p></center>
			</div>
		  </div>
		</form>
		<?php
		}
			?>
	   
	  </div>
	  </div>
	<?php   }
	}}
//}
	  
	  
	  
	  // my code end
 elseif(isset($_POST['grade'])){
	$allStudent=$db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$_POST["class"]."' $where $stsearch and status=1 and issue_TC=0 order by name");
//echo $db->getLastQuery();
$examtype=$db->getRows("select name,id,total from examterm where school_id='".$_SESSION["admin"]["school_id"]."' order by lorder");
if(is_array($allStudent) && count($allStudent)>0){ $he=0;
	foreach($allStudent as $aryForm){$mss++;$he++;	
		$_GET['id']=$aryForm['idno'];
		$type=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' group by type order by id");
				if(is_array($type) && count($type)>0){
					?>
                    <div style="height:780px;margin-bottom:20px; <?php if($he!=1){?> padding-top: 10px;<?php } ?>">
	 				 <div style="height:726px;border:8px solid #D5DA13;">
         			  <div style="height:20px;width:100%;background:#FDFD0A;color: #0743D2;font-weight: 800;BORDER-TOP:2PX SOLID RED;BORDER-BOTTOM:2PX SOLID RED;font-size:12px;">
                      <ul style="padding-right:5px;width:100%;margin-top:2px;">
                      <li style="float:left;width:30%"> Name : <?php echo $aryForm["name"];?></li>
                      <li style="float:left;width:20%;">CO-SCHOLASTIC AREAS</li>
                      <li style="float:left;width:20%">Class : <?php echo $_POST['class'];if(isset($_POST["section"]) && $_POST["section"]!="") echo "-".$_POST['section']; ?></li>
                      <li style="float:left;width:30%">Father's Name : <?php echo $aryForm["fname"];?></li>
                      
                      </ul>
                    </div>
                   
                      
                      <div style="width:100%;display:inline-block;vertical-align:top;margin:0 5px 0 0">
              <?php $ijk=0;
						foreach($type as $t){$ijk++;
							if($ijk%4==0)echo '</div><div class="right_div" style="width:49.5%; display:inline-block;float:right;vertical-align:top;margin:0 5px 0 0">';
							?>
                            <?php if($_POST["term"]=='term1' OR $_POST["term"]=='term2' ){?>
                            <table border="1" style="width:50% !important;margin-top:10px;margin-left:150px;font-size:11px;font-weight:800;text-align:center;display:inline-table" cellpadding="8" cellspacing="0">
                   <thead>
                    	<?php
                                     $lifeskill=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' and type='".$t["type"]."'");
                                    // echo $db->getErMsg(); $i=1;
                                     //echo"<pre>";print_r($all_product);echo"</pre>";
                                      if(is_array($lifeskill) && count($lifeskill))
                                      {
										   ?>
                      <tr style="background:#D5DA13;">
                        <th><?php echo $t["type"]; if($t["type"]=="2-A") echo ": LIFE SKILS";elseif($t["type"]=="2-B") echo ": WORK EDUCATION";elseif($t["type"]=="2-C") echo ": VISUAL & PERFORMING ARTS";elseif($t["type"]=="2-D") echo ": ATTITUDES & VALUES";elseif($t["type"]=="3-A") echo ": ACTIVITIES"; ?></th>
                        <!--<th>Descriptive_	Indicators</th>-->
                        <th>Grade</th>
                      </tr>
                      </thead>
                    <tbody id="tbodyskill">
                      <?php
                                        foreach($lifeskill as $iSkill)
                                        {
											$grade=$db->getVal("select grade from examcriteriarecord where idno='".$_GET['id']."' and term='".$_POST["term"]."' and criteria='".$t["type"]."' and subcriteria='".$iSkill["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'");
											//echo $db->getLastQuery();
                                     ?>
                      <tr>
                        <td style="color:blue;" width="25%"><?php echo $iSkill["name"]; ?></td>
                       <!-- <td style="color:blue;" width="70%"><?php //echo $db->getVal("select detail from grade where grade='".$grade."' and  school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'  and criteria='".$t["type"]."' and sub_criteria='".$iSkill['name']."' ");//echo $db->getLastQuery() ?></td>-->
                        <td style="color:blue;" width="5%"><?php echo $grade; ?></td>
                      </tr>
                      <?php $i++;
                                        } 
                                    }
                                     ?>
                    </tbody>
                  </table>
                  
				<?php   }
				
				if($_POST["term"]=='final'){ ?>
				
				         <table border="1" style="width:45% !important;float:left;font-size:11px;font-weight:800;text-align:center;display:inline-table " cellpadding="8" cellspacing="0">
                   <thead>
                    	<?php
                                     $lifeskill=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' and type='".$t["type"]."'");
                                    // echo $db->getErMsg(); $i=1;
                                     //echo"<pre>";print_r($all_product);echo"</pre>";
                                      if(is_array($lifeskill) && count($lifeskill))
                                      {
										   ?>
                      <tr style="background:#D5DA13;">
                        <th><?php  echo $t["type"]; if($t["type"]=="2-A") echo ": LIFE SKILS";elseif($t["type"]=="2-B") echo ": WORK EDUCATION";elseif($t["type"]=="2-C") echo ": VISUAL & PERFORMING ARTS";elseif($t["type"]=="2-D") echo ": ATTITUDES & VALUES";elseif($t["type"]=="3-A") echo ": ACTIVITIES"; ?></th>
                        <!--<th>Descriptive_	Indicators</th>-->
                        <th>Grade</th>
                      </tr>
                      </thead>
                    <tbody id="tbodyskill">
                      <?php
                                        foreach($lifeskill as $iSkill)
                                        {
											$grade=$db->getVal("select grade from examcriteriarecord where idno='".$_GET['id']."' and term='term1' and criteria='".$t["type"]."' and subcriteria='".$iSkill["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'");
											//echo $db->getLastQuery();
                                     ?>
                      <tr>
                        <td style="color:blue;" width="25%"><?php  echo  $iSkill["name"]; ?></td>
                       <!-- <td style="color:blue;" width="70%"><?php //echo $db->getVal("select detail from grade where grade='".$grade."' and  school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'  and criteria='".$t["type"]."' and sub_criteria='".$iSkill['name']."' ");//echo $db->getLastQuery() ?></td>-->
                        <td style="color:blue;" width="5%"><?php echo $grade; ?></td>
                      </tr>
                      <?php $i++;
                                        } 
                                    }
                                     ?>
                    </tbody>
                  </table>
					
					
					<table border="1" style="width:45% !important;float:right;margin-top:3px;margin-right:42px;font-size:11px;font-weight:800;text-align:center;display:inline-table" cellpadding="8" cellspacing="0">
					
					
                   <thead>
                    	<?php
                                     $lifeskill=$db->getRows("select * from criteria where school_id='".$_SESSION["admin"]["school_id"]."' and type='".$t["type"]."'");
                                   //  echo $db->getErMsg(); $i=1;
                                     //echo"<pre>";print_r($all_product);echo"</pre>";
                                      if(is_array($lifeskill) && count($lifeskill))
                                      {
										   ?>
                      <tr style="background:#D5DA13;">
                        <th><?php echo $t["type"]; if($t["type"]=="2-A") echo ": LIFE SKILS";elseif($t["type"]=="2-B") echo ": WORK EDUCATION";elseif($t["type"]=="2-C") echo ": VISUAL & PERFORMING ARTS";elseif($t["type"]=="2-D") echo ": ATTITUDES & VALUES";elseif($t["type"]=="3-A") echo ": ACTIVITIES"; ?></th>
                        <!--<th>Descriptive_	Indicators</th>-->
                        <th>Grade</th>
                      </tr>
                      </thead>
                    <tbody id="tbodyskill">
                      <?php
                                        foreach($lifeskill as $iSkill)
                                        {
											$grade=$db->getVal("select grade from examcriteriarecord where idno='".$_GET['id']."' and term='term2' and criteria='".$t["type"]."' and subcriteria='".$iSkill["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'");
											//echo $db->getLastQuery();
                                     ?>
                      <tr>
                        <td style="color:blue;" width="25%"><?php echo $iSkill["name"]; ?></td>
                       <!-- <td style="color:blue;" width="70%"><?php //echo $db->getVal("select detail from grade where grade='".$grade."' and  school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'  and criteria='".$t["type"]."' and sub_criteria='".$iSkill['name']."' ");//echo $db->getLastQuery() ?></td>-->
                        <td style="color:blue;" width="5%"><?php echo $grade; ?></td>
                      </tr>
                      <?php $i++;
                                        } 
                                    }
                                     ?>
                    </tbody>
                  </table>
					
					
					
			<?php	}
				
						}
						?>
           			</div>
                      <div style="margin-left: 120px;">
					    <div style="width:100%;margin-top:6px;">
                           <table border="1" cellpadding="2" cellspacing="0" style="text-align:center;color:#1224A5;font-size:10px;width:39%;font-weight:800;float:left;">
                                   <tr>
                                        <td colspan="3">GRADING SYSTEM - SCHOLASTIC</td>
                                    </tr>
                                    <tr>
                                        <td>MARK RANGE</td><td>GRADE</td>
                                    </tr>
                                    <tr>
                                        <td>91 - 100</td><td>A1</td>
                                    </tr>
                                    <tr>
                                        <td>81 - 90</td><td>A2</td>
                                    </tr>
                                    <tr>
                                        <td>71 - 80</td><td>B1</td>
                                    </tr>
                                    <tr>
                                        <td>61 - 70</td><td>B2</td>
                                    </tr>
                                    <tr>
                                        <td>51 - 60</td><td>C1</td>
                                    </tr>
                                    <tr>
                                        <td>41 - 50</td><td>C2</td>
                                    </tr>
                                    <tr>
                                        <td>33 - 40</td><td>D</td>
                                    </tr>
                                    <tr>
                                        <td>0 - 32</td><td>E</td>
                                    </tr>

                                </table>
                   
                    <table border="1" cellpadding="6" cellspacing="0" style="text-align:center;width:29%;color:#1224A5;font-size:10px;font-weight:800;line-height:29px;float:left">
                                    <tr>
                                        <td colspan="3">CO - SCHOLASTIC</td>
                                    </tr>
                                    <tr>
                                        <td>GRADE</td><td>GRADE POINTS</td>
                                    </tr>
                                    <tr>
                                        <td>A</td><td>Outstanding</td>
                                    </tr>
                                    <tr>
                                        <td>B</td><td>Very Good</td>
                                    </tr>
                                    <tr>
                                        <td>C</td><td>Fair</td>
                                    </tr>
                                    
                    </table>
					<br>
                    </div>
                        
					</div>
					
					
					
					
					 <table style="width:60%;margin:0;text-align:left;font-size:13px;solid #F71111;height: 80px;font-weight: 800;color: #1224A5;margin-left:22px;" cellpadding="0" cellspacing="2" >
								<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
								</tr>
								<tr style="vertical-align: bottom;">
								  <td width="60%">Class Teacher's remarks :................................</td>
								  
								</tr>
								<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
								</tr>
								<tr style="vertical-align: bottom;">
								  <td width="60%">Promoted to Class :................................</td>
								  
								</tr>
							  </table>
					
							   <table style="width:100%;margin:0;text-align:left;font-size:13px;solid #F71111;height: 80px;font-weight: 800;color: #1224A5;float:center;margin-left:22px;" cellpadding="0" cellspacing="2" >
								<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
								</tr>
								<tr style="vertical-align: bottom;">
								 
								 
								  <td>Place:<br>Date........</td>
								  <td>&nbsp;</td>
								  <td>Signature of Class Teacher </td>
								  <td>&nbsp;</td>
								  <td>Signature of Principal</td>
								</tr>
							  </table>
						
										
		</div> 
        </div>
            <?php
						//echo $db->getErMsg();
				}
	  }
	  
	}
}
?> 
<style>th{color:#000;}td, th{line-height: 1;} table{margin:2px;}</style>

<input type="hidden" name="smsTXT" id="smsTXT" value="<?php echo $smsAry; ?>" />
<input type="hidden" name="examtype" id="examtype" value="<?php echo $_POST["term"]; ?>" />
<?php
//}
?>
</div>
<div id="canvas"></div>
<script src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>
<script>

</script>
