<?php include "header.php"; 
if($login_type=='admin'){
$btnSave=$_POST['btnSave'];
$college_id=$_POST['college_id'];
$college_type=$_POST['college_type'];
$course_name=$_POST['course_name'];
$sub_id=$_POST['sub_id'];
$sem_yer=$_POST['sem_yer'];

$pra_fees=$_POST['pra_fees'];
$admin_fee=$_POST['admin_fee'];
$pra_file_fee=$_POST['pra_file_fee'];
$uin_fee=$_POST['uin_fee'];
$other_fee=$_POST['other_fee'];
$other_fee2=$_POST['other_fee2'];
$pr=$_POST['pr'];
$total_fees=$pra_fees+$admin_fee+$pra_file_fee+$uin_fee+$other_fee+$other_fee2;

$submit=$_GET['submit'];
if($submit=='Update'){
$id=$_GET['id'];
$rollno=$_GET['rollno'];
$total_stu=$_GET['total_stu'];
//$total_ffes=$_GET['total_fees'];
$pra_fees=$_GET['pra_fees'];
$admin_fee=$_GET['admin_fee'];
$pra_file_fee=$_GET['pra_file_fee'];
$uin_fee=$_GET['uin_fee'];
$other_fee=$_GET['other_fee'];
$other_fee2=$_GET['other_fee2'];
$fn1=$_GET['fn1'];
$fn2=$_GET['fn2'];
$fn3=$_GET['fn3'];
$fn4=$_GET['fn4'];
$pr=$_GET['pr'];
$total_fees=$pra_fees+$admin_fee+$pra_file_fee+$uin_fee+$other_fee+$other_fee2;
$query = "UPDATE fees SET total_ffes='$total_fees',pra_fees='$pra_fees',rollno='$rollno',total_stu='$total_stu',admin_fee='$admin_fee',pra_file_fee='$pra_file_fee',uin_fee='$uin_fee',other_fee='$other_fee',other_fee2='$other_fee2',fn1='$fn1',fn2='$fn2',fn3='$fn3',fn4='$fn4',pr='$pr' WHERE id='$id' and code='$code' and session='$session'";
 $result = mysql_query( $query );
 if ( ! $result )
die ("Couldn't update: ".mysql_error());
print "<h1>Table Updated ". mysql_affected_rows() .
" row(s) updated</h1>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_fees.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?php 
}
$rollno=$_POST['rollno'];
$total_stu=$_POST['total_stu'];
if($btnSave=='Add Record'){
$query = "INSERT INTO `fees` (`id`, `class`, `section`, `total_ffes`, `pra_fees`, `code`, `rollno`, `total_stu`, `admin_fee`, `pra_file_fee`, `uin_fee`, `other_fee`, `other_fee2`,`session`,`fn1`,`fn2`,`fn3`,`fn4`,`pr`) VALUES ('$id','$course_name','$sem_yer','$total_fees','$pra_fees','$college_id','$rollno','$total_stu','$admin_fee','$pra_file_fee','$uin_fee','$other_fee','$other_fee2','$session','$fn1','$fn2','$fn3','$fn3','$pr')";
  mysql_query( $query )
 or die ( "Couldn't add data to \"application\" table: " 
 .mysql_error() );
print "<div>Data Save [ ". mysql_affected_rows() .
" row(s) ] Successfully </div>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_fees.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?PHP
}






if($submit=='Delete'){
$id=$_GET['id'];

$query = "DELETE FROM fees WHERE id='$id' and code='$code' and session='$session'";
$result = mysql_query( $query );
if ( ! $result )
die ("Couldn't deleted: ".mysql_error());
print "<h1>Table deleted ". mysql_affected_rows() .
" row(s) deleted</h1><p>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_fees.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?PHP
}

?> <section class="content">
      <div class="container-fluid">
                <!-- Page Header -->
                <div class="col-lg-12">
                    
    <style type="text/css">
<!--
.style1 {color: }
-->
</style>


</script><div class="card card-danger">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>


    
      <form name="form1" action="feed_fees.php?active7=1&title=Fees" method="post"  class="form-horizontal" role="form">
	  <table cellpadding=2 cellspacing=0 border=1 bordercolor=#FFFFCC bgcolor="" align=center class="table table-bordered table-striped">
				
		<tr>
		  <td colspan="2" class=color3 style="color:">Add Records</td>
		  </tr>
		<tr>
          <td class=color3>Select College</td>
		  <td class=color2><?php
							
$queryy = "SELECT * FROM college_name where code='$code'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
?>
              <select name="college_id" id="college_id" required class="form-control" onchange='this.form.submit()' >
                <option value="">Select</option>
                <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                <option
                 <?php 
				 $cn_id=$a_roww[2];
				 if($cn_id==$college_id){
				  ?>selected<?php } ?>
                  
                   value="<?php echo $a_roww[2];?>" >( <?php echo $a_roww[2];?> ) <?php echo $a_roww[1];?></option>
                <?php } ?>
            </select></td>
		  </tr>
		<tr>
          <td width="116" class=color3>College Type</td>
		  <td width="190" class=color2><select name="college_type" required="required" class="form-control" onchange='this.form.submit()'>
                  <?php
