<?php include "dbconfig.php"; 
$datee=$_GET['date'];
$datee2=$_GET['date2'];
?>
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style3 {font-weight: bold}
.style4 {font-weight: bold}
-->
</style>

<form action="Daily_report.php" method="get">
Select Date <input type="date" name="date" value="<?php echo $datee; ?>" /> to <input type="date" name="date2" value="<?php echo $datee2; ?>"/>
Order By <select name="orderby">
<option value="pay_date">By Date</option>
<option value="checked_by">By Counter</option>
</select>
<input type="submit" name="submit" value="Find"/>
</form>
<?php

$submit=$_GET['submit'];
$orderby=$_GET['orderby'];

if($submit!=''){
//$college=$_GET['college'];
//$CourseType=$_GET['CourseType'];
//$Course=$_GET['Course'];
//$Course_Details=$_GET['Course_Details'];
$queryyo = "SELECT * FROM college_info where code='$code'";
$numresultsyo=mysql_query($queryyo);
$resultyo= mysql_query($queryyo) or die("Couldn't execute query");
$a_rowwo = mysql_fetch_row( $resultyo );
 ?>
</Br>
<style>
td{
font-family:"Times New Roman", Times, serif;
font-size:12px;}
</style>

<table width="100%" border="1" cellspacing="0" cellpadding="1" class="table table-bordered table-striped">
  <tr>
    <td colspan="27" ><table width="100%" border="0" cellspacing="0" cellpadding="2">
              <tr>
                <td><div align="center"><img src="../<?php echo $a_rowwo['4']; ?>" width="107" height="101" /></div></td>
                <td><div align="center" class="style1" ><strong><?php echo $a_rowwo['2']; ?><br />
                  ( <?php echo $a_rowwo['1']; ?>)</strong></div>
                  <div align="center" class="style1" ><?php echo $a_rowwo['3']; ?></div>
                  
                  <div align="center" class="style1" > ( Affiliated to Dr. Ram Manohar Lohia Avadh University, Faizabad )</div></td>
              </tr>
    </table></td>
  </tr>
  
  <tr>
    <td ><span class="style3 style1">S.No.</span></td>
    <td ><span class="style3 style1">Roll No</span></td>
    <td >R.No.</td>
    <td ><span class="style3 style1">Pay Date</span></td>
    <td ><span class="style3 style1">Course Type</span></td>
    <td ><span class="style3 style1">Course</span></td>
    <td ><span class="style3 style1">Year</span></td>
    <td ><span class="style3 style1">Student Name</span></td>
    <td ><span class="style3 style1">Fathers Name</span></td>
    <td ><span class="style3 style1">Mothers Name</span></td>
    <td bgcolor="#CCCCCC" >Total Course Fee</td>
    <td bgcolor="#FFFFFF" >Admission Fee</td>
    <td bgcolor="#FFFFFF" >Practical Fee</td>
    <td bgcolor="#FFFFFF" >Practical File Fee</td>
    <td bgcolor="#FFFFFF" >UIN Fee</td>
    <td bgcolor="#FFFFFF" >Other Fee</td>
    <td bgcolor="#FFFFFF" >Other Fee - 2</td>
    <td bgcolor="#CCCCCC" ><span class="style1"><strong>Pay Fees</strong></span></td>
    <td bgcolor="#FFFFFF" >Admission Fee</td>
    <td bgcolor="#FFFFFF" >Practical Fee</td>
    <td bgcolor="#FFFFFF" >Practical File Fee</td>
    <td bgcolor="#FFFFFF" >UIN Fee</td>
    <td bgcolor="#FFFFFF" >Other Fee</td>
    <td bgcolor="#FFFFFF" >Other Fee - 2</td>
    <td bgcolor="#CCCCCC" ><span class="style3 style1">Discount Amount</span></td>
    <td bgcolor="#CCCCCC" >Due Fee</td>
    <td ><span class="style3 style1">Checked By</span></td>
  </tr>
  
    
     <?php

$query = "SELECT * FROM pay_fees WHERE pay_date>='$datee' and pay_date<='$datee2' and session='$session' and code='$code' order by $orderby";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");
if($numrows!=''){
?>

<?php 
$counter = 1;?>
 <?php
while ( $a_row = mysql_fetch_array( $result ) )
 {
 $sv=$a_row[9];
 $code=$a_row[7];
 ?>
   <tr>
    <td><?php echo $counter; ?></td>
    <td><?php echo $a_row['roll_no']; ?></td>
    <td><?php echo $code.'-'.$a_row['id']; ?></td>
    <td><?php echo $a_row['pay_date']; ?></td>
    <td><?php echo $a_row['college_type']; ?></td>
    <td> <?php 
$queryy = "SELECT * FROM course_name where college_id='$code' && id='$sv' and session='$session' and code='$code'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
 ?>
	                 
	                 <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
	                 <?php 
				  
				 $course_namei=$a_row['sv'];
				//echo $course_namei;
				
				 $Course_id=$a_roww[0];
				 if($Course_id==$course_namei){
				  ?> 
	                 <?php echo $a_roww[1];?>
	                 <?php } ?> 
                     <?php } ?></td>
    <td><?php echo $a_row['sem_yer']; ?></td>
    <td><?php
	$roll_no=$a_row['roll_no'];
	$queryy = "SELECT * FROM class2 where college_roll='$roll_no' and session='$session' and code='$code'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
$a_rowop = mysql_fetch_array($resulty );
	
	 echo $a_rowop['StudentName']; ?></td>
    <td><?php echo $a_rowop['FatherName']; ?></td>
    <td><?php echo $a_rowop['MotherName']; ?></td>
    
    <td bgcolor="#CCCCCC"><div align="right">
        <?php $tofees=$a_rowop['total_fees']; ?>
    <?php echo $tofees; 
			   
			   ?>    </div></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[13]; $payy1+=$a_row[13];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[14]; $payy2+=$a_row[14];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[15]; $payy3+=$a_row[15];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[16]; $payy4+=$a_row[16];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[17]; $payy5+=$a_row[17];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[18]; $payy6+=$a_row[18];?></td>
    <td bgcolor="#CCCCCC"><div align="right"><strong><?php echo $pay_amount4=$a_row['pay_amount']; ?></strong></div></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[19]; $duee1+=$a_row[19];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[20]; $duee2+=$a_row[20];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[21]; $duee3+=$a_row[21];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[22]; $duee4+=$a_row[22];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[23]; $duee5+=$a_row[23];?></td>
    <td bgcolor="#FFFFFF"><?php echo $a_row[24]; $duee6+=$a_row[24];?></td>
    <td bgcolor="#CCCCCC"><div align="right"><?php echo $dis_amount4=$a_row['dis_amount']; ?>
     <?php
			$roll=$a_row['college_roll'];				
$queryy = "SELECT * FROM pay_fees where roll_no='$roll' and session='$session' and code='$code'";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
?>
          
        <?php
while ( $a_rowd = mysql_fetch_row( $resulty ) )
 {?>
          
        <?php
 $dis1=$a_rowd[5];
    $pay1=$a_rowd[4];
  
  $pay2+=$pay1;
  $dis2+=$dis1;  
  } 
			    $s1=$tofees-$dis2;
			   $dues3=$s1-$pay2;
			  
  ?>
          
        <?php echo $dis2; $ty=$pay_amount4+$dis2 ?> 
    
    </div></td>
    <td bgcolor="#CCCCCC"><?php echo $tu=$tofees-$ty; ?></td>
    <td><?php echo $a_row['checked_by']; ?></td>
  </tr>
  
  
  <?php $counter++;
   $pay_amount2+=$a_row['pay_amount'];
  $dis_amount2+=$a_row['dis_amount'];
  $tofeesd+=$tofees;
  $tua+=$tu;
  } ?>
  <tr>
 
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC"><div align="center" class="style4">
      <div align="right"><?php echo $tofeesd; ?></div>
    </div></td>
    <td bgcolor="#FFFFFF"><?php echo $payy1;?></td>
    <td bgcolor="#FFFFFF"><?php echo $payy2; ?></td>
    <td bgcolor="#FFFFFF"><?php echo $payy3;?></td>
    <td bgcolor="#FFFFFF"><?php echo $payy4;?></td>
    <td bgcolor="#FFFFFF"><?php echo $payy5;?></td>
    <td bgcolor="#FFFFFF"><?php echo $payy6;?></td>
    <td bgcolor="#CCCCCC"><div align="right"><strong><?php echo $pay_amount2; ?></strong></div></td>
    <td bgcolor="#FFFFFF"><?php echo $duee1;?></td>
    <td bgcolor="#FFFFFF"><?php echo $duee2;?></td>
    <td bgcolor="#FFFFFF"><?php echo $duee3;?></td>
    <td bgcolor="#FFFFFF"><?php echo $duee4;?></td>
    <td bgcolor="#FFFFFF"><?php echo $duee5;?></td>
    <td bgcolor="#FFFFFF"><?php echo $duee6;?></td>
    <td bgcolor="#CCCCCC"><div align="right"><strong><?php echo $dis_amount2; ?></strong></div></td>
    <td bgcolor="#CCCCCC"><?php echo $tua; ?></td>
    <td>&nbsp;</td>
  </tr> <?php }else{
?><tr>
 
    <td colspan="27">
<div align="center" style="font-size:16px; color:#FF0000;">No Records Found</div></td>
<?php } ?>
</table>



<?php  }
 ?>