<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;} 
.dynamic{display:none}
table td {
padding: 6px !important;
}
legend{line-height: 16px;font-weight:100;}

.outer .MigrateLeftFee{
  background-color: #DADADA !important;
  border: 5px solid #181616 !important;
  min-height: 440px;
  min-width:700px;
}
.st {
	width: 55px;
	font-size:10px;
	display: inline-block;
	color: #021EF0;
}
.size{
	font-size:12px;
}
.recepit {
	width: 717px !important;
	height: 344px !important;
}
.total{
	color: darkgreen;
    font-weight: 800;
}
</style>
<input type="hidden" name="tog" id="togglevalueforzeoshow" value="0" />
<script>

function checkAll(){
	if($('#checkboxa').prop('checked')) {
		$('.checkboxes').prop('checked', true);
		 
    } else {
		
        $('.checkboxes').prop('checked', false);
    }
	//var chk=$('input[name=cat]:checked').length;
	//alert(chk);
	
}
function  sendAll(){
	checked = $('input[name=sid]:checked');
        if( checked.length > 0 ) {
            var checkValues = checked.map(function(){
               return $(this).val();
            }).get();
			//alert(checkValues);
			//confirm();
			var chk=checkValues.toString();
			$.post( "?page_id=sms&type=student", { type: "POST" ,chk: chk} , function( data ) {
	  
				window.location.href = './?page_id=sms&type=student&chk='+chk+'';
		});
          /*$.ajax({
                type: "POST",
				 url: "http://127.0.0.1/sms/?page_id=sms&type=student",
                data: { ids: checkValues },
                success:function(data){
						window.location.href = '?page_id=sms&type=student';
					 },
            });*/
        }else{
             alert("You need to pick at least one checkbox!");
        }
	//var date=$("#date").val();
	//$.post( "ajax.php", { type: "DATE_SEARCH" ,date: date } , function( data ) {
	//  	$("#date_content").html(data);
	//	getTotal();
	//});
}

function SMSComplete(valueid,act){
	$(this).hide();
	var Fee=$("#"+valueid).html();
	var fdate='<?php if($_GET["fdate"]!="")echo $_GET["fdate"];else echo "0" ?>';
	var fmonth='<?php if($_GET["fmonth"]!="")echo $_GET["fmonth"];else echo "0" ?>';
	var fyear='<?php if($_GET["fyear"]!="")echo $_GET["fyear"];else echo "0" ?>';
	var tdate='<?php if($_GET["tdate"]!="")echo $_GET["tdate"];else echo "0" ?>';
	var tmonth='<?php if($_GET["tmonth"]!="")echo $_GET["tmonth"];else echo "0" ?>';
	var tyear='<?php if($_GET["tyear"]!="")echo $_GET["tyear"];else echo "0" ?>';
	var cls='<?php if($_GET["class"]!="")echo $_GET["class"];else echo "0" ?>';
	$.post( "ajax.php", { type: act ,fee: Fee, fdate:fdate, fmonth:fmonth, fyear:fyear, tdate:tdate, tmonth:tmonth, tyear:tyear,class: cls  } , function( data ) {
	  	//$("#ins").html(data);getTotal();
		alert(data);
		$(this).show();
	});
}
function SMS(type){
	if(confirm('Do you want to send sms now..!')){
	var ids=document.getElementsByName('mobile[]');
	var detail=document.getElementsByName('details[]');
	var arr = [];
	for(var i=0;i<ids.length;i++){
		arr.push(ids[i].value+"-"+detail[i].value);
	}
	var Fee=arr.join(",");
	var fdate='<?php if($_GET["fdate"]!="")echo $_GET["fdate"];else echo "0" ?>';
	var fmonth='<?php if($_GET["fmonth"]!="")echo $_GET["fmonth"];else echo "0" ?>';
	var fyear='<?php if($_GET["fyear"]!="")echo $_GET["fyear"];else echo "0" ?>';
	var tdate='<?php if($_GET["tdate"]!="")echo $_GET["tdate"];else echo "0" ?>';
	var tmonth='<?php if($_GET["tmonth"]!="")echo $_GET["tmonth"];else echo "0" ?>';
	var tyear='<?php if($_GET["tyear"]!="")echo $_GET["tyear"];else echo "0" ?>';
	var cls='<?php if($_GET["class"]!="")echo $_GET["class"];else echo "0" ?>';
	$.post( "ajax.php", { type: type ,fee: Fee, fdate:fdate, fmonth:fmonth, fyear:fyear, tdate:tdate, tmonth:tmonth, tyear:tyear,class: cls  } , function( data ) {
		alert(data);
	});
}}
function sendSMDTO(){
	//alert("sms sending process under constration...");
}