$query = "SELECT * FROM ctype where session='$session' and code='$code' ORDER BY id";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");
while ( $a_row = mysql_fetch_row( $result ) )

 {?>
          <option value="<?php echo $yiu=$a_row[1]; ?>" <?php if($college_type==$yiu){ ?> selected<?php } ?> ><?php echo $a_row[2]; ?></option>
<?php } ?>
            </select>          </td>
		  </tr>
		<tr>
          <td class=color3> Course Name</td>
		  <td class=color2>
          <select name="course_name" class="form-control"  required onchange='this.form.submit()'>
                                            
                                            <?php $queryy = "SELECT * FROM course_name where college_id='$college_id' && ctype='$college_type' and code='$code' and session='$session' Order by id";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
 ?>
	<option value="">Select</option>
	 <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                  <option 
                 <?php 
				 $course_name1=$a_roww[0];
				 if($course_name==$course_name1){
				  ?>selected<?php } ?> 
                  value="<?php echo $a_roww[0];?>" ><?php echo $a_roww[1];?></option>
                  <?php } ?>
</select>         </td>
		  </tr>
		<?php /*?><tr>
		  <td class=color3>Subject Name</td>
		  <td class=color2><select name="sub_id"  required onchange='this.form.submit()' class="chosen-select form-control">
                                            
                                            <?php $queryy = "SELECT * FROM subject where college_code='$college_id' && college_type='$college_type' Order by id";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
 ?>
	<option value="">Select</option>
	 <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                  <option 
                 <?php 
				 $sub_id1=$a_roww[0];
				 if($sub_id1==$sub_id){
				  ?>selected<?php } ?> 
                  value="<?php echo $a_roww[0];?>" ><?php echo $a_roww[1];?></option>
                  <?php } ?>

</select></td>
		</tr><?php */?>
        <tr>
          <td class=color3>Semester / Year</td>
          <td class=color2>
   <select name="sem_yer" required class="chosen-select form-control">

            <?php $queryy = "SELECT * FROM seme_year where course_name='$course_name' and college_id='$college_id' Order by id";

$numresultsy=mysql_query($queryy);

$resulty= mysql_query($queryy) or die("Couldn't execute query");

 ?>

	<option value="">Select</option>

	 <?php

