<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();
	//alert(examtype);

	$.post( "ajax.php", { type: "sendsmsexam_mp" ,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="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>
          
        </div>
      </div>
      <div class="well no-padding">
        <div class="controls controls-row">
        
           			    <div class="control-group span3">
                    
                           
                            <div class="controls span3">
                                <select onchange="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">   
                               <select name="term">
                                <option value="">Exam type</option>
                                 <?php 
                                        $exam=$db->getRows("select * from examterm_mp order by id");
                                        foreach($exam as $ex){
                                            ?>
                                <option value="<?php echo $ex["name"] ?>"><?php echo $ex["name"] ?></option>
                               <?php } ?>
                              </select>
                           </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 name,id,total from examterm_mp 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++;
				
	  ?>
	  <!--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["term"]!="final") $termWhere=" and name='".$_POST["term"]."' ";
		$examtype=$db->getRow("select name,id from examterm_mp  where school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by id");
		
		//echo "select name,id from examterm_mp  where school_id='".$_SESSION["admin"]["school_id"]."' $termWhere order by id";
		
	//echo $db->getLastQuery();print_r($examtype);exit;
		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 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 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;
								 //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 $examtype[0] ?>" placeholder="Exam type" /><?php echo $examtype[0] ?>
	</td>
							<?php 
							}?>
							
							<td style="border-bottom: 1px solid #000;" width="18%">Grade Point</td>
						</tr>
						
						<?php $x=0;
						$detail=$db->getRows("select * from subject_mp where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$_REQUEST["class"]."' and session='".$_SESSION["admin"]["session"]."'");
																		
						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 
								 $examResultData=$db->getRow("select * from exammarks_mp where idno='".$aryForm["idno"]."' and type='".$examtype[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[0];?>[]" class="<?php echo $examtype[0];?>_total_marks total" value="<?php
								echo $total=$db->getVal("select total from examterm_mp where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$examtype[1]."'"); ?>" placeholder="Total Maks" />
								 <input required type="hidden" style="width:70px" name="<?php echo $examtype[0];?>_student[]" class="onlyZero obtain <?php echo $examtype[0];?>_obtain_marks" value="<?php echo (int)$examResultData["obtain"]; ?>" placeholder="Obtain Maks" />
								 <?php
								 echo $examResultData['obtain'];
								 $obt=$examResultData['obtain'];
								  ?>
								 </td>
								<?php $x++; ?>
								<?php if($_POST["term"]=="term1"){ ?>
								
								<?php }elseif($_POST["term"]=="term2"){ ?>
								
								<?php } ?>
								<td><?php 
								//$tgrade=$db->getVal("select point from examgrade_mp where grade='".$final."'"); 
								
								$tgrade=$db->getVal("SELECT point FROM `examgrade_mp` WHERE $obt between minrange and maxrange"); 
								
								
								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>
				                     
					</div>
				</div>-->
				
				<?php
				$smsAry.="$stid~--~<br/>";
				//$smsAry.="$stid~CGPA~".$cgpa."<br/>";
				
						?>
						 <div>
							   
						</div>
						 
			  </div>
			</div>
		  </div>
		</form>
		<?php
		}
			?>
	   
	  </div>
	  </div>
	<?php 
	   
	}}
}
?> 
<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>
