<?php 
$pgMod="feediscount";
$pgAct="view";
$monthsList = array(
    1=>'Apr',
    2=>'May',
    3=>'Jun',
    4=>'Jul ',
    5=>'Aug',
    6=>'Sep',
    7=>'Oct',
    8=>'Nov',
    9=>'Dec',
	10=>'Jan',
    11=>'Feb',
    12=>'Mar'
);

unset($_SESSION["recept"]);
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);


if($pgAct=="viewall"){
	global $db,$LinksDetails;
	$pgTable = "student";
	$dataAry = array();
	$sqlArray = array();
	$i = 0;
	$table = "";
	$select = "";
	$where = "";
	$whereAry = array();
	
	$whereAry[] = " school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and status=1 and issue_TC=0";
	if (isset($_REQUEST["class"]) && $_REQUEST["class"] != "") {
		$whereAry[] = " class='".$_REQUEST["class"]."' ";
	}
	if(isset($_REQUEST["section"]) && $_REQUEST["section"]!="" && $_REQUEST["section"]!="undefined"){
		$whereAry[] = " section='".$_REQUEST["section"]."' ";
	}
	if (isset($_REQUEST["q"]) && $_REQUEST["q"] != "") {
		$whereAry[] = " (admissionno like '%".$_REQUEST["q"]."%'
					OR name like '%".$_REQUEST["q"]."%'
					OR class like '%".$_REQUEST["q"]."%'
					OR section like '%".$_REQUEST["q"]."%'
					OR medium like '%".$_REQUEST["q"]."%'
					OR cast like '%".$_REQUEST["q"]."%'
					OR fname like '%".$_REQUEST["q"]."%'
					OR mobile like '%".$_REQUEST["q"]."%') ";
	}
	
	if (is_array($whereAry) && count($whereAry) > 0)
		$where = " WHERE " . implode(" AND ", $whereAry);
		
	$pcount = $db->getVal("select count(admissionno) from  student $where");

	$startV = $_REQUEST['startV'];
	$endV = $_REQUEST['endV'];
	$ProDetail["totPost"] = $pcount;

	$contentDetail = $db->getRows("select * from student $where order by name DESC " . ($endV == 'All' ? "" : "limit $startV, $endV"));
	$ProDetail["query"] = $db->getLastQuery();
	$ProDetail["ncount"] = count($contentDetail);
	$ProDetail["tcolumn"] = 9;
	if (is_array($contentDetail) && count($contentDetail) > 0) {
		$aryData = array();
		$i = 0;
		foreach ($contentDetail as $iList) {
			$button = "";
// 			$aryPgAct["id"] = $iList['id'];
			$aryPgAct["src"] = "Promote";
			$aryPgAct["page_id"] = $pgMod;
			$image="<img src='".URL_ROOT."uploads/product/50/50/".$iList['front_image']."' width='50'  />";
			$button = "";
		
		
			$aryPgAct["action"] = "add";
			//$button .= '<a href="javascript:;" onclick="del(\''.URL_ADMIN_HOME.getQueryString($aryPgAct).'&id='.$iList['idno'].'\')" class="confirmation"><button type="button" class="btn btn-danger">Delete</button></a>';
			$button .= '<a href="'.URL_ADMIN_HOME.getQueryString($aryPgAct).'&action=add&id='.$iList['idno'].'"><button type="button" class="btn btn-info">Discount</button></a>';
			$aryPgAct['action']="back_dues";
		//	$button.='<a href=\'#\' onclick=\"backdue(\''.$iList['idno'].'\',\''.$iList['class'].'\')\"><button type=\'button\' class=\'btn btn-info\'>Back Dues</button></a>';
			$button .= '<a href="javascript:;" onclick="backdue(\''.URL_ADMIN_HOME.getQueryString($aryPgAct).'&id='.$iList['idno'].'\')" class="confirmation"><button type="button" class="btn btn-info">Back Dues</button></a>';

			$i++;
			//$aryPgAct["action"] = "submenu";
			$aryData[] = array(
				POST($iList['admissionno']),
				POST($iList['name']),
				POST($iList['class'])."(".POST($iList['section']).")",
				POST($iList['medium']),
			
				POST($iList["cast"]),
				POST($iList['fname']),
			
				$button,
			);
		}
		$ProDetail["Result"] = $aryData;
	}
	echo json_encode($ProDetail);
	exit;
}








		
elseif(isset($_GET["id"]) && $_GET["id"]!=""){
	$insTall=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."'");
	if(is_array($insTall) && count($insTall)>0){
	
	}else{
		if(!isset($_GET["dis"]) || $_GET["dis"]=="" || $_GET["dis"]=="NULL"){
		?>
		<script>
			var dis=prompt("Please Enter Tusion Fee Discount",0);
			var queryStr='&dis='+dis;
        <?php
		$installDetail=$db->getRow("select * from bus where school_id='".$_SESSION["admin"]["school_id"]."' and id=(select bus from student where idno=(SELECT is_root FROM `session_idno` where idno='".$_GET["id"]."' limit 0,1))");
		if(count($installDetail)>0){
			?>
				var busdis=prompt("Please Enter Bus Fee Discount",0);
				queryStr=queryStr+'&bus='+busdis;
			<?php
		}
		//echo $db->getLastQuery();		exit;
		?>
		window.location='?page_id=feediscount&action=add&id=<?php echo $_GET["id"] ?>'+queryStr;</script>
        <?php
		exit;	
		}
		$insAry=array(	"idno"=>$_GET["id"],
						"session"=>$_SESSION["admin"]["session"],
						"discount"=>$_GET["dis"],
						"busdiscount"=>$_GET["bus"]
		    );
		$total=0;
		$installDetail=$db->getRow("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and class=(select class from student where idno='".$_GET["id"]."')");
		if(is_array($installDetail) && count($installDetail)>0)
		{
			$devidedFee=(int)($installDetail["fee"]-$_GET["dis"])/(int)$installDetail["installment"];
			for($i=1; $i<=$installDetail["installment"]; $i++){
				$total=$total+$devidedFee;
				$insAry["i".$i]=$devidedFee;
			}
			$insAry["total"]=$total;
		}else{
			echo "Class May Be delete or remove From database, Please re allocate class to this student<br />
			<br />
			Click <a href='?page_id=feediscount'>here</a> to ho back<br />
			".$db->getLastQuery().$db->getErMsg();
			exit;
		}
		$total=0;
		$installDetail=$db->getRow("select * from bus where school_id='".$_SESSION["admin"]["school_id"]."' and id=(select bus from student where idno=(SELECT is_root FROM `session_idno` where idno='".$_GET["id"]."' limit 0,1))");
		if(is_array($installDetail) && count($installDetail)>0)
		{
			$devidedFee=(int)($installDetail["fee"]-$_GET["bus"])/(int)$installDetail["installment"];
			for($i=1; $i<=$installDetail["installment"]; $i++){
				$insAry["b".$i]=$devidedFee;
				$total=$total+$devidedFee;
			}
			$insAry["bus"]=$total;
			//$db->insertAry("installment",$insAry);
		}
		$insAry["school_id"]=$_SESSION["admin"]["school_id"];
$insAry["added_by"]=$_SESSION["admin"]["uid"];
		$db->insertAry("installment",$insAry);echo $db->getErMsg();
		//echo "<pre>";print_r($insAry);echo "</pre>";
	}
}
	
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
}
if($pgAct=="add" && isset($_GET['id']) && trim($_GET['id']) !='')
{ 
	if(isset($_SESSION['form']))
	{
		$aryForm=$_SESSION['form'];
		unset($_SESSION['form']);
	}
	$aryForm=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET['id']."'");
	
	
