<?php
$pgMod="student_portal";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);

	?>
	<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    </div>
    <div class="well no-padding">
	<?php
	$aryPgAct=array("src"=>"TC", "page_id"=>$pgMod,"action"=>"add");
	$aryList=$db->getRows("select idno from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and status=1 and issue_TC=0 order by name");
	if(is_array($aryList) && count($aryList)>0){
		?>

         <div style="position: absolute;width:300px;z-index: 99999;margin: 30px;">
            <select onchange="fetchByClass()" class="span6" 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>
            <select onchange="fetchByClass()" class="span6" name="section" 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 value="<?php echo $cla["name"] ?>">
                            <?php echo $cla["name"] ?>
                        </option>
                        <?php
                    }
                ?>
            </select>
        </div>
        <input type="hidden" id="tabletype" value="student_portal_data" />

        <table class="table" id="ajaxtable">
            <thead>
                <tr>
                    <th>S. No</th>
                    <th>Name</th>
                    <th>Father</th>
                    <th>Class</th>
                    <th>Roll No.</th>
                    <th>Admission no</th> 
                    <th>Mobile</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tfoot>
            </tfoot>
            <tbody>
           
            </tbody>
            <!--<tbody>-->
           <?php /* $student = $db->getRows("select * from student where session='".$_SESSION['admin']['session']."' and status='1'  ");
                    foreach($student as $stu){ $i++; ?>
                        <tr>
                            <td><?php echo $i; ?></td>
                            <td><?php echo $stu['name']; ?></td>
                            <td><?php echo $stu['fname']; ?></td>
                            <td><?php echo $stu['class']; ?></td>
                            <td><?php echo $stu['fincome']; ?></td>
                            <td><?php echo $stu['admissionno']; ?></td>
                            <td><?php echo $stu['mobile']; ?></td>
                            <td><button class="btn btn-info" onclick="enterStudentPortal('<?php echo $stu['idno']; ?>')">Enter</button></td>
                        </tr>
            <?php } */
           ?>
            <!--</tbody>-->
        </table>
		<?php
	}
	else{
		?>
        <div class="alert alert-info">
          <a class="close" data-dismiss="alert">×</a>
          <i class="icon icon-warning-sign"></i> <b>Notice</b> Record not found </i>
        </div>
        <?php
	}?>
	</div></div></div>
	<?php

?>
<script type="text/javascript">

$(document).ready(function(e) {
    var oTable = $('#ajaxtable').dataTable( {
		"bProcessing": true,
		'sPaginationType': 'full_numbers',
		"sAjaxSource": 'Exam/ajax.php?type='+$('#tabletype').val(),
		'iDisplayLength': 5,
		"oLanguage": {
			"sSearch": "Search by any columns:"
		}
	});
});
function fetchByClass(id){
	var name=$("#class").val();
	var section=$("#section").val();
	//alert(name+section);
	if(name!=""){
		var url='Exam/ajax.php?class='+name+'&type='+$('#tabletype').val();
		if(section!=""){
			url+='&section='+section;
		}
		 oTable = $('#ajaxtable').dataTable( {
			"bProcessing": true,
			'sPaginationType': 'full_numbers',
			"bServerSide": false,
			"bDestroy":true,
			"sAjaxSource": url,
			'iDisplayLength': 5,
			"oLanguage": {
				"sSearch": "Search by any columns:"
			}
		});
	}else{
		var oTable = $('#ajaxtable').dataTable( {
			"bProcessing": true,
			'sPaginationType': 'full_numbers',
			"bServerSide": false,
			"bDestroy":true,
			"sAjaxSource": 'Exam/ajax.php?type='+$('#tabletype').val(),
			'iDisplayLength': 5,
			"oLanguage": {
				"sSearch": "Search by any columns:"
			} 
		});
	}
}

    function enterStudentPortal(idno){
    	$.post( "Exam/ajax.php", { type: "studentportal" ,idno: idno } , function( data ) {
    	    window.location = data;
    	});
    }
</script>