function filterPayleft(Tval){
	var val=$(Tval).val();
	if(val.trim()==""){
		$(".MyTotalFee").parent().show();
		$(".MyTotalFee").parent().addClass('none');
	}
	else
	if(!isNaN(val)){
		var allTot="";
		$(".MyTotalLeft").each(function(index, element) {
			var myVal=parseInt($(this).html());
			if(myVal>val)
			{
				$(this).parent().hide('slow');
				$(this).parent().removeClass('none');
			}
			else
			{
				$(this).parent().show('slow');
				$(this).parent().addClass('none');
			}
        });
		//alert(allTot);
	}else{
		alert("Please enter only number");
		$(Tval).val('');
		$(".MyTotalFee").parent().show('slow');
		$(".MyTotalFee").parent().addClass('none');
	}
	var MyTotalFee=0,MyTotalpaid=0,MyTotalLeft=0,MyDiscount=0;
	$(".none").each(function(index, element) {
		MyTotalFee+=parseInt($(this).children('.MyTotalFee').html());
		MyTotalpaid+=parseInt($(this).children('.MyTotalpaid').html());
		MyTotalLeft+=parseInt($(this).children('.MyTotalLeft').html());
		MyDiscount+=parseInt($(this).children('.MyDiscount').html());
	});
	$("#MyTotalFee").html(MyTotalFee);
	$("#MyTotalpaid").html(MyTotalpaid);
	$("#MyTotalLeft").html(MyTotalLeft);
	$("#MyDiscount").html(MyDiscount);
}

function filterPay(Tval){
	var val=$(Tval).val();
	if(val.trim()==""){
		$(".MyTotalFee").parent().show('slow');
		$(".MyTotalFee").parent().addClass('none');
		$(".dynamic").hide('slow');
	}
	else
	if(!isNaN(val)){
		$(".dynamic").show('slow');
		var allTot="";
		$(".MyTotalpaid").each(function(index, element) {
			var myVal=parseInt($(this).html());
			if(myVal>val)
			{
				$(this).parent().hide('slow');
				$(this).parent().removeClass('none');
			}
			else
			{
				$(this).parent().show('slow');
				$(this).parent().addClass('none');
			}
        });
		//alert(allTot);
	}
	else{
		alert("Please user only number");
		$(Tval).val('');
		$(".MyTotalFee").parent().show();
		$(".MyTotalFee").parent().addClass('none');
		$(".dynamic").hide();
	}
	var MyTotalFee=0,MyTotalpaid=0,MyTotalLeft=0,MyDiscount=0,MyTotalLeftDynamic=0;
	$(".none").each(function(index, element) {
		var totalleft=val-parseInt($(this).children('.MyTotalpaid').html());
		$(this).children('.MyTotalLeftDynamic').html(totalleft);
		MyTotalFee+=parseInt($(this).children('.MyTotalFee').html());
		MyTotalpaid+=parseInt($(this).children('.MyTotalpaid').html());
		MyTotalLeftDynamic+=parseInt($(this).children('.MyTotalLeftDynamic').html());
		MyTotalLeft+=parseInt($(this).children('.MyTotalLeft').html());
		MyDiscount+=parseInt($(this).children('.MyDiscount').html());
	});
	$("#MyTotalFee").html(MyTotalFee);
	$("#MyTotalpaid").html(MyTotalpaid);
	$("#MyTotalLeftDynamic").html(MyTotalLeftDynamic);
	$("#MyTotalLeft").html(MyTotalLeft);
	$("#MyDiscount").html(MyDiscount);
}
$(document).ready(function(e) {
	$("#btnduesend").click(function () {
		var ch=$("#togglevalueforzeoshow").val();
		if(ch==0){
			$("#togglevalueforzeoshow").val('1');
	   		filterLeftZero(0)
		}else{
			$("#togglevalueforzeoshow").val('0');
			filterLeftZero(1)
		}
	 });
});
function filterLeftZero(ids){
	var allTot="";
	$(".MyTotalLeft").each(function(index, element) {
		var myVal=parseInt($(this).html());
		if(myVal==0 && ids==0)
		{
			$(this).parent().hide('slow');
			$(this).parent().removeClass('none');
		}
		else
		{
			$(this).parent().show('slow');
			$(this).parent().addClass('none');
		}
	});
	//alert(allTot);
	
	var MyTotalFee=0,MyTotalpaid=0,MyTotalLeft=0,MyDiscount=0;
	$(".none").each(function(index, element) {
		MyTotalFee+=parseInt($(this).children('.MyTotalFee').html());
		MyTotalpaid+=parseInt($(this).children('.MyTotalpaid').html());
		MyTotalLeft+=parseInt($(this).children('.MyTotalLeft').html());
		MyDiscount+=parseInt($(this).children('.MyDiscount').html());
	});
	$("#MyTotalFee").html(MyTotalFee);
	$("#MyTotalpaid").html(MyTotalpaid);
	$("#MyTotalLeft").html(MyTotalLeft);
	$("#MyDiscount").html(MyDiscount);
}
</script>
<?php
$pgMod="enquiry_summery";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);

