<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( "Exam/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>
<form method="post" action="">
  <div class="row-fluid">
  <div class="row-fluid">
    <div class="span12">
      <div class="top-bar">
        <h3><i class="icon-cog"></i>Search Student Record</h3>
        <div>
          <?php 
						if($_POST){
							?>
          <button type="button" name="fee" onClick="printDivNoHeader('printableDiv')" class="btn btn-primary"> Print</button>
          <button type="button" name="fee" onClick="smsDivNoHeader()" class="btn btn-primary"> SMS</button>
          <?php
						}
						?>
          <button type="submit" name="fee" class="btn btn-primary"> View Record</button>
          <button type="submit" name="grade" class="btn btn-primary"> View Grade</button>
        </div>
      </div>
      <div class="well no-padding">
        <div class="controls controls-row">
        
           			    <div class="control-group span3">
                    
                           
                            <div class="controls span3">
                                <select onchange="getType(this.value),findStudent()" name="class" id="class">
                                    <option value="">Class</option>
                                    <?php 
                                        $class=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."'");
                                        foreach($class as $cla){
                                            ?>
                                            <option <?php if($cla["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $cla["class"] ?>">
                                                <?php echo $cla["class"] ?>
                                            </option>
                                            <?php
                                        }
                                    ?>
                                </select>
                            </div>
                       </div>
                       	<div class="control-group span3">
                            
                            <div class="controls span3">
                               <select name="section" onchange="findStudent()" id="section">
                                    <option value="">Section</option>
                                    <?php 
                                        $class=$db->getRows("select * from section where school_id='".$_SESSION["admin"]["school_id"]."'");
                                        foreach($class as $cla){
                                            ?>
                                            <option <?php if($cla["name"]==$aryForm["section"])echo 'selected';?> value="<?php echo $cla["name"] ?>">
                                                <?php echo $cla["name"] ?>
                                            </option>
                                            <?php
                                
                                        }
                                    ?>
                                </select>
                            </div>
                        </div>  
                           <div class="control-group span3">   
                               <div class="controls span3" id="extype">
                                <select name="type">
                                	<option value="">Exam type</option>
                                </select>
                                </div>
                           </div>
                        <div class="control-group span3">
                            <div class="controls span3" id="findStudent">
                              <select  name="idno" id="idno">
                               <option value="">All Student</option>
                              </select>
                            </div>
         			   </div>   
        </div>
        <br>
      </div>
      <!-- / Forms: Content --> 
      
    </div>
  </div>
</form>
<div id="printableDiv">
  <?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 $db->getLastQuery();
	$examtype=$db->getRows("select type,id,total from examtype where class='".$_POST["class"]."' and school_id='".$_SESSION["admin"]["school_id"]."' order by id ASC");
	if(is_array($allStudent) && count($allStudent)>0){ $he=0;
		foreach($allStudent as $aryForm){$mss++;$he++;
		
	  if($_POST["type"]=="I Term" || $_POST["type"]=="II Term"){  ?>
	  <!--one page <div style="height:942px">end --> 
	  <!--two page-->
	  <div style="height:962px;margin-bottom:20px;">
	  <div style="height:955px;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["type"]!="final") $termWhere=" and term='".$_POST["type"]."' ";
		$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:22px"> <img src="<?php echo $LinksDetails["logo"] ?>" height="80px" width="110px" style="margin:6px 0px 0px 10px;"></div>
			 <div style="float:left;text-align:center;margin-bottom:18px;"> <h1 style="font-size:32px;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"])) ?></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"] ?></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">Admission No.</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["admissionno"] ?></td>
					<td width="21%"><strong class="st">Contact</strong></td><td width="2%">:</td>
					<td width="21%"><?php echo $aryForm["mobile"] ?></td>
					
				  </tr>
				  <tr>
					<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="20%"><strong class="st">D.O.B</strong></td><td width="2%">:</td>
					<td width="30%"><?php if($aryForm["dob"]!="")echo date("d-M-Y",strtotime($aryForm["dob"])); ?></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>
							
							
							<?php if($_POST["type"]=="final"){?> 
							<td colspan="3" style="border-right:2px solid #FA0606; text-align:center">Term-I</td>
							<td colspan="3" style="border-right:2px solid #FA0606; text-align:center">Term-II</td>
							<td colspan="3" style="border-right:2px solid #FA0606; text-align:center">(Overall Grade)</td>
							<?php }elseif($_POST["type"]=="term1"){ ?>
							<td colspan="2" style="border-right:2px solid #FA0606; text-align:center">Term-I</td>
							<td colspan="2" style="border-right:2px solid #FA0606; text-align:center">(Overall Grade)</td>
							<?php }elseif($_POST["type"]=="term2"){ ?>
						   <td colspan="2" style="border-right:2px solid #FA0606; text-align:center">Term-II</td>
							<td colspan="2" style="border-right:2px solid #FA0606; text-align:center">(Overall Grade)</td>
							<?php } ?>
							<td></td>
						</tr>-->
						<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="15%">
								<input type="hidden" name="type[]" style="width:80px" class="total" value="<?php echo $eytpe[0] ?>" placeholder="Exam type" /><?php echo $eytpe[0] ?>
	</td>
							<?php }
							}?>
							<?php if($_POST["type"]=="final"){?> 
							<td style="border-right:2px solid #FA0606">FA</td>
							<td style="border-right:2px solid #FA0606">SA</td>
							<td style="border-right:2px solid #FA0606">Grade</td>
							<?php }elseif($_POST["type"]=="term1"){ ?>
							<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;padding:5px;" width="15%">FA1+FA2+SA1</td>
							<?php }elseif($_POST["type"]=="term2"){ ?>
							<td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">FA3+FA4+SA2</td>
							<?php } ?>
							<td style="border-bottom: 1px solid #000;" width="18%">Grade Point</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][0]."' 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][0];?>[]" class="<?php echo $examtype[$i-1][0];?>_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][1]."'"); ?>" placeholder="Total Maks" />
								 <input required type="hidden" 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; ?>
								 </td>
								<?php }$x++; ?>
								<?php if($_POST["type"]=="final"){?> 
								<td style="border-right:2px solid #FA0606"><?php $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); ?></td>
								<td style="border-right:2px solid #FA0606"><?php $saObtain=$fsAry["SA1_Obtain"]+$fsAry["SA2_Obtain"];$saTotal=$fsAry["SA1_Total"]+$fsAry["SA2_Total"];echo FindGrade($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;
								?>
								</td>
								<?php }elseif($_POST["type"]=="term1"){ ?>
								<td style="border-right:2px solid #FA0606"><?php $fa1Obtain=$fa2Obtain=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;
									$AllTotal =50;
									$AllObtain = $saObtain + $faObtain;
									echo $final=FindGrade($AllObtain,$AllTotal);//."/".$AllObtain."-".$AllTotal;
									$finalObtain+=$AllObtain;
									$finalTotal+=$AllTotal;
								?></td>
								<?php }elseif($_POST["type"]=="term2"){ ?>
								<td style="border-right:2px solid #FA0606"><?php 
									$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;
									echo $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;?></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>Keep Up The Good Work</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;">CGPA </div> 
					<span style="padding:5px;font-size:17px">
					<?php $c=$overallTotalGrade/count($detail); echo $cgpa=number_format((float)$c, 2, '.', ''); ?></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["type"]=="term1")echo $attr['term1_att'];elseif($_POST["type"]=="term2") $attr['term2_att'];?></span><br/>
						<span style="padding:5px">Total working days : <?php if($_POST["type"]=="term1")echo $LinksDetails['term1_all_day'];elseif($_POST["type"]=="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){
						?>
			  <!--  <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["type"]."' 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>
							   <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 style="width:34%;float:left;margin-top:8px;">
			<table border="1" cellpadding="3" 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>
			</div>
		  </div>
		</form>
		<?php
		}
			?>
	   
	  </div>
	  </div>
	<?php }
	   elseif($_POST["type"]=="III Term"){
		//echo $_POST["type"];exit;  ?>
		  <div style="height:765px;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["type"]!="final") $termWhere=" and type='".$_POST["type"]."' ";
		$examtype=$db->getRows("select distinct(type) from examtype  where class='".$_POST["class"]."' and school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by id ASC");
		//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:226px"> <img src="<?php echo $LinksDetails["logo"] ?>" height="80px" width="80px" 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"])) ?></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;"> Report Card FINAL (SESSION : <?php echo $_SESSION["admin"]["session"];?>)</div>
				<?php $attr=$db->getRow("select * from allattandence where idno='".$aryForm["idno"]."' and session='".$_SESSION["admin"]["session"]."'"); 
				 
				?>
                <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>
               	
				<?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 } ?> 
				 <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%; float:left;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="2" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">THEORY</td>
                            <td colspan="2" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">PROJECT</td>
                            <td colspan="2" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">TOTAL</td>
		               
						</tr>
						<tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
							<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">MM</td> 
							<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">OM</td>
							
                            <td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">MM</td> 
							<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">OM</td>
						
                            <td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">MM</td> 
							<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">OM</td>
							
						</tr>
						
						<?php $x=0;$fsAry=array();$term1=0;$term2=0;$annual=0;
						$detail=$db->getRows("select * from subject_mp where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' order by id");
						foreach($detail as $d){ $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 $totalmarks=0;$totalobtained=0;
								for($i=1; $i<=count($examtype);$i++){ 
								$examResultData=$db->getRow("select * from exammarks_mp where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1][0]."' and subject='".$d["subject"]."'"); //echo $db->getLastQuery();

                                if($i==3){}
                                else {
								?>
								
								<td style="border-right:2px solid #FA0606"><?php echo $total=$examResultData["total"]; ?></td>
                                <td style="border-right:2px solid #FA0606"><?php echo $examResultData["obtain"];?></td>

								 <?php 
 								 $totalmarks += $examResultData["total"];; 
								 $totalobtained += $examResultData["obtain"]; 
                                    
                                }
								 $fs=$examtype[$i-1][0];
								 $fsAry[$fs."_Obtain"]+=$examResultData["obtain"];
								 $fsAry[$fs."_Total"]+=$total;
								 
								 
								  }?>
								 <td style="border-right:2px solid #FA0606"><?php echo $totalmarks; ?></td>
								 <td style="border-right:2px solid #FA0606"><?php echo $totalobtained; ?></td>
								</tr>
						<?php 
						 $stid=$_GET["id"];$subj1=$d["subject"];
						$smsAry.="$stid~$subj1~".$final."<br/>";
								}
						?>
                        <tr>
                        	<td style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom:1px solid #000;">Total</td>
                            <?php $totalfinal=0; $toalobt=0; for($i=1; $i<=count($examtype);$i++){
								$fs=$examtype[$i-1][0]; 
								if($i==3){}
                                else {
                                    
								?>
                            <td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"><?php echo $fsAry[$fs."_Total"] ?></td> 
							<td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"><?php  echo $fsAry[$fs."_Obtain"] ?></td>
							<!--<td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"><?php //echo FindGrade_junior($fsAry[$fs."_Obtain"],$fsAry[$fs."_Total"]); ?></td> -->
                            <?php $per[$fs]=($fsAry[$fs."_Obtain"]*100)/$fsAry[$fs."_Total"]; 
                            $totalfinal += $fsAry[$fs."_Total"];
                            $toalobt += $fsAry[$fs."_Obtain"];
                            } } ?>
                            <td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"><?php echo $totalfinal; ?></td> 
							<td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"><?php echo $toalobt; ?></td>
                        </tr>

                            <!--<tr>-->
                            <!--	<td style="border-right:2px solid #FA0606;border-bottom:1px solid #ccc;">Percentage</td>-->
        						<?php for($i=1; $i<=count($examtype);$i++){  $fs=$examtype[$i-1][0];
									$per[$fs]=sprintf ("%.2f", $per[$fs]); 
									if($fs=="QUATERLY") $term1=$per[$fs];
									elseif($fs=="HALF YEARLY") $term2=$per[$fs]; 
									elseif($fs=="ANNUAL") $annual=$per[$fs]; ?>
                            <!--    <td colspan="2" style="border-right:2px solid #FA0606;border-bottom:1px solid #ccc;"><?php echo $ann=$per[$fs]."%"; ?></td> <?php }?>-->
                            <!--</tr>-->

                            <?php
						$detail_ext=$db->getRows("select * from subject_extra_mp where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."'");
						if(is_array($detail_ext) && count($detail_ext)>0){
							foreach($detail_ext as $dext){?>
                            <tr>
								<td style="border-right:2px solid #FA0606"><?php echo ucfirst($dext["subject"]) ?><input type="hidden" name="subject[]" value="<?php echo $dext["subject"] ?>" /></td>
								<?php 
								for($i=1; $i<=count($examtype);$i++){ 
								$examResultData=$db->getVal("select grade from extra_subgrade_mp where idno='".$aryForm["idno"]."' and type='".$examtype[$i-1][0]."' and subject='".$dext["subject"]."'"); //echo $db->getLastQuery(); ?>
                                 <td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"> - </td> 
								<td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;border-bottom: 1px solid #000;"> <?php echo $examResultData; ?> </td>
                                <?php }?>
								</tr>
                             <?php }} ?>
						</table>
						
						
						<table style="width:100%;font-size:12px;border-top:1px solid #FA0606 ;border-bottom:1px solid #000;color: #1224A5;font-weight: 800;" cellpadding="5" cellspacing="0">
						
						    <tr><br>
						        <td style="border-right:solid 2px #000;width:30%">ATTENDANCE _________________</td>
						        <td style="border-right:solid 2px #000;width:24%"></td>
						        <td style="border-right:solid 2px #000;width:23%"></td>
						        <td style="border-right:solid 2px #000;width:23%"></td>
						    </tr>
						    
						    <tr>
						        <td style="border-right:solid 2px #000;">RESULTS ______________________</td>
						        <td style="border-right:solid 2px #000;">PREPARED BY: <br> _________________________</td>
						        <td style="border-right:solid 2px #000;"></td>
						        <td style="border-right:solid 2px #000;"></td>
						    </tr>
						    
						    <tr>
						        <td style="border-right:solid 2px #000;">GRADE ________________________</td>
						        <td style="border-right:solid 2px #000;"></td>
						        <td style="border-right:solid 2px #000;"></td>
						        <td style="border-right:solid 2px #000;"></td>
						    </tr>
						    
						    <tr>
						        <td style="border-right:solid 2px #000;">REMARK ______________________</td>
						        <td style="border-right:solid 2px #000;">SIGN. :-</td>
						        <td style="border-right:solid 2px #000;text-align:center;">PARENTS SIGN.</td>
						        <td style="border-right:solid 2px #000;text-align:center;">PRINCIPAL SIGN.</td>
						    </tr>
						    
						</table>
						
                        <!--<table style="width:20%;float:left;font-size:10px;margin:0;border-top:1px solid #FA0606 ;border-bottom:1px solid #000;text-align: center;color: #1224A5;font-weight: 800;" cellpadding="2" cellspacing="0">-->
						<?php/* $detail1=$db->getRows("select * from extrahead_mp where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'"); 

   
						if(is_array($detail1) && count($detail1)>0){ 
								foreach($detail1 as $dext1){?>
						
						<?php $x=0;$fsAry=array();
						$detail_ext=$db->getRows("select * from extra_head_detail_mp where head='".$dext1["name"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."' order by id");
						if(is_array($detail_ext) && count($detail_ext)>0){
							foreach($detail_ext as $dext){?>
                            <tr>
								<td style="border-right:2px solid #FA0606"><?php echo ucfirst($dext["subject"]) ?><input type="hidden" name="subject[]" value="<?php echo $dext["subject"] ?>" /></td>
								<?php 
									$examResultData=$db->getVal("select grade from extra_headgrade_mp where idno='".$aryForm["idno"]."' and type='ANNUAL' and subject='".$dext["subject"]."' and head='".$dext1["name"]."'  and session='".$_SESSION["admin"]["session"]."' and school_id='".$_SESSION["admin"]["school_id"]."'"); 
			 
									?>
									
                                 <td width="7%" style="border-right:2px solid #FA0606;border-top:1px solid red;"><?php echo $examResultData; ?></td>
                                <?php ?>
								</tr>
                             <?php }}} } */?>
						<!--</table>-->
						
						
                        <!--<table style="width:100%;font-size:12px;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>-->
                        <!--	<td style="border-right:2px solid #FA0606;">ANNUAL REMARK</td><td style="border-right:2px solid #000;">-->
                        <!--<?php  if($annual>=75 && $annual<=100)echo "Excellence";elseif($annual>=60 && $annual<=74.9)echo "Very Good";elseif($annual>=45 && $annual<=59.9)echo "Good";elseif($annual>=33 && $annual<=44.9)echo "Average";elseif($annual<=33.9)echo "Below Average"; ?></td>-->
                        <!--</tr>-->
                        <!--</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>Keep Up The Good Work</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;">Annual Result : -->
				<!--	<?php echo $ann; ?></div> -->
				<!--	<div style="width:100%;padding: 5px 5px 0px 5px;font-size:14px;background:#FFEA15;">RESULT : Promoted-->
				<!--	</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["type"]."' 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;">-->
								
						<!--	   <table style="width:100%;margin:0;text-align:center;font-size:13px;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>Parents/Guardian</td>-->
      <!--                            <td>Principal</td>-->
						<!--		</tr>-->
						<!--	  </table>-->
						<!--</div>-->
					
			  </div>
			</div>
		  </div>
		</form>
		<?php
		}
			?>
	   
	  </div>
	  </div>
	<?php   }
	}}
}
 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:733px;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:49.5%;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">';
							?>
                            
                            <table border="1" style="width:100% !important;margin-top:10px;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
						}
						?>
           			</div>
                      <div style="margin-left: 5px;">
					    <div style="width:50%;margin-top:6px;">
                           <table border="1" cellpadding="2" cellspacing="0" style="text-align:center;color:#1224A5;font-size:10px;width:59%;font-weight:800;float:left;">
                                   <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>
                   
                    <table border="1" cellpadding="6" cellspacing="0" style="text-align:center;width:39%;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>4.1 - 5.0</td>
                                    </tr>
                                    <tr>
                                        <td>B</td><td>3.1 - 4.0</td>
                                    </tr>
                                    <tr>
                                        <td>C</td><td>2.1 - 3.0</td>
                                    </tr>
                                    <tr>
                                        <td>D</td><td>1.1 - 2.0</td>
                                    </tr>
                                    <tr>
                                        <td>E</td><td>0 - 1.0</td>
                                    </tr>
                    </table>
                    </div>
                        <div style="width:48%;float:right;margin:6px;color:#1224A5;font-size:10px;font-weight: 800;">
                            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%
                        </div>
					</div>
		</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>