while ( $a_roww = mysql_fetch_row( $resulty ) )

 {?>

                  <option

                 <?php 

				 $Course_Detailss=$a_roww[1];

				 if($Course_Detailss==$sem_yer){

				  ?>selected<?php } ?>

                  

                   value="<?php echo $a_roww[1];?>" ><?php echo $a_roww[1];?></option>

                  <?php } ?>
          </select></td>
        </tr>
       <?php /*?> <tr>
          <td class=color3>Total Fees</td>
          <td class=color2><input class="form-control" name="total_fees" type="text" class="form-control"  required="required" /></td>
        </tr><?php */?>
         <tr>
          <td class=color3>Admission Fees</td>
          <td class=color2><input class="form-control" name="admin_fee" type="text" id="admin_fees"  required="required" /></td>
        </tr>
        <tr>
          <td class=color3>Practical Fees</td>
          <td class=color2><input class="form-control" name="pra_fees" type="text"   required="required" /></td>
        </tr>
        <tr>
          <td class=color3><span class="color2">
            <input class="form-control" name="fn1" type="text" id="fn1"  required="required" />
          </span></td>
          <td class=color2><input class="form-control" name="pra_file_fee" type="text" id="pra_file_fee"  required="required" /></td>
        </tr>
        <tr>
          <td class=color3><span class="color2">
            <input class="form-control" name="fn2" type="text" id="fn2"  required="required" />
          </span></td>
          <td class=color2><input class="form-control" name="uin_fee" type="text" id="uin_fee"  required="required" /></td>
        </tr>
         <tr>
          <td class=color3><span class="color2">
            <input class="form-control" name="fn3" type="text" id="fn3"  required="required" />
          </span></td>
          <td class=color2><input class="form-control" name="other_fee" type="text" id="other_fee"  required="required" /></td>
        </tr>
         <tr>
          <td class=color3><span class="color2">
            <input class="form-control" name="fn4" type="text" id="fn4"  required="required" />
          </span></td>
          <td class=color2><input class="form-control" name="other_fee2" type="text" id="other_fee2"  required="required" /></td>
        </tr>
        <tr>
          <td class=color3>Alloted Roll No Start to</td>
          <td class=color2><input class="form-control" name="rollno" type="text" id="rollno"  required="required" /></td>
        </tr>
        <tr>
          <td class=color3>Total Students</td>
          <td class=color2><input class="form-control" name="total_stu" type="text" id="total_stu"  required="required" /></td>
        </tr>
        <tr>
          <td class=color3>Print Receipt</td>
          <td class=color2><select name="pr" required>
          <option value="" <?php if($pr==''){ ?>selected<?php } ?>>Select</option>
          <option value="Full" <?php if($pr=='Full'){ ?>selected<?php } ?>>Full</option>
          <option value="Headwise" <?php if($pr=='Headwise'){ ?>selected<?php } ?>>Headwise</option>
          </select></td>
        </tr>
        <tr> 
			<td class=color3></td>
			<td class=color2><input type="submit" name="btnSave" value="Add Record"  class="btn btn-info" ></td>
		</tr>
	</table>
</form>
<?php
	 
$query = "SELECT * FROM fees where code='$code' and session='$session' ORDER BY class";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");