if(isset($_SESSION['msg']) && $_SESSION['msg']!=""){
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0){
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}

	?>
    <form method="get" action="">
    <input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
	<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
                     <fieldset style="width:100%;"><legend>Enquiry Section</legend>
						<button type="submit" name="enquiry" class="btn-classic margin">Enquiry Detail</button>
                        <button type="submit" name="delete_report" class="btn-classic margin">Delete report</button>
                        <button type="submit" name="enquiry_report" class="btn-classic margin">Enquiry Report</button>
                        <button type="submit" name="test_report" class="btn-classic margin">Test Report</button>
                     </fieldset>  
                    
				</div>
				<div class="well no-padding">
                	<div class="controls controls-row">
                        <div class="control-group span3">
                           
                            <div class="controls span3">
                                <select onchange="changeIns()" 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"]==$_GET["class"])echo 'selected';?> value="<?php echo $cla["class"] ?>">
                                                <?php echo $cla["class"] ?>
                                            </option>
                                            <?php
                                        }
                                    ?>
                                </select>
                            </div>
                        </div>
                                             
                    </div>
                    <div class="controls controls-row">
                        <div class="control-group span6">
                            <label class="control-label" for="gender">Gender</label>
                            <div class="controls">
                                <select name="gender" id="gender">
                                    <option value="">All</option>
                                    <option <?php if($_GET["gender"]=="male")echo 'selected="selected"'; ?>  value="male">male</option>
                                    <option <?php if($_GET["gender"]=="female")echo 'selected="selected"'; ?> value="female">female</option>
                                </select>
                            </div>
                        </div>
                        <div class="control-group span6">
                            <label class="control-label" for="age">Age</label>
                            <div class="controls">
                                    <select class="span6" name="startage" id="startage">
                                    	<option value="">Start age</option>
                                        <?php
									    for($m = 1;$m <= 100; $m++){ 
                                            $selected="";if($_GET["startage"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?>
                                    </select>
                                    <select class="span6" name="endage" id="endage">
                                    	<option value="">End age</option>
                                        <?php
									    for($m = 1;$m <= 100; $m++){ 
                                            $selected="";if($_GET["endage"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?>
                                    </select>
                                    
                                </div>
                        </div>
                    </div>
                    <div class="controls controls-row">
                        <div class="control-group span6">
                            <label class="control-label" for="class">From Date</label>
                            <div class="controls">
                                    <select class="span3" name="fdate" id="date">
                                    	<option value="">Date</option>
                                        <?php
									    for($m = 01;$m <= 31; $m++){ 
                                            $selected="";if($_GET["fdate"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?> 
                                    </select>
                                    <select class="span5" name="fmonth" id="fmonth">
                                    	<option value="">Month</option>
                                     <?php
									    for($m = 1;$m <= 12; $m++){ 
											$newDate=date("Y")."-".$m."-1";
											$month =  date("F",strtotime($newDate));//."(".($ij+3).")";
                                            //$month =  date("F", mktime(0, 0, 0, $m)); 
											$selected="";if($_GET["fmonth"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$month</option>";
                                        }
									 ?> 
                                    </select>
                                    <select class="span4" name="fyear" id="fyear">
                                    	<option value="">Year</option>
                                        <?php
									    for($m = 2013;$m <= 2050; $m++){  
                                            $selected="";if($_GET["fyear"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?> 
                                    </select>
                                </div>
                        </div>
                        <div class="control-group span6">
                            <label class="control-label" for="medium">To date</label>
                            <div class="controls">
                                    <select class="span3" name="tdate" id="tdate">
                                    	<option value="">Date</option>
                                        <?php
									    for($m = 01;$m <= 31; $m++){ 
                                             $selected="";if($_GET["tdate"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?> 
                                    </select>
                                    <select class="span5" name="tmonth" id="tmonth">
                                    	<option value="">Month</option>
                                     <?php
									    for($m = 1;$m <= 12; $m++){ 
                                            $newDate=date("Y")."-".$m."-1";
											$month =  date("F",strtotime($newDate));//."(".($ij+3).")";
                                            //$month =  date("F", mktime(0, 0, 0, $m)); 
											$selected="";if($_GET["tmonth"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$month</option>";
                                        }
									 ?> 
                                    </select>
                                    <select class="span4" name="tyear" id="tyear">
                                    	<option value="">Year</option>
                                        <?php
									    for($m = 2013;$m <= 2050; $m++){  
                                             $selected="";if($_GET["tyear"]==$m)$selected=" selected ";
											echo "<option $selected value='$m'>$m</option>";
                                        }
										?> 
                                    </select>
                                </div>
                        </div>
                    </div>
                    <div class="controls controls-row">
                    	<div class="control-group span6">
                            <label class="control-label" for="stype">Student Type</label>
                            <div class="controls">
                                <select name="stype" id="stype">
                                    <option value="">All</option>
                                    <option <?php if($_GET["stype"]=="new")echo 'selected="selected"'; ?>  value="new">New</option>
                                    <option <?php if($_GET["stype"]=="old")echo 'selected="selected"'; ?> value="old">Old</option>
                                </select>
                            </div>
                        </div>
                        <?php 
						if(isset($_GET["other_fix_fee"]) && isset($_GET["class"]) && $_GET["class"]!=""){
							$otherfee=$db->getRows("select * from otherfee_structure where class='".$_GET["class"]."'");
							if(is_array($otherfee) && count($otherfee)>0){ //echo $_GET["optype"];		
								?>
								<div class="control-group span6">
                                    <label class="control-label" for="optype">Otherfee type</label>
                                    <div class="controls">
                                        <select name="optype" id="optype">
                                            <option value="">All</option>
                                            <?php
											foreach($otherfee as $fee){
												?>
												<option value="<?php echo $fee["name"] ?>" <?php if($fee["name"]==$_GET["optype"])echo 'selected';?>><?php echo $fee["name"] ?></option>
												<?php
											}
											?>
                                        </select>
                                    </div>
                                </div>
								<?php
							}
						}
						else{
							$location=$db->getRows("select * from discount_mode where school_id='".$_SESSION["admin"]["school_id"]."'");
							if(is_array($location) && count($location)>0){ //echo $_GET["optype"];		
								?>
								<div class="control-group span6">
                                    <label class="control-label" for="discount_mode">Discount Mode</label>
                                    <div class="controls">
                                        <select name="discount_mode" id="discount_mode">
                                            <option value="">All</option>
                                            <?php
											foreach($location as $loc){
												?>
												<option value="<?php echo $loc["name"] ?>" <?php if($loc["name"]==$_GET["location"])echo 'selected';?>><?php echo $loc["name"] ?></option>
												<?php
											}
											?>
                                        </select>
                                    </div>
                                </div>
								<?php
							}
													
						}
						
						?>
                    </div>
                    <?php $location=$db->getRows("select * from location where school_id='".$_SESSION["admin"]["school_id"]."'");
							if(is_array($location) && count($location)>0){ //echo $_GET["optype"];		
								?>
                                 <div class="controls controls-row">
								<div class="control-group span6">
                                    <label class="control-label" for="location">Location</label>
                                    <div class="controls">
                                        <select name="location" id="location">
                                            <option value="">All</option>
                                            <?php
											foreach($location as $loc){
												?>
												<option value="<?php echo $loc["id"] ?>" <?php if($loc["id"]==$_GET["location"])echo 'selected';?>><?php echo $loc["name"] ?></option>
												<?php
											}
											?>
                                        </select>
                                    </div>
                                </div>
                                </div>
								<?php
							}?>
				</div>
			</div>
    </div>
    </form>
	<?php
	$where=array();
	$qry="";
	
	if(isset($_GET["enquiry"])){
		if(isset($_GET["fyear"]) && trim($_GET["fyear"])!="" && isset($_GET["fmonth"]) && trim($_GET["fmonth"])!="" && isset($_GET["fdate"]) && trim($_GET["fdate"])!="" && isset($_GET["tyear"]) && trim($_GET["tyear"])!="" && isset($_GET["tmonth"]) && trim($_GET["tmonth"])!="" && isset($_GET["tdate"]) && trim($_GET["tdate"])!=""){
			$fdate=$_GET["fyear"]."/".$_GET["fmonth"]."/".$_GET["fdate"];
			$tdate=$_GET["tyear"]."/".$_GET["tmonth"]."/".$_GET["tdate"];
			$where[]=" (s.udate between '$fdate' and '$tdate') ";
		}
		if(isset($_GET["stype"]) && trim($_GET["stype"])!=""){
			$where[]=" s.stype='".$_GET["stype"]."' ";
			$conwhere.=" and student.stype='".$_GET["stype"]."' ";
		}
		if(isset($_GET["medium"]) && trim($_GET["medium"])!=""){
			$where[]=" s.medium='".$_GET["medium"]."' ";
			$conwhere.=" and student.medium='".$_GET["medium"]."' ";
		}
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and student.class='".$_GET["class"]."' ";
		}
		if(isset($_GET["section"]) && $_GET["section"]!=""){
			$where[]=" s.section='".$_GET["section"]."' ";
			$conwhere.=" and student.section='".$_GET["section"]."' ";
		}
		if(isset($_GET["gender"]) && trim($_GET["gender"])!=""){
			$where[]=" s.gender='".$_GET["gender"]."' ";
			$conwhere.=" and student.gender='".$_GET["gender"]."' ";
		}
		if(isset($_GET["cast"]) && trim($_GET["cast"])!=""){
			$where[]=" s.cast='".$_GET["cast"]."' ";
			$conwhere.=" and student.cast='".$_GET["cast"]."' ";
		}
		if(isset($_GET["startage"]) && trim($_GET["startage"])!="" && isset($_GET["endage"]) && trim($_GET["endage"])!=""){
			$start = date('Y-m-d', strtotime('-'.$_GET["startage"].' years'));
			$end = date('Y-m-d', strtotime('-'.$_GET["endage"].' years'));
			$where[]=" (s.dob between '".$end."' and '".$start."')";
			$conwhere.=" and (student.dob between '".$end."' and '".$start."') ";
		}
		if(isset($_GET["location"]) && trim($_GET["location"])!=""){
			$where[]=" s.location='".$_GET["location"]."' ";
			$conwhere.=" and student.location='".$_GET["location"]."' ";
		}
		if(isset($_GET["discount_mode"]) && trim($_GET["discount_mode"])!=""){
			$where[]=" s.discount_mode='".$_GET["discount_mode"]."' ";
			$conwhere.=" and student.discount_mode='".$_GET["discount_mode"]."' ";
		}
		$where[]=" s.session='".$_SESSION["admin"]["session"]."' and s.status=1 ";
		$table=" enquiry as s";
		$result=$db->getRows("SELECT s.* FROM ".$table." where s.school_id='".$_SESSION["admin"]["school_id"]."' and ".implode(" AND ",$where)." order by s.name");
		//echo "<pre>";print_r($result);echo "</pre>";echo $db->getLastQuery();		echo $db->getErMsg();
		?>
		 <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Detail</h3>
                <div style="float:right; margin-top:5px">
                    <button type="button" onclick="printDiv('printDiv2')" class="btn btn-primary">Print</button>
                </div>
            </div>
            <div class="well no-padding" id="printDiv2">
                            	<table class="table">
                    <thead>
                        <tr>
                            <th width="5%">S.No</th>
                            <th>Name</th>
                            <th>Class</th>
                            <th>Father</th> 
                            <th>Mother</th>                    
                            <th>Mobile</th>
                            <th>Address</th>
                            <th>Test Date</th>
                            <th>Test Time</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<?php $full_total=0;
						if(is_array($result) && count($result)>0){$ijk=0;
							foreach($result as $detail){$ijk++;
							
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                                    <td><?php echo ucfirst($detail["name"]); ?></td>
                                    <td><?php echo $detail["class"]; ?></td>
                                    <td><?php echo $detail["fname"]; ?></td>
                                    <td><?php echo $detail["mname"]; ?></td>
                                    <td><?php echo $detail["mobile"]; ?></td>
                                    <td><?php echo $detail["address"]; ?></td>
                                    <td><?php if($detail["test_date"]!="") echo date("d-m-Y",strtotime($detail["test_date"])); ?></td>
                                    <td><?php if($detail["test_time"]!="") echo date("h:s a",strtotime($detail["test_time"])); ?></td>
                                                </tr>
								<?php
							}?>
                           
				<?php }else{
							?><tr>
                            <td colspan="13">No record Found</td>
                            </tr><?php
						}
						?>
                    </tbody>
                    <tfoot>
                    	<tr>
                        	<th colspan="13"></th>
                        </tr>
                    </tfoot>
                 </table>
              </div>
          </div>
		<?php
	}
	elseif(isset($_GET['delete_report'])){
		
		if(isset($_GET["fyear"]) && trim($_GET["fyear"])!="" && isset($_GET["fmonth"]) && trim($_GET["fmonth"])!="" && isset($_GET["fdate"]) && trim($_GET["fdate"])!="" && isset($_GET["tyear"]) && trim($_GET["tyear"])!="" && isset($_GET["tmonth"]) && trim($_GET["tmonth"])!="" && isset($_GET["tdate"]) && trim($_GET["tdate"])!=""){
			$fdate=$_GET["fyear"]."/".$_GET["fmonth"]."/".$_GET["fdate"];
			$tdate=$_GET["tyear"]."/".$_GET["tmonth"]."/".$_GET["tdate"];
			$where[]=" (ch.udate between '$fdate' and '$tdate') ";
		}
		
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
		}
		
		$where[]=" ch.status!='' ";
		$table=" delete_report as ch, enquiry as s";
		$result=$db->getRows("SELECT ch.*,s.class as sclass,s.name,s.fname,s.mname FROM ".$table." where ch.school_id='".$_SESSION["admin"]["school_id"]."' and ch.session='".$_SESSION["admin"]["session"]."' and ch.paytype='enquiry' AND ".implode(" AND ",$where)." group by ch.id order by ch.udate");
		//echo $db->getLastQuery();
		?>
		 <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Detail</h3>
                <div style="float:right; margin-top:5px">
                    <button onclick="printDiv('printDiv')" type="button" class="btn btn-primary">Print</button>
                </div>
            </div>
            <div class="well no-padding" id="printDiv">
            	<table class="table tableSummery" >
                    <thead>
                        <tr>
                            <th>S. No</th>
                            <th>Name</th>
                            <th>Class</th>
                            <th>Father</th>
                            <th>fee</th>
                            <th>Receipt No</th>
                            <th>Amount</th>
                            <th>Type</th>
                            <th>Date</th>
                                                   
                        </tr>
                    </thead>
                    <tbody>
                    	<?php $ollTotal=0;$ijk=0;
						if(is_array($result) && count($result)>0)
						{
							foreach($result as $detail)
							{$ijk++;
							$stu=$db->getRow("Select * from enquiry where idno='".$detail['idno']."' and status =1");
							$ollTotal+=$detail["amount"];
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                                    <td><?php echo ucfirst($stu["name"]); ?></td>
                                    <td><?php echo $stu["class"]; ?></td>
                                    <td><?php echo $stu["fname"]; ?></td>
                                    <td><?php echo $detail["detail"]; ?></td>
                                    <td><?php echo $detail["receipt_id"]; ?></td>     
                                    <td><?php echo $detail["amount"] ?></td>
                                    <td><?php echo $detail["paytype"]; ?></td>
                                    <td><?php echo $detail["udate"]; ?></td>
                                    
                                    
                                </tr>
								<?php
							}
						}
						?>
                    </tbody>
                    <tfoot>
                    <tr>
                    <td colspan="6">Total</td>
                    <td><?php echo $ollTotal;?></td>
                    </tr>
                  </tfoot>  
                 </table>
              </div>
          </div>
          </div>
		<?php
	
	}
	elseif(isset($_GET['enquiry_report'])){
		
		if(isset($_GET["fyear"]) && trim($_GET["fyear"])!="" && isset($_GET["fmonth"]) && trim($_GET["fmonth"])!="" && isset($_GET["fdate"]) && trim($_GET["fdate"])!="" && isset($_GET["tyear"]) && trim($_GET["tyear"])!="" && isset($_GET["tmonth"]) && trim($_GET["tmonth"])!="" && isset($_GET["tdate"]) && trim($_GET["tdate"])!=""){
			$fdate=$_GET["fyear"]."/".$_GET["fmonth"]."/".$_GET["fdate"];
			$tdate=$_GET["tyear"]."/".$_GET["tmonth"]."/".$_GET["tdate"];
			$where[]=" (udate between '$fdate' and '$tdate') ";
		}
		$student=$db->getRows("Select * from enquiry where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
		
		?>
		 <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Detail</h3>
                <div style="float:right; margin-top:5px">
                    <button onclick="printDiv('printDiv')" type="button" class="btn btn-primary">Print</button>
                </div>
            </div>
            <div class="well no-padding" id="printDiv">
            	<table class="table tableSummery" >
                    <thead>
                        <tr>
                            <th>S.No</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th>Mother Name</th>
                            <th>Receipt No</th>
                            <th>Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<?php $ollTotal=0;$ijk=0;
						if(is_array($student) && count($student)>0){
							foreach($student as $s){
								$total=0;$rids=array();	$recno="";						
							$table="transaction";
							$result=$db->getRows("SELECT * FROM ".$table." where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and detail like 'Enquiryfee%' and rid='".$s["idno"]."' AND ".implode(" AND ",$where)." group by id order by udate");
							//echo $db->getLastQuery();
								if(is_array($result) && count($result)>0)
								{
									foreach($result as $detail)
									{
										$total+=$detail["amount"];
										
										$rrde=$db->getVal("select id from enquiry_receipt where session='".$_SESSION["admin"]["session"]."' and school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$s["idno"]."' and rrid like '%".$detail["id"]."%' and paytype='Enquiry' ");
										if($rrde)
											$rids[]=$rrde;
										
									}
									$ollTotal+=$total;
									$rids=array_unique($rids);
									$recno= implode(",",$rids);
								}   
								if($total>0){ $ijk++;?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                                    <td><?php echo $s["name"]; ?></td>
                                    <td><?php echo $s["fname"]; ?></td>
                                    <td><?php echo $s["mname"]; ?></td>
                                    <td><?php echo $recno; ?></td>
                                    <td><?php echo $total ?></td>
                                   
                                </tr>
								<?php }
							}
						}
			
						?>
                    </tbody>
                    <tfoot>
                    <tr>
                    <td colspan="5">Total</td>
                    <td><?php echo $ollTotal;?></td>
                    </tr>
                  </tfoot>  
                 </table>
              </div>
          </div>
          </div>
		<?php
	
	}
	elseif(isset($_GET['test_report'])){
		if(isset($_GET["fyear"]) && trim($_GET["fyear"])!="" && isset($_GET["fmonth"]) && trim($_GET["fmonth"])!="" && isset($_GET["fdate"]) && trim($_GET["fdate"])!="" && isset($_GET["tyear"]) && trim($_GET["tyear"])!="" && isset($_GET["tmonth"]) && trim($_GET["tmonth"])!="" && isset($_GET["tdate"]) && trim($_GET["tdate"])!=""){
			$fdate=$_GET["fyear"]."-".date("m",strtotime($_GET["fmonth"]))."-".$_GET["fdate"];
			$tdate=$_GET["tyear"]."-".date("m",strtotime($_GET["tmonth"]))."-".$_GET["tdate"];
			$where[]=" (s.test_date between '$fdate' and '$tdate') ";
		}
		if(isset($_GET["stype"]) && trim($_GET["stype"])!=""){
			$where[]=" s.stype='".$_GET["stype"]."' ";
			$conwhere.=" and student.stype='".$_GET["stype"]."' ";
		}
		if(isset($_GET["medium"]) && trim($_GET["medium"])!=""){
			$where[]=" s.medium='".$_GET["medium"]."' ";
			$conwhere.=" and student.medium='".$_GET["medium"]."' ";
		}
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and student.class='".$_GET["class"]."' ";
		}
		if(isset($_GET["section"]) && $_GET["section"]!=""){
			$where[]=" s.section='".$_GET["section"]."' ";
			$conwhere.=" and student.section='".$_GET["section"]."' ";
		}
		if(isset($_GET["gender"]) && trim($_GET["gender"])!=""){
			$where[]=" s.gender='".$_GET["gender"]."' ";
			$conwhere.=" and student.gender='".$_GET["gender"]."' ";
		}
		if(isset($_GET["cast"]) && trim($_GET["cast"])!=""){
			$where[]=" s.cast='".$_GET["cast"]."' ";
			$conwhere.=" and student.cast='".$_GET["cast"]."' ";
		}
		if(isset($_GET["startage"]) && trim($_GET["startage"])!="" && isset($_GET["endage"]) && trim($_GET["endage"])!=""){
			$start = date('Y-m-d', strtotime('-'.$_GET["startage"].' years'));
			$end = date('Y-m-d', strtotime('-'.$_GET["endage"].' years'));
			$where[]=" (s.dob between '".$end."' and '".$start."')";
			$conwhere.=" and (student.dob between '".$end."' and '".$start."') ";
		}
		if(isset($_GET["location"]) && trim($_GET["location"])!=""){
			$where[]=" s.location='".$_GET["location"]."' ";
			$conwhere.=" and student.location='".$_GET["location"]."' ";
		}
		if(isset($_GET["discount_mode"]) && trim($_GET["discount_mode"])!=""){
			$where[]=" s.discount_mode='".$_GET["discount_mode"]."' ";
			$conwhere.=" and student.discount_mode='".$_GET["discount_mode"]."' ";
		}
		//$where[]=" s.session='".$_SESSION["admin"]["session"]."' and s.status=1 ";
		$table=" enquiry as s";
		$result=$db->getRows("SELECT s.* FROM ".$table." where s.school_id='".$_SESSION["admin"]["school_id"]."' and ".implode(" AND ",$where)." and s.status=1 order by s.name");
		//echo "<pre>";print_r($result);echo "</pre>";echo $db->getLastQuery();		echo $db->getErMsg();
		?>
		 <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Detail</h3>
                <div style="float:right; margin-top:5px">
                    <button type="button" onclick="printDiv('printDiv2')" class="btn btn-primary">Print</button>
                </div>
            </div>
            <div class="well no-padding" id="printDiv2">
                            	<table class="table">
                    <thead>
                        <tr>
                            <th width="5%">S.No</th>
                            <th>Name</th>
                            <th>Class</th>
                            <th>Father</th> 
                            <th>Mother</th>                    
                            <th>Mobile</th>
                            <th>Address</th>
                            <th>Test Date</th>
                            <th>Test Time</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<?php $full_total=0;
						if(is_array($result) && count($result)>0){$ijk=0;
							foreach($result as $detail){$ijk++;
							
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                                    <td><?php echo ucfirst($detail["name"]); ?></td>
                                    <td><?php echo $detail["class"]; ?></td>
                                    <td><?php echo $detail["fname"]; ?></td>
                                    <td><?php echo $detail["mname"]; ?></td>
                                    <td><?php echo $detail["mobile"]; ?></td>
                                    <td><?php echo $detail["address"]; ?></td>
                                    <td><?php if($aryForm["test_date"]!="")  echo date("d-m-Y",strtotime($detail["test_date"])); ?></td>
                                    <td><?php if($aryForm["test_time"]!="")  echo date("h:s a",strtotime($detail["test_time"])); ?></td>
                                                </tr>
								<?php
							}?>
                           
				<?php }else{
							?><tr>
                            <td colspan="13">No record Found</td>
                            </tr><?php
						}
						?>
                    </tbody>
                    <tfoot>
                    	<tr>
                        	<th colspan="13"></th>
                        </tr>
                    </tfoot>
                 </table>
              </div>
          </div>
		<?php
	
	}
	//echo "<pre>";print_r($result);echo $db->getLastQuery();
	echo $db->getErMsg();
	
?>

	<script type="text/javascript">
	$(document).ready(function(e) {
		var oTable = $('.table').dataTable( {
			"bPaginate": false,
			"bLengthChange": false,
			"bFilter": true,
			"bSort": true,
			"bInfo": true,
			"bAutoWidth": false
		});
	});
	function activeNowMe(id){
		$.ajax({
			url: "<?php echo URL_ROOT ?>Promote/ajax.php?type=activeMe&id="+id
		}).done(function(data) {
			$("#row"+id).hide("slow");
		});
	}
	function getStudentPopup(){
		var url="";
		$(".checkboxes").each(function(){
			if($(this).prop('checked')==true){
				var idno=$(this).val();
				var name=$(".name"+idno).html()
				var left=$(".left"+idno).html()
				url+="&"+name+"`"+idno+"="+left;
			}
		})
		if(url!=""){
			getPopup("<?php echo URL_ROOT ?>Promote/?page_id=MigrateLeftFee&class=<?php echo $_GET["class"] ?>"+url,"1","MigrateLeftFee");
			$(".close").click(function() {
				$(this).parent().remove();
			});
			$(".outer").click(function() {
				$(this).remove();
			});

		}else{
			alert("select atleast one student to mgrate");
		}
	}
	</script>
    <style>
    tfoot{display: table-footer-group !important;}
	.MigrateLeftFee{width:650px !important}
    </style>