<script type="text/javascript" src="js/tableExport.js"></script>

<script type="text/javascript" src="js/jquery.base64.js"></script>

<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 ids=document.getElementsByName('idno[]');
	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="book_summery";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);
if($pgAct=="delete" && isset($_GET['id']) && trim($_GET['id'])!='')
{
	$res=$db->delete("student","where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET['id']."'");
	if(!is_null($res)) { $_SESSION['msg']='Deleted Successfully'; }
	else { array_push($alert_err,$db->getErMsg()); }
	redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Library", "page_id"=>$pgMod)));
}
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="src" value="Library" />
    <input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
	<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
                    <br />
                   
                    <fieldset style="width:48%; float:left"><legend>Detail Section</legend>
						<button type="submit" name="detail" class="btn-classic margin"> Book Detail</button>
						 <button type="submit" name="issuesbook" class="btn-classic margin">Issue Book </button>
						  <button type="submit" name="returnsbook" class="btn-classic margin">Return Book </button>
						 	 <button type="submit" name="finebook" class="btn-classic margin"> Book Fine </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 class="control-group span3">
                           
                            <div class="controls span3">
                               <select 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 <?php if($cla["name"]==$_GET["section"])echo 'selected';?> value="<?php echo $cla["name"] ?>">
                            <?php echo $cla["name"] ?>
                        </option>
                        <?php
            
                    }
                ?>
            </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>
			</div>
    </div>
    </form>
	<?php
	$where=array();
	$qry="";
	
	if(isset($_GET["detail"])){
		
		
		$conwhere="";
		
		
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and class='".$_GET["class"]."' ";
		}
		if(isset($_GET["section"]) && $_GET["section"]!=""){
			$where[]=" s.section='".$_GET["section"]."' ";
			$conwhere.=" and student.section='".$_GET["section"]."' ";
		}
		
		
		
	//	$where[]=" rr.idno=s.idno and s.session='".$_SESSION["admin"]["session"]."' and (rr.type='fee' or rr.type='busfee' or rr.type='hostelfee' or rr.type like 'extrafee%') and s.status=1 ";
	//	$table=" reff_receipt as rr, student as s";
		//$result=$db->getRows("select * from book where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
		//echo "<pre>";print_r($result);echo "</pre>";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>Serial No</th>
                    <th>Title</th>
                    <th>Class</th>
                      <th>Book Author</th>
                        <th>No of Page</th>
                          <th>Edition</th>
                    <th>Publisher</th>
                    <th>Category</th>
                    <th>No of Copy</th>
                     <th>Volume</th>
                      <th>Class No</th>
                       <th>ISBN No</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                    	<?php 
                 
						$result=$db->getRows("select * from book where school_id='".$_SESSION["admin"]["school_id"]."' $conwhere and status=1");
						//echo $db->getErMsg().$db->getLastQuery();
						if(is_array($result) && count($result)>0){
							foreach($result as $detail){$ijk++;
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                    <td><?php echo $detail["title"] ?></td>
                   
                    <td><?php echo $detail["class"] ?></td>
                     <td><?php echo $detail["auther"] ?></td>
                      <td><?php echo $detail["noofpage"] ?></td>
                    <td><?php echo $detail["edition"] ?></td>
                     <td><?php echo $detail["pname"] ?></td>
                    <td><?php echo $detail["category"] ?></td>
                    <td><?php echo $detail["nocopy"] ?></td>
                     <td><?php echo $detail["volume"] ?></td>
                      <td><?php echo $detail["classno"] ?></td>
                       <td><?php echo $detail["isbn_no"] ?></td>
                       
                                    
                                </tr>
								<?php
							}
						}
						
						?>
                        
                    </tbody>
                    
                 </table>
              </div>
          </div>
          </div>
		<?php
	}
	
	
	
		elseif(isset($_GET["finebook"])){
		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') ";
			$conwhere.=" and  (s.rdate between '$fdate' and '$tdate') ";
		}
	
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and b.class='".$_GET["class"]."' ";
		}
	
	
	
		$where[]=" s.session='".$_SESSION["admin"]["session"]."' and s.status=1 ";
		$table=" student as s";
	//	$result=$db->getRows("SELECT s.* FROM ".$table." where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.issue_TC=0 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 tableSummery" >
                    <thead>
                        <tr>
                            <th>Serial No</th>
                             <th>Student Name</th>
                    <th>Title</th>
                    <th>Class</th>
                      <th>Book Author</th>
                       
                          <th>Edition</th>
                    <th>Publisher</th>
                   
                     <th>Volume</th>
                    
                       <th>ISBN No</th>
                        <th>Fine</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                    	<?php 
                    	
						$result=$db->getRows("select b.title,b.class,b.auther,b.edition,b.volume,b.classno,b.isbn_no,s.sid,s.bid,s.fine,p.name from book as b inner join issueBook as s on b.idno=s.bid inner join student as p on p.idno=s.sid where s.school_id='".$_SESSION["admin"]["school_id"]."' $conwhere and s.fine!=0");
						
				//	echo $ss="select b.title,b.class,b.auther,b.edition,b.volume,b.classno,b.isbn_no,s.sid,s.bid from book as b inner join issueBook as s on b.idno=s.bid where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.fine!=0";	
						//echo $db->getErMsg().$db->getLastQuery();
						if(is_array($result) && count($result)>0){
							foreach($result as $detail){$ijk++;
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                                     <td><?php echo $detail["name"] ?></td>
                    <td><?php echo $detail["title"] ?></td>
                   
                    <td><?php echo $detail["class"] ?></td>
                     <td><?php echo $detail["auther"] ?></td>
                   
                    <td><?php echo $detail["edition"] ?></td>
                     <td><?php echo $detail["pname"] ?></td>
                   
                     <td><?php echo $detail["volume"] ?></td>
                    
                       <td><?php echo $detail["isbn_no"] ?></td>
                        <td><?php echo $detail["fine"] ?></td>
                       
                                    
                                </tr>
								<?php
								
							$totalfineval+=$detail["fine"];
							}
						}
						
						?>
                        
                    </tbody>
                   <tfoot>
                    	<tr style="border-top:1px solid #F00; color:#F00">
                        	<td colspan="7">Total Fine</td><td></td><td></td><td id="completeFeeShw"><?php echo  $totalfineval; ?></td><td></td>
                        </tr>
                    </tfoot>
                 </table>
              </div>
          </div>
		<?php
	}
	
	

	
	
	

	
	elseif(isset($_GET["issuesbook"])){
			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') ";
			$conwhere.=" and  (s.idate between '$fdate' and '$tdate') ";
		}
		
	
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and b.class='".$_GET["class"]."' ";
		}
		
	
	
		
		$where[]=" s.session='".$_SESSION["admin"]["session"]."' and s.status=1 ";
		$table=" student as s";
		$result=$db->getRows("SELECT s.* FROM ".$table." where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.issue_TC=0 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 tableSummery" >
                    <thead>
                        <tr>
                            <th>Serial No</th>
                    <th>Title</th>
                    <th>Class</th>
                      <th>Book Author</th>
                       
                          <th>Edition</th>
                    <th>Publisher</th>
                   
                     <th>Volume</th>
                      <th>Class No</th>
                       <th>ISBN No</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                    	<?php 
						$result=$db->getRows("select b.title,b.class,b.auther,b.edition,b.pname,b.volume,b.classno,b.isbn_no,s.sid,s.bid from book as b inner join issueBook as s on b.idno=s.bid where s.school_id='".$_SESSION["admin"]["school_id"]."' $conwhere and s.status=0");
						
				//	echo $ss="select b.title,b.class,b.auther,b.edition,b.volume,b.classno,b.isbn_no,s.sid,s.bid from book as b inner join issueBook as s on b.idno=s.bid where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.status=0";	
						//echo $db->getErMsg().$db->getLastQuery();
						if(is_array($result) && count($result)>0){
							foreach($result as $detail){$ijk++;
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                    <td><?php echo $detail["title"] ?></td>
                   
                    <td><?php echo $detail["class"] ?></td>
                     <td><?php echo $detail["auther"] ?></td>
                   
                    <td><?php echo $detail["edition"] ?></td>
                     <td><?php echo $detail["pname"] ?></td>
                   
                     <td><?php echo $detail["volume"] ?></td>
                      <td><?php echo $detail["classno"] ?></td>
                       <td><?php echo $detail["isbn_no"] ?></td>
                       
                                    
                                </tr>
								<?php
							}
						}
						
						?>
                        
                    </tbody>
                    
                 </table>
              </div>
          </div>
		<?php
	}
	
	
	
	elseif(isset($_GET["returnsbook"])){
			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') ";
			$conwhere.=" and  (s.rdate between '$fdate' and '$tdate') ";
		}
		
	
		if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where[]=" s.class='".$_GET["class"]."' ";
			$conwhere.=" and b.class='".$_GET["class"]."' ";
		}
		
	
	
		
		$where[]=" s.session='".$_SESSION["admin"]["session"]."' and s.status=1 ";
		$table=" student as s";
		$result=$db->getRows("SELECT s.* FROM ".$table." where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.issue_TC=0 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 tableSummery" >
                    <thead>
                        <tr>
                            <th>Serial No</th>
                    <th>Title</th>
                    <th>Class</th>
                      <th>Book Author</th>
                       
                          <th>Edition</th>
                    <th>Publisher</th>
                   
                     <th>Volume</th>
                      <th>Class No</th>
                       <th>ISBN No</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                    	<?php 
						$result=$db->getRows("select b.title,b.class,b.auther,b.edition,b.pname,b.volume,b.classno,b.isbn_no,s.sid,s.bid from book as b inner join issueBook as s on b.idno=s.bid where s.school_id='".$_SESSION["admin"]["school_id"]."' $conwhere and s.status=0");
						
				//	echo $ss="select b.title,b.class,b.auther,b.edition,b.volume,b.classno,b.isbn_no,s.sid,s.bid from book as b inner join issueBook as s on b.idno=s.bid where s.school_id='".$_SESSION["admin"]["school_id"]."' and s.status=0";	
						//echo $db->getErMsg().$db->getLastQuery();
						if(is_array($result) && count($result)>0){
							foreach($result as $detail){$ijk++;
								?>
                                <tr>
                                    <td><?php echo $ijk; ?></td>
                    <td><?php echo $detail["title"] ?></td>
                   
                    <td><?php echo $detail["class"] ?></td>
                     <td><?php echo $detail["auther"] ?></td>
                   
                    <td><?php echo $detail["edition"] ?></td>
                     <td><?php echo $detail["pname"] ?></td>
                   
                     <td><?php echo $detail["volume"] ?></td>
                      <td><?php echo $detail["classno"] ?></td>
                       <td><?php echo $detail["isbn_no"] ?></td>
                       
                                    
                                </tr>
								<?php
							}
						}
						
						?>
                        
                    </tbody>
                    
                 </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>