?>
<div style="overflow:auto; text-align:center">
<div class="card card-success">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>
<?php if($numrows!=""){?>
   <table  cellpadding="1" border="1" cellspacing="1" bgcolor="" align="center" class="table table-bordered table-striped">

<?php 
$counter = 1;?>
 <?php
while ( $a_row = mysql_fetch_row( $result ) )
 {?>
 
 <form action="feed_fees.php?active7=1&title=Fees" enctype="text/plain" method="get">
<input  name="id" type="hidden" value="<?php echo $a_row[0];?>" />
 <tr>
	
 <td rowspan="2" align="center" valign="top"  class="border">   <div align="center" ><?php echo $counter;?></div></td>
  <td rowspan="2" align="center" valign="top"  class="style1" ><span class="color2"><?php echo $a_row[5]; ?></span></td>
  <td rowspan="2" align="center" valign="top"  class="style1" >
 
  
                                            
                                            <?php 
											$course_namei=$a_row[1];
											$queryy = "SELECT * FROM course_name where id='$course_namei' and code='$code' and session='$session'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
 ?>
	
              <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                  <?php 
				  
				 
				
				
				 $Course_id=$a_roww[0];
				 if($Course_id==$course_namei){
				  ?>                  <?php echo $a_roww[1];?>-<?php echo $a_row[2];?>
                  <?php } ?> 
            <?php } ?> </td>
  <td rowspan="2" align="center" valign="top"  class="style1" >Admission Fee
    <input class="form-control" name="admin_fee" type="text" id="admin_fees2" value="<?php echo $a_row[8]; ?>" required="required" /></td>
  <?php /*?><td align="center" valign="top"  class="style1" >Subject Name</td>
  <td align="center" valign="top"  class="style1" >Total Fees</td><?php */?>
  <td rowspan="2" align="center" valign="top"  class="style1" >Practical Fees
    <input  name="pra_fees" type="text" class="form-control" value="<?php echo $a_row[4]; ?>" required="required" /></td>

  <td align="center" valign="top"  class="border"><span class="color2">
    <input class="form-control" name="fn1" type="text" id="fn1" value="<?php echo $a_row[14]; ?>"  required="required" /><?php echo $a_row[14]; ?>
  </span></td>
  <td align="center" valign="top"  class="border"><input class="form-control" name="fn2" type="text" id="fn2" value="<?php echo $a_row[15]; ?>" required="required" /><?php echo $a_row[15]; ?></td>
  <td align="center" valign="top"  class="border"><input class="form-control" name="fn3" type="text" id="fn3" value="<?php echo $a_row[16]; ?>"  required="required" /><?php echo $a_row[16]; ?></td>
  <td align="center" valign="top"  class="border"><input class="form-control" name="fn4" type="text" id="fn4"  value="<?php echo $a_row[17]; ?>" required="required" /><?php echo $a_row[17]; ?></td>
  <td align="center" valign="top"  class="border">Total Fee</td>
  <td align="center" valign="top"  class="border"><span class="color3">Alloted Roll No Start to</span></td>
  <td align="center" valign="top"  class="border"><span class="color3">Total Students</span></td>
  <td rowspan="2" align="center" valign="top"  class="border"><select name="pr" required>
          <option value="<?php if($a_row[18]==''){ ?>selected<?php } ?>">Select</option>
          <option value="Full" <?php if($a_row[18]=='Full'){ ?>selected<?php } ?>>Full</option>
          <option value="Headwise" <?php if($a_row[18]=='Headwise'){ ?>selected<?php } ?>>Headwise</option>
          </select></td>
  <td rowspan="2" align="center" valign="top"  class="border"><input class="btn btn-primary" type="submit"  name="submit" value="Update"  ></td>
  <td rowspan="2" align="center" valign="top"  class="border">

 
    <a href="feed_fees.php?id=<?php echo $a_row[0];?>&&submit=Delete">Delete</a></td>
 </tr>
 <tr>
 <?php /*?> <td bordercolor="#FFFFCC" class=color2>
      <input class="form-control" name="total_fees" type="text" class="form-control"  required="required" value="<?php echo $a_row[3]; ?>" /></td><?php */?>
 <td height="20" align="center" valign="top" ><span class="color2">
   <input class="form-control" name="pra_file_fee" type="text" id="pra_file_fee" value="<?php echo $a_row[9]; ?>"  required="required" />
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <input class="form-control" name="uin_fee" type="text" id="uin_fee" value="<?php echo $a_row[10]; ?>" required="required" />
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <input class="form-control" name="other_fee" type="text" id="other_fee" value="<?php echo $a_row[11]; ?>"  required="required" />
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <input class="form-control" name="other_fee2" type="text" id="other_fee" value="<?php echo $a_row[12]; ?>" required="required" />
 </span></td>
 <td align="center" valign="top" > <input class="form-control" name="total_fees" type="text" readonly="readonly"   required="required" value="<?php echo $a_row[3]; ?>" /></td>
 <td align="center" valign="top" ><span class="color2"><input class="form-control" name="rollno" type="text" id="rollno" value="<?php echo $a_row[6]; ?>"  required="required"  /></span></td>
 <td align="center" valign="top" ><span class="color2"><input class="form-control" name="total_stu" type="text" id="total_stu" value="<?php echo $a_row[7]; ?>"  required="required" /></span></td>
 </tr>
</form>
   
  <?php $counter++;}?>
  </table>