?>
<style>
.st {
	width: 55px;
	display: inline-block;
	color: #021EF0;
}
.recepit {
	width: 717px !important;
	height: 344px !important;
}
.half {
	width: 49%;
	display: inline-block;
	vertical-align: top;
	border-left: 5px solid #f00;
border-right: 5px solid #f00;
}
.half .input-block-level {
	width: 80px;
}
.half .table td {
	padding: 3px 5px;
}
.half center {
	font-weight: bold;
	border-top: 1px solid #f00;
	padding: 5px;
	background-color: #A7A1A1;
	color: #000;
}
</style>
<!-- Forms --> 
<div id="printDiv">		
     <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Student detail</h3>
                <div style="float:right; margin-top:5px;">
				<a>
                     <a href="print/?page_id=change_class&id=<?php echo $_GET["id"] ?>" class="btn btn-danger fancybox">Change Class</a>
                    <a href="javascript:;" onclick="checkRecept('<?php echo $aryForm["class"]; ?>')" class="btn btn-danger">Recepit</a>
                    
                     <a>
                    <button type="button" onclick="checkRecept('<?php echo $aryForm["class"]; ?>')" class="btn btn-danger">Reset Discount</button></a>
                </div>
            </div>
            <div class="well" style="padding: 0;margin: 0;">
            	<table class="table">
                	<tr style="border-right: 5px solid #f00;border-left: 5px solid #f00;">
                    	<td><strong class="st">Name</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["name"] ?></td>
                        <td><strong class="st">Class</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["class"] ?></td>
                        <td><strong class="st">id no</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["idno"] ?></td>
                        <td><strong class="st">Medium</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["medium"] ?></td>
                        <td rowspan="2"><?php if($aryForm["photo"]!=""){
                        ?><img src="media/photo/<?php echo $aryForm["photo"]; ?>" style="height:70px" /><?php
                    }else{
                        echo "No photo uploaded";
                    }?></td>
                    </tr>
                    <tr style="border-right: 5px solid #f00;border-left: 5px solid #f00;">
                    	<td><strong class="st">DOB</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["dob"] ?></td>
                        <td><strong class="st">Father</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["fname"] ?></td>
                        <td><strong class="st">DOA</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["doa"] ?></td>
                        <td><strong class="st">Contact</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["mobile"] ?></li></td>
                    </tr>
                </table>
            </div>
        </div>
     </div> 
     <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Payment detail</h3>
                <div style="float:right; margin-top:5px">
                    <button type="button" class="btn btn-primary hide" onclick="if(confirm('Do you want to Pay compleet fee'))competeFee()">Complete fee</button>
                </div>
            </div>
            <div class="well no-padding">
                 
             	<div class="half"><center>Tution fee</center>
            	<table class="table">
                	
                    <thead>
                        <tr>
                            <th style="color:#FFF">Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php 
						$aryInstall=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and session='".$_SESSION["admin"]["session"]."'");
						/* echo "<pre>";
						print_r($aryInstall);  */
						$feeCount=array();$totalclasspayfee=0;$totalbuspayfee=0;$busFine=0;$schoolFine=0;
						for($i=1;$i<=12;$i++){
							$iis="i".$i;
							$iip="ip".$i;
							if($aryInstall[$iis]!="" && $aryInstall[$iis]!=0){
								$totalclasspayfee=$totalclasspayfee+$aryInstall[$iip];
								$is_rr=false;
							?>
                            <tr>
                            	
                                <td><?php $ij=$i;
						  if($ij<=9){
							$newDate=date("Y")."-".($ij+3)."-1";
							echo date("F",strtotime($newDate));//."(".($ij+3).")";
						  }
						  else{
							$newDate=date("Y")."-".($ij-9)."-1";
							echo date("F",strtotime($newDate));//."(".($ij-9).")";
						  } ?></td>
              				<!--	<td>School Fee inst. <?php echo $i;?></td>-->
                                <td><input type="text" id="fee<?php echo $i ?>" class="input-block-level" oldValue value="<?php echo $aryInstall[$iis]; ?>"  name="fee[]"></td>
                                <td><input readonly="readonly" type="text" id="given<?php echo $i ?>" class="input-block-level" value="<?php echo $aryInstall[$iip]; ?>" <?php if($aryInstall[$iip]>0)echo 'readonly="readonly"'; ?> name="given[]"></td>
                                <td><?php if($aryInstall[$iip]>0)echo '<font color="#009900">Paid</font>';else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="classtd">
								<?php
								if($aryInstall[$iip]>0){}else{
								?><a href="javascript:;" onClick="updateFee('<?php echo $i ?>','<?php echo $aryInstall[$iis]; ?>','<?php echo $aryInstall["total"]?>','<?php echo $aryInstall["discount"]?>','fee')">
								<button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetFee('<?php echo $i ?>','<?php echo $aryInstall[$iis] ?>','fee')"><button type="button" class="btn btn-default">Reset fee</button></a>
								<?php	
								}
								?></td>
                                <td></td>
                            </tr>
							<?php
							}
						}
					?>
					</tbody>
                </table>
                </div>
                <?php if($aryForm["bus"]!=""){ ?>
                <div  class="half">
                <center>Transport fee</center>
                <table class="table">
                    <thead>
                        <tr>
                            <th>Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
					<?php
						$ji=0;
						for($i=1;$i<=12;$i++){
							$iis="b".$i;
							$iip="bp".$i;$is_rr=false;
							if($aryInstall[$iis]!="" && $aryInstall[$iis]!=0){
								$totalbuspayfee=$totalbuspayfee+$aryInstall[$iip];$ji++;
							$is_rr=false;
							?>
                            <tr <?php if($ji==1)echo 'class="first" style="border-top:2px solid #F00"'; ?>>
                            	<td><?php $ij1=$i;
									  if($ij1<=9){
										$newDate=date("Y")."-".($ij1+3)."-1";
										echo date("F",strtotime($newDate));//."(".($ij+3).")";
									  }
									  else{
										$newDate=date("Y")."-".($ij1-9)."-1";
										echo date("F",strtotime($newDate));//."(".($ij-9).")";
									  } ?></td>
                                <!--<td>Bus Fee inst. <?php echo $i ?></td>-->
                                <td><input type="text" id="busfee<?php echo $i ?>" class="input-block-level" value="<?php echo $aryInstall[$iis]; ?>"  name="busfee[]"></td>
                                <td><input readonly="readonly" type="text" id="busgiven<?php echo $i ?>" class="input-block-level" value="<?php echo $aryInstall[$iip]; ?>" <?php if($aryInstall[$iip]>0)echo 'readonly="readonly"'; ?> name="busgiven[]"></td>
                               
                                <td><?php 
								if($aryInstall[$iip]>0)echo '<font color="#009900">Paid</font>';
								else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="bustd">
                                <?php
								if($aryInstall[$iip]>0){}else{
								?><a href="javascript:;" onClick="updateFee('<?php echo $i ?>','<?php echo $aryInstall[$iis]; ?>','<?php echo $aryInstall["bus"]?>','<?php echo $aryInstall["busdiscount"]?>','busfee')">
                                <button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetFee('<?php echo $i ?>','<?php echo $aryInstall[$iis] ?>','busfee')"><button type="button" class="btn btn-default">Reset fee</button></a><?php	
								}
								?>
                                </td>
                                <td></td>
                            </tr>
							<?php
							}
						}
					?>
                    </tbody>
                </table>
                </div>
                <?php } ?>
                <?php 
					$checkhostelFee=$db->getVal("select id from hostelinstallment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."'");	
					
					
					if($checkhostelFee){
						?>
                        <div  class="half">
                        <center>Hostel fee</center>
                        <table class="table">
                	
                    <thead>
                        
                        <tr>
                            <th style="color:#FFF">Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php 
						$aryHostelInstall=$db->getRow("select * from hostelinstallment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and session='".$_SESSION["admin"]["session"]."'");
						/*  echo "<pre>";
						print_r($aryHostelInstall);  */  
						$hostelfeeCount=array();$totalhostelpayfee=0;$hostelFine=0;
						for($i=1;$i<=12;$i++){
							$iis="i".$i;
							$iip="ip".$i;$is_rr=false;
							//echo $iip;
							if($aryHostelInstall[$iis]!="" && $aryHostelInstall[$iis]!=0){
								$totalhostelpayfee=$totalhostelpayfee+$aryHostelInstall[$iip];$ji++;
								$is_rr=false;
							?>
                            <tr <?php if($ji==1)echo 'class="first" style="border-top:2px solid #F00"'; ?>>
                            	<td><?php $ij1=$i;
									  if($ij1<=9){
										$newDate=date("Y")."-".($ij1+3)."-1";
										echo date("F",strtotime($newDate));//."(".($ij+3).")";
									  }
									  else{
										$newDate=date("Y")."-".($ij1-9)."-1";
										echo date("F",strtotime($newDate));//."(".($ij-9).")";
									  } ?></td>
                                <!--<td>hostel Fee inst. <?php echo $i ?></td>-->
                                <td><input type="text" id="hostelfee<?php echo $i ?>" class="input-block-level" value="<?php echo $aryHostelInstall[$iis]; ?>"  name="hostelfee[]"></td>
                                <td><input readonly="readonly" type="text" id="hostelgiven<?php echo $i ?>" class="input-block-level" value="<?php echo $aryHostelInstall[$iip]; ?>" <?php if($aryHostelInstall[$iip]>0)echo 'readonly="readonly"'; ?> name="hostelgiven[]"></td>
                                
                                
                                <td><?php 
								if($aryHostelInstall[$iip]>0)echo '<font color="#009900">Paid</font>';
								else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="hosteltd"><?php
								if($aryHostelInstall[$iip]>0){}else{
								?><a href="javascript:;" onClick="updateFee('<?php echo $i ?>','<?php echo $aryHostelInstall[$iis]; ?>','<?php echo $aryHostelInstall["total"]?>','<?php echo $aryHostelInstall["discount"]?>','hostelfee')">
                                <button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetFee('<?php echo $i ?>','<?php echo $aryHostelInstall[$iis] ?>','hostelfee')"><button type="button" class="btn btn-default">Reset fee</button></a><?php	
								}
								?></td>
                                <td></td>
                            </tr>
							<?php
							}
						}
					?>
					</tbody>
                </table>
                        </div>
                		<?php
					}
				?>
								
<!-- nitish code start-->
				
				 <?php $extrafeeFine=0;
					$checkextFee=$db->getRows("select * from extrafee_type where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$aryForm["class"]."'");	
					
					
					  // echo "<pre>";
					//print_r($checkextFee);   

					
					if(is_array($checkextFee) && count($checkextFee)>0){
						foreach($checkextFee as $chkExtFee){
							//$mycheckInstall=$db->getRows("select * from extrafee where idno='".$_GET["id"]."' and type='".$chkExtFee["id"]."'");
							$mycheckInstall=$db->getRows("select * from extrafee where idno='".$_GET["id"]."' and type='".$chkExtFee["id"]."'");
							
				 		 /*  echo "<pre>";
					print_r($mycheckInstall);  */ 
				
							if(is_array($mycheckInstall) && count($mycheckInstall)>0){
									//echo 333;
						?>
                        <div  class="half">
                        <center><?php  echo $chkExtFee["type"];?></center>
                        <table class="table">               	
                    <thead>                       
                        <tr>
                            <th style="color:#FFF">Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php 
						foreach($mycheckInstall as $myinstall){
							
							
							$fine="";
							?>
							<tr><td><?php $ipi=ltrim ($myinstall["pid"], 'p');
							if($ipi<=9){
										$newDate=date("Y")."-".($ipi+3)."-1";
										echo date("F",strtotime($newDate));//."(".($ij+3).")";
									  }
									  else{
										$newDate=date("Y")."-".($ipi-9)."-1";
										echo date("F",strtotime($newDate));//."(".($ij-9).")";
									  }
							 ?></td>
                           <td><input  type="text" id="extra<?php echo $myinstall["type"] ?>fee<?php echo $ipi ?>" class="input-block-level findFeeNow" value="<?php echo $myinstall["fee"]; ?>"  name="extra<?php echo $myinstall["type"] ?>fee[]"></td>
						   
                                <td><input readonly="readonly" type="text" id="extragiven<?php echo $myinstall["type"] ?>fee<?php echo $ipi ?>" class="input-block-level" value="" <?php if($myinstall["pay"]>0)echo 'readonly="readonly"'; ?> name="extra<?php echo $myinstall["type"] ?>feegiven[]"></td>
                          
                            	<td><?php 
								if($myinstall["pay"]>0)echo '<font color="#009900">Paid</font>';
								else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="hosteltd"><?php
								if($myinstall["pay"]>0){}else{
								?><a href="javascript:;" onClick="update_extra_Fee('<?php echo $ipi ?>','<?php echo $myinstall[id] ?>','extra<?php echo $myinstall[type] ?>fee<?php echo $ipi ?>','<?php echo $myinstall[fee]; ?>','<?php echo $chkExtFee["total"]?>','<?php echo $myinstall["discount"]?>','extra')">
                                <button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetextrafee('<?php echo $ipi ?>','<?php echo $myinstall["fee"]; ?>','<?php echo $myinstall["type"]; ?>','<?php echo $myinstall["fee"];?>','extra')"><button type="button" class="btn btn-default">Reset fee</button></a><?php	
								}
								?></td>
                            </td>
							<?php
						}
					?>
					</tbody>
                </table>
                        </div>
                		<?php
							}
						}
					}
				?>
				
				
				
				
<!-- nitish code end-->
				
				
                <?php $i=1;$totalOther=0;$payOther=0;$fineTotal=0;$allReasion=array();$OtherSiteTotal=0;
					 if($_GET["id"]!=''){ 
					 $utype=mydetail("htype",$_GET["id"],"student");
					 $all_other=$db->getRows("select * from hostel_otherfee_structure where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$aryForm["class"]."' and (otype='' OR otype='".$utype."' OR otype='".$_GET["id"]."')");
					 //echo"<pre>";print_r($all_other);echo"</pre>";exit;
					  if(is_array($all_other) && count($all_other))
                      {
						?><div class="half">
                        <center>Hostel Extra fee</center>
                <table class="table">
                    <thead>
                        <tr>
                             <th style="color:#FFF">Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="tbody" style="border-top:2px solid #F00"><?php  
						  
                        foreach($all_other as $iPro)
                        {
							$i++;$ijk=trim($iPro['month']," ");$amt=0;
							$paid_Fee=$db->getVal("select fine from installment_fine where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and reasion='".$iPro["name"]."' and ins_name like '%otherfeehostel%'");
							$fineAry=$db->getRow("select fine,reasion from installment_fine where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and ins_name='".$i."-otherhostel'");
							//print_r($fineAry);echo $db->getLastQuery();
							$other_Fee=$db->getVal("select sum(discount) from hostelotherfee_discount where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and other_id='".$iPro["id"]."'");		
							$OtherSiteTotal+=(int)$other_Fee;
							$name=$iPro['name'];
							$name=trim($name," ");
							$amt=$iPro["fee"];
							$amt=($iPro["fee"]-(int)$other_Fee);
					 ?>
                     <tr>
                      
                      	<td><?php echo $name; ?></td>
                        <td>
                        <input type="hidden" name="idno[]" value="<?php echo $_GET["id"]; ?>" />
                        <input type="hidden" name="month" value="<?php echo $ijk; ?>" />
                        <input type="hidden" name="reasion[]" id="<?php echo $i;?>" value="<?php echo $iPro["name"]; ?>" />
                        <input rel='tooltip' type="text" id="hostelotherfee<?php echo $iPro["id"]; ?>" class="input-block-level" value="<?php echo ($iPro["fee"]-(int)$other_Fee); ?>" title="<?php echo $other_Fee["detail"]; ?>" name="hostelotherfee[]"><?php $totalOther+=(int)$iPro["fee"]-(int)$other_Fee; ?></td>
                        <td><input type="text" readonly id="givenother<?php echo $i; ?>" class="input-block-level" value="<?php echo $paid_Fee; ?>" name="othergiven[]" ><?php $payOther+=(int)$paid_Fee; ?></td>
                       <td><?php 
								if($paid_Fee>0)echo '<font color="#009900">Paid</font>';
								else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="hosteltd"><?php
								if($paid_Fee>0){}else{
								?><a href="javascript:;" onClick="updateFee('<?php echo $iPro["id"] ?>','<?php echo $amt; ?>','<?php echo $paidfee ?>','<?php echo $iPro["month"]?>','hostelotherfee')">
                                <button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetotherFee('<?php echo $iPro["id"]?>','<?php echo ($iPro["fee"]-(int)$other_Fee); ?>','<?php echo $iPro["otype"]?>','hostelotherfee')"><button type="button" class="btn btn-default">Reset fee</button></a><?php	
								}
								?></td>
                               
                      </tr>
                     <?php $i++;} 
					 
					 ?></tbody>
                  </table>
                  </div><?php
					  }
					 
					 echo $db->getErMsg();
					 }?>
                     <?php $i=1;$totalOther=0;$payOther=0;$fineTotal=0;$allReasion=array();$OtherSiteTotal=0;
					 if($_GET["id"]!=''){ 
					 $utype=mydetail("stype",$_GET["id"],"student");
					 $all_other=$db->getRows("select * from otherfee_structure where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and class='".$aryForm["class"]."' and (otype='' OR otype='".$utype."' OR otype='".$_GET["id"]."')");
					 //echo"<pre>";print_r($all_other);echo"</pre>";exit;
					  if(is_array($all_other) && count($all_other))
                      {
						?><div class="half">
                        <center>Extra fee</center>
                <table class="table">
                    <thead>
                        <tr>
                             <th style="color:#FFF">Quater</th>
                            <th>Amount</th>
                            <th>Amount Given</th>
                            <th>Status</th>
                            <th><span class="action">Action</span></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="tbody" style="border-top:2px solid #F00"><?php  
						  
                        foreach($all_other as $iPro)
                        {
							$i++;$ijk=trim($iPro['month']," ");$amt=0;
							$paid_Fee=$db->getVal("select fine from installment_fine where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET["id"]."' and reasion='".$iPro["name"]."' and ins_name like '%otherfee%'");
							$fineAry=$db->getRow("select fine,reasion from installment_fine where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and ins_name='".$i."-other'");
							//print_r($fineAry);echo $db->getLastQuery();
							$other_Fee=$db->getVal("select sum(discount) from otherfee_discount where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$aryForm["idno"]."' and other_id='".$iPro["id"]."'");		
							$OtherSiteTotal+=(int)$other_Fee;
							$name=$iPro['name'];
							$name=trim($name," ");
							$amt=$iPro["fee"];
							$amt=($iPro["fee"]-(int)$other_Fee);
					 ?>
                     <tr>
                      
                      	<td><?php echo $name; ?></td>
                        <td>
                        <input type="hidden" name="idno[]" value="<?php echo $_GET["id"]; ?>" />
                        <input type="hidden" name="month" value="<?php echo $ijk; ?>" />
                        <input type="hidden" name="reasion[]" id="<?php echo $i;?>" value="<?php echo $iPro["name"]; ?>" />
                        <input rel='tooltip' type="text" id="otherfee<?php echo $iPro["id"]; ?>" class="input-block-level" value="<?php echo ($iPro["fee"]-(int)$other_Fee); ?>" title="<?php echo $other_Fee["detail"]; ?>" name="otherfee[]"><?php $totalOther+=(int)$iPro["fee"]-(int)$other_Fee; ?></td>
                        <td><input type="text" readonly id="givenother<?php echo $i; ?>" class="input-block-level" value="<?php echo $paid_Fee; ?>" name="othergiven[]" ><?php $payOther+=(int)$paid_Fee; ?></td>
                       <td><?php 
								if($paid_Fee>0)echo '<font color="#009900">Paid</font>';
								else echo '<font color="#FF0000">Due</font>'; ?></td>
                                <td class="hosteltd"><?php
								if($paid_Fee>0){}else{
								?><a href="javascript:;" onClick="updateFee('<?php echo $iPro["id"]?>','<?php echo $amt; ?>','<?php echo $paidfee ?>','<?php echo $iPro["month"]?>','otherfee')">
                                <button type="button" class="btn btn-primary">Discount</button></a>
								<a href="javascript:;" onClick="resetotherFee('<?php echo $iPro["id"]?>','<?php echo ($iPro["fee"]-(int)$other_Fee); ?>','<?php echo $iPro["otype"]?>','otherfee')"><button type="button" class="btn btn-default">Reset fee</button></a><?php	
								}
								?></td>
                               
                      </tr>
                     <?php $i++;} 
					 
					 ?></tbody>
                  </table>
                  </div><?php
					  }
					 
					 echo $db->getErMsg();
					 }?>
                 <?php $overAllTotal=0;$overAllPay=0;$overAllRemaining=0;$overAllDiscount=0; ?>
                 <table class="table">
                 	<thead>
                    	<tr>
                        	<th>School Fee Description</th>
                            <th>Total Fee</th>
                            <th>Total Paid</th>
                            <th>Total Left</th>
                            <th>Discount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="first"  style="border-top:2px solid #F00">
                            <th>Total Class Fee</th>
                            <th><?php echo (int)$aryInstall["total"];$overAllTotal+=$aryInstall["total"]; ?></th>
                            <th><?php echo (int)$totalclasspayfee;$overAllPay+=$totalclasspayfee; ?></th>
                            <th><?php echo $rem=(int)($aryInstall["total"]-$totalclasspayfee);$overAllRemaining+=$rem; ?></th>
                           <td><?php echo (int)$aryInstall["discount"];$overAllDiscount+=$aryInstall["discount"]; ?></td>
                       </tr>
                        <tr>
                            <th>Total Transport Fee</th>
                            <th><?php echo (int)$aryInstall["bus"];$overAllTotal+=$aryInstall["bus"]; ?></th>
                            <th><?php echo (int)$totalbuspayfee;$overAllPay+=$totalbuspayfee; ?></th>
                            <th><?php echo $rem=(int)($aryInstall["bus"]-$totalbuspayfee);$overAllRemaining+=$rem; ?></th>
                            <td><?php echo (int)$aryInstall["busdiscount"];$overAllDiscount+=$aryInstall["busdiscount"]; ?></td>
                       </tr>
                       <tr>
                            <th>Total Hostel Fee</th>
                            <th><?php echo (int)$aryHostelInstall["total"];$overAllTotal+=$aryHostelInstall["total"]; ?></th>
                            <th><?php echo (int)$totalhostelpayfee;$overAllPay+=$totalhostelpayfee; ?></th>
                            <th><?php echo $rem=(int)($aryHostelInstall["total"]-$totalhostelpayfee);$overAllRemaining+=$rem; ?></th>
                            <td><?php echo (int)$aryHostelInstall["discount"];$overAllDiscount+=$aryHostelInstall["discount"]; ?></td>
                       </tr>
                       
                       <tr style="border-bottom:2px solid #F00; border-top:2px solid #F00;">
                            <th>OverAll Detail</th>
                            <th><?php echo (int)$overAllTotal; ?></th>
                            <th><?php echo (int)$overAllPay; ?></th>
                            <th><?php echo (int)($overAllTotal-$overAllPay); ?></th>
                            <td><?php echo (int)$overAllDiscount+$OtherSiteTotal; ?></td>
                       </tr>
					 <?php 
                     $session=$db->getRows("select session from session where school_id='".$_SESSION["admin"]["school_id"]."' and session!='".$_SESSION["admin"]["session"]."'");
					 
                     $my_root=$db->getVal("select is_root from session_idno	where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and idno='".$_GET["id"]."'");
					 //echo $db->getErMsg().$db->getLastQuery(); 
                     if(is_array($session) && count($session)>0){
                         foreach($session as $s){
                            $installs=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$s["session"]."' and idno=(select idno from session_idno where session='".$s["session"]."' and is_root=".$my_root.")");
                            $classFee=0;$busFee=0;$classFeePay=0;$busFeePay=0;
                            for($i=1;$i<=15;$i++){
                                $classFee=$classFee+$installs["i".$i];
                                $busFee=$busFee+$installs["b".$i];
                                $classFeePay=$classFeePay+$installs["ip".$i];
                                $busFeePay=$busFeePay+$installs["bp".$i];
                            }
							if(($classFee+$busFee)>($classFeePay+$busFeePay) ){
                            ?>
							<tr style="border-top:2px solid #090">
                                <th>Remainin Class Fee for <?php echo $s["session"]; ?></th>
                                <th><?php echo (int)$installs["total"]; ?></th>
                                <th><?php echo (int)$classFeePay; ?></th>
                                <th><?php echo (int)($installs["total"]-$classFeePay); ?></th>
                                <td>Login with <?php echo $s["session"]; ?> session to pay fee</td>
                           </tr>
                           <tr>
                                <th>Remainin Bus Fee for <?php echo $s["session"]; ?></th>
                               <th><?php echo (int)$installs["bus"]; ?></th>
                                <th><?php echo (int)$busFeePay; ?></th>
                                <th><?php echo (int)($installs["bus"]-$busFeePay); ?></th>
                                <td>Login with <?php echo $s["session"]; ?> session to pay fee</td>
                           </tr>
							<?php
							}
                         }
                     }
                     ?>
                 	</tbody>
              </table>
                 <?php //echo $db->getErMsg().$db->getLastQuery(); ?>
          </div>
         </div>
    </div>
</div>        
<!-- / Forms -->
<?php
}
else{
	?>
	<style>.popupme{display:none}.top-bar-minimize{display:none !important}</style>			<!-- Add News: Top Bar -->
    <div class="popupme">
        <div class="top-bar">
            <h3><i class="icon-calendar"></i> Add Backdue</h3>
            <div class="pull-right" style="margin:5px"><a href="#" onclick="$('.popupme').hide()" class="btn btn-info">Close</a></div>
        </div>
        <div class="well no-padding">
        	<input type="hidden" id="class" />
            <input type="hidden" id="idno" />
                <div class="control-group">
                    <label class="control-label" for="name">Fees Title</label>
                    <div class="controls">
                        <input type="text" id="feetitle" placeholder="tusion fee" required="" class="input-block-level" value="Back_dues">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="class">Select Month</label>
                    <div class="controls">
                        <select id="month" name="month" multiple="multiple">
                            <option value="">Select some months</option>
                            <?php 
                                               if(is_array($monthsList) && count($monthsList)>0){
                                            foreach($monthsList as $key=>$value){
                                                ?>
                                    <option <?php if($key==$aryForm["month"])echo 'selected';?> value="<?php echo $key ?>"> 
                                        <?php echo $value ?>
                                    </option>
                                    <?php
                                } }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="fee">Fixed Fees</label>
                    <div class="controls">
                        <input type="text" id="fixedfee" placeholder="150" name="fee" required="" class="input-block-level" value="">
                    </div>
                </div>
                <div class="form-actions">
                    <button type="submit" onclick="saveBackDue()" class="btn btn-primary"> Save</button>
                    <button type="button" class="btn"  onclick="$('.popupme').hide()"> Cancel</button>
                </div>
                        
		</div>
    <!-- / Add News: Content -->
	</div>
<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    <button style="float:right; margin-top:5px" onclick="window.location='./?src=Promote&page_id=<?php echo $pgMod; ?>&action=add'" class="btn" type="button">Add <?php echo $pgMod; ?></button>
    </div>
    <div class="well no-padding">
	<?php
	$aryPgAct=array("src"=>"Promote", "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="applyfilter()" class="span6 searchFilter" 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 value="<?php echo $cla["class"] ?>">
                            <?php echo $cla["class"] ?>
                        </option>
                        <?php
            
                    }
                ?>
            </select>
            <select onchange="applyfilter()" class="span6 searchFilter" 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="feediscount" />
        <input type="hidden" id="CurrentPage" name="CurrentPage" value="1">
        <input type="hidden" name="startV" id="startV" value="0">
        <input type="hidden" name="endV" id="endV" value="5">
        <div class="searchData"></div>
        <table class="table table-widget table-striped" id="mssresulttable" data-action="viewall" data-extra="&type=student" data-page="index.php?src=Promote&page_id=feediscount&loadData=yes" data-table="student">
            <thead>
                <tr>
                   <th width="10%">Admission no</th>
                    <th width="20%">Name</th>
                    <th>Class</th>
                    <th>Medium</th>
                   
                    <th>Cast</th>
                    <th>Father</th>
                  
                    <th>Action</th>
                </tr>
            </thead>
            <tfoot>
            </tfoot>
            <tbody id="resultBody">
           
            </tbody>
        </table>
        <div class="paginationData"></div>
		<?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
}

?>
<!-- / Forms -->
<script type="text/javascript">
function cheackname(id,name)
{
		$.ajax("Promote/ajax.php?type=checkname&idno="+id+"&title="+name,
		function(data){
	alert(data)
			
			//$(".popupme").hide();
		})	
	}
function backdue(id,cla){
	
	$("#class").val(cla);
	$("#idno").val(id)
	$(".popupme").slideDown();
}
function saveBackDue(){
	
	var idno=$("#idno").val();
	var cla=$("#class").val();
	var title=$("#feetitle").val();
	var month=$("#month").val();
	var fixedfee=$("#fixedfee").val();
	cheackname(idno,title);
	
	if(title==""){
		alert("please check fee title")
	}else if(month==""){
		alert("please check fee month")
	}else if(fixedfee==""){
		alert("please check fee fee")
	}else{
		$.ajax("Promote/ajax.php?type=BackDue&idno="+idno+"&title="+title+"&class="+cla+"&month="+month+"&fixedfee="+fixedfee,function(data){
	
			alert(data)
			$(".popupme").hide();
		})
	location.reload();	
	}
}
$(document).ready(function(e) {
    var oTable = $('#ajaxtable').dataTable( {
		"bProcessing": true,
		'sPaginationType': 'full_numbers',
		"sAjaxSource": 'Promote/ajax.php?type='+$('#tabletype').val(),
		'iDisplayLength': 5,
		"oLanguage": {
			"sSearch": "Search by any columns:"
		}
	});
});
function fetchByClass(id){
//	var name=$("#class").val();
	 var name=(id.value);
	var section=$("#section").val();
	//alert(name+section);
	if(name!=""){
		var url='Promote/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": 'Promote/ajax.php?type='+$('#tabletype').val(),
			'iDisplayLength': 5,
			"oLanguage": {
				"sSearch": "Search by any columns:"
			}
		});
	}
}
function updateFee(id,oldvalue,total,discount,type){
	var newValue=$("#"+type+id).val();
	
	//alert(newValue);
	//alert(newValue+oldvalue+type);
	if(newValue==""){
		alert("New value for total cannot blank");
	}else if(isNaN(parseInt(newValue))){
		alert("New value for total must numeric");
		
	}/*else if(parseInt(newValue)==parseInt(oldvalue)){
		alert("old total and new total both are same");
	}*//*else if(parseInt(newValue)>parseInt(oldvalue)){
		alert("New value cannot more then old total");
	}*/else{
		$.post( "Promote/ajax.php", { type: "updateTotal" ,paytype: type, id: id, discount: discount, total: total, newValue: newValue, oldvalue: oldvalue, idno:"<?php echo $_GET["id"] ?>" } , 
		
		function( data ) {
			//alert(data);
			window.location.reload();
		});
	}
}



//update extra fee start--

function update_extra_Fee(did,id,amt_field_value,oldvalue,total,discount,type){
	var newValue=$("#"+amt_field_value).val();
	//alert(id);
	
	if(newValue==""){
		alert("New value for total cannot blank");
	}else if(isNaN(parseInt(newValue))){
		alert("New value for total must numeric");
		}
		
		else{
		$.post( "Promote/ajax.php", { type: "extra_fee_discount" ,paytype: type, did: did, id: id,amt_field_value:amt_field_value, discount: discount, total: total, newValue: newValue, oldvalue: oldvalue, idno:"<?php echo $_GET["id"] ?>" } , function( data ) {
			//alert(data);
			window.location.reload();
		});
	}
	
}

// update extra fee end

function resetFee(id,oldvalue,type){
	//alert(oldvalue);
	var newValue=prompt("Please Enter Default Fee",0);
	
	if (newValue === null) {
        return; //break out of the function early
    }
    
	$.post( "Promote/ajax.php", { type: "updateNewTotal" ,paytype: type, oldvalue: oldvalue, id: id, newValue: newValue, idno:"<?php echo $_GET["id"] ?>" } , function( data ) {
			//alert(data);
		window.location.reload();
	});
}function resetotherFee(id,oldvalue,sid,type){
	
	if(sid=='' || sid=='old' || sid=='new')
	{
alert("This Fee Can Not Be reset");
	}

else{	
//	alert(id);
	var newValue=prompt("Please Enter Default Fee",0);
	
	if (newValue === null) {
        return; //break out of the function early
    }
	$.post( "Promote/ajax.php", { type: "updateNewTotal" ,paytype: type, id: id,  oldvalue: oldvalue,  sid: sid, newValue: newValue, idno:"<?php echo $_GET["id"] ?>" } , function( data ) {
			//alert(data);
		window.location.reload();
	});
}
}

function resetextrafee(id,oldvalue,typeid,total,type){
	//var newValue=$("#"+type+id).val();

	var newValue=prompt("Please Enter Default Fee",0);
	
	
	if (newValue === null) {
        return; //break out of the function early
    }
	//alert(oldvalue);
	//alert(newValue);
	if(newValue==""){
		alert("New value for total cannot blank");
	}else if(isNaN(parseInt(newValue))){
		alert("New value for total must numeric");
		
	}/*else if(parseInt(newValue)==parseInt(oldvalue)){
		alert("old total and new total both are same");
	}*//*else if(parseInt(newValue)>parseInt(oldvalue)){
		alert("New value cannot more then old total");
	}*/else{
		$.post( "Promote/ajax.php", { type: "resetextrafees" ,paytype: type, id: id, oldvalue: oldvalue, newValue: newValue, typeid: typeid, total: total, idno:"<?php echo $_GET["id"] ?>" } , 
		
		function( data ) {
			//alert(data);
			window.location.reload();
		});
	}
}

function checkRecept(STcls){
	var totalSum=0;var tot=0;
	var name=0;	var bus=0; var hostel=0; var otherlMonth="";	var extraFee="";	var other=0; var otherfee=""; var ext="";	var msg="";	var rrid="rrid";
	var nameFine=0;	var busFine=0; var hostelFine=0; var otherlMonthFine="";	var extraFeeFine="";	var otherFine=0; var otherFinefee=""; var extFine="";
	var busMonth="";	var hotelMonth="";	var tutionMonth="";	var otherMonth="";	var myotherMonth="";	var extraMonth=""; var m=""; var extrafee=0;
	var busFineMonth="";	var hotelFineMonth="";	var tutionFineMonth="";	var otherFineMonth="";	var myotherMonth="";	var extraFineMonth=""; var m=""; var extraFinefee=0;  var extraFineFee ="";
	$("input:checkbox[type=checkbox]:checked").each(function(){
		var amt=parseInt($(this).val());
		rrid=rrid+"-"+$(this).attr('data-rr');
		if($(this).attr("class")=="bus"){msg+=" bus";bus+=amt;if(busMonth=="")busMonth+=$(this).attr("data-month");else busMonth+=","+$(this).attr("data-month"); m+=","+$(this).attr("data-extramonth");tot+=parseInt($(this).attr("data-tot"));}
		else if($(this).attr("class")=="bus_fine"){msg+=" bus fine ";busFine+=amt;if(busFineMonth=="")busFineMonth+=$(this).attr("data-month");else busFineMonth+=","+$(this).attr("data-month"); m+=","+$(this).attr("data-extramonth");tot+=amt;}
		else if($(this).attr("class")=="hostel"){msg+=" hostel";hostel+=amt;if(hotelMonth=="")hotelMonth+=$(this).attr("data-month");else hotelMonth+=","+$(this).attr("data-month");tot+=parseInt($(this).attr("data-tot"));}
		else if($(this).attr("class")=="hostel_fine"){msg+=" hostel Fine";hostelFine+=amt;if(hotelFineMonth=="")hotelFineMonth+=$(this).attr("data-month");else hotelFineMonth+=","+$(this).attr("data-month");tot+=amt;}
		
		
		else if($(this).attr("class")=="other"){msg+= $(this).attr("data-class");otherfee+="&fee-"+$(this).attr("data-class")+"="+amt; if(otherlMonth=="")otherlMonth+=$(this).attr("data-month"); else otherlMonth+=","+$(this).attr("data-month");tot+=amt;}
		
		else if($(this).attr("class")=="myother"){msg+= $(this).attr("data-class"); ext+="&fee-"+$(this).attr("data-class")+"="+amt;tot+=parseInt($(this).attr("data-tot"));}
		else if($(this).attr("class")=="myother_fine"){msg+= $(this).attr("data-class"); extFine+="&fee-"+$(this).attr("data-class")+"%20Remaining"+"="+amt;tot+=amt;}
		
		
		else if($(this).attr("class")=="cla"){msg+=" class";name+=amt;if(tutionMonth=="")tutionMonth+=$(this).attr("data-month");else tutionMonth+=","+$(this).attr("data-month"); m+=","+$(this).attr("data-extramonth");tot+=parseInt($(this).attr("data-tot")); }
		else if($(this).attr("class")=="cla_fine"){msg+=" class Fine";nameFine+=amt;if(tutionFineMonth=="")tutionFineMonth+=$(this).attr("data-month");else tutionFineMonth+=","+$(this).attr("data-month"); m+=","+$(this).attr("data-extramonth");tot+=amt;}
		
		
		else if($(this).attr("class")=="extrafee"){extraFee+="&extrafee-"+$(this).attr("data-name")+"`"+$(this).attr("data-month")+"="+amt;
if(extraMonth=="")extraMonth+=$(this).attr("data-month");else extraMonth+=","+$(this).attr("data-month");tot+=parseInt($(this).attr("data-tot"));}
		else if($(this).attr("class")=="extrafee_fine"){
			extraFineFee+="&extrafee-fine%20"+$(this).attr("data-name")+"`"+$(this).attr("data-month")+"="+amt;tot+=amt;
			 if(extraFineMonth=="")extraFineMonth+=$(this).attr("data-month");else extraFineMonth+=","+$(this).attr("data-month"); }
		//alert(amt+"-"+tot);
		totalSum+=amt;
	}); //alert(otherfee);
	//var month="&busMonth="+busMonth+"&hotelMonth="+hotelMonth+"&tutionMonth="+tutionMonth+"&otherMonth="+otherMonth+"&myotherMonth="+myotherMonth+"&extraMonth="+extraMonth;
	//alert(tot);
	var month="&Months="+busMonth+","+hotelMonth+","+tutionMonth+","+m+","+otherMonth+","+myotherMonth+","+extraMonth;
	//var tution_month="&tution_month="+tutionMonth;
	//var bus_month="&bus_month="+busMonth;
	getPopup("<?php echo URL_ROOT ?>print/?page_id=resetdiscount&id=<?php echo $_GET["id"]."&udate=".date("d-m-Y")."&amount="; ?>"+totalSum+"&type=fee&fee-Tution%20Fees="+name+"&fee-Bus%20Fees="+bus+"&fee-Hostel%20Fees="+hostel+"&fee-Hostel%20Fine="+hostelFine+"&fee-Bus%20Fine="+busFine+"&fee-Tution%20Fine="+nameFine+"&rrid="+rrid+otherfee+"&paytype=classfee&detail=pay fee for "+msg+"&class="+STcls+"&install=1"+
	extraFee+extraFineFee+ext+extFine+month+"&total="+tot,"1","recepit");
	$(".close").click(function() {
		$(this).parent().remove();
	location.reload();	
	});
	$(".outer").click(function() {
		$(this).remove();
		location.reload();
	});
	
}

</script>