</div>
   <?php }?>

<?php if($numrows==""){
  echo "<div  style='border:none; text-align:center'><h3 class='logo2'>No Record Found</h3></div>";
}?>
</div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
    <?php
	 
$query = "SELECT * FROM fees where code='$code' and session='$session' ORDER BY class";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");


?>
<div style="overflow:auto; text-align:center">
<div class="card card-success">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>
<?php if($numrows!=""){?>
   <table  cellpadding="1" border="1" cellspacing="1" bgcolor="" align="center" class="table table-bordered table-striped">
 
<?php 
$counter = 1;?>
 <?php
while ( $a_row = mysql_fetch_row( $result ) )
 {?>
 
 <tr>
	
 <td rowspan="2" align="center" valign="top"  class="border"> <div align="center" ><?php echo $counter;?></div></td>
  <td rowspan="2" align="center" valign="top"  class="style1" ><span class="color2"><?php echo $a_row[5]; ?></span></td>
  <td rowspan="2" align="center" valign="top"  class="style1" >
 
  
                                            
                                            <?php 
											$course_namei=$a_row[1];
											$queryy = "SELECT * FROM course_name where id='$course_namei' and code='$code' and session='$session'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
 ?>
	
            <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                  <?php 
				  
				 
				
				
				 $Course_id=$a_roww[0];
				 if($Course_id==$course_namei){
				  ?>                  <?php echo $a_roww[1];?>-<?php echo $a_row[2];?>
                  <?php } ?> 
          <?php } ?> </td>
  <td align="center" valign="top"  class="style1" >Admission Fee</td>
  <?php /*?><td align="center" valign="top"  class="style1" >Subject Name</td>
  <td align="center" valign="top"  class="style1" >Total Fees</td><?php */?>
  <td align="center" valign="top"  class="style1" >Practical Fees</td>

  <td align="center" valign="top"  class="border"><?php echo $a_row[14]; ?></td>
  <td align="center" valign="top"  class="border"><?php echo $a_row[15]; ?></td>
  <td align="center" valign="top"  class="border"><?php echo $a_row[16]; ?></td>
  <td align="center" valign="top"  class="border"><?php echo $a_row[17]; ?></td>
  <td align="center" valign="top"  class="border">Total Fee</td>
  <td align="center" valign="top"  class="border"><span class="color3">Alloted Roll No Start to</span></td>
  <td align="center" valign="top"  class="border"><span class="color3">Total Students</span></td>
  </tr>
 <tr>
 <td height="20" bordercolor="#FFFFCC" class=color2><?php echo $a_row[8]; ?></td>
 <?php /*?> <td bordercolor="#FFFFCC" class=color2>
      <input class="form-control" name="total_fees" type="text" class="form-control"  required="required" value="<?php echo $a_row[3]; ?>" /></td><?php */?>
 <td bordercolor="#FFFFCC" class=color2><?php echo $a_row[4]; ?></td>
 
 <td align="center" valign="top" ><span class="color2">
   <?php echo $a_row[9]; ?>
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <?php echo $a_row[10]; ?>
 </span></td>
 <td align="center" valign="top" ><span class="color2">
  <?php echo $a_row[11]; ?>
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <?php echo $a_row[12]; ?>
 </span></td>
 <td align="center" valign="top" > <?php echo $a_row[3]; ?></td>
 <td align="center" valign="top" ><?php echo $a_row[6]; ?></span></td>
 <td align="center" valign="top" ><?php echo $a_row[7]; ?></span></td>
 </tr>
   
  <?php $counter++;}?>
  </table>
</div>
   <?php }?>

<?php if($numrows==""){
  echo "<div  style='border:none; text-align:center'><h3 class='logo2'>No Record Found</h3></div>";
}?>
</div><!-- /.container-fluid -->
    </section>
  </div><?php } include "footer.php"; ?>