<?php
include "dbconfig.php";
include "sendsms.php";
session_start();
$login_session=$_SESSION['login_user']; 
if($login_session==""){
		?>
        <h1>Please Login Again.........</h1>
        <script type="text/javascript">

				 <!--

					function Redirect() {

					   window.location="http://rnsc.mdsoftware.co.in/old/admin/";

					}

					document.write("<h1>You will be redirected to main page in 10 sec.</h1>");

					setTimeout('Redirect()', 1000);

				 //-->

			  </script>
        <?php
}

$fno=$_GET['fno'];

$class_app=$_GET['all_game_valueb'];

$CourseType=$_GET['CourseType'];

$Course=$_GET['Course'];

$Course_Details=$_GET['Course_Details'];

$session=$_GET['session'];

$Student_Type=$_GET['Student_Type'];

$college=$_GET['college'];
$sd=$_GET['sd'];

?>

<style type="text/css">

<!--

.style1 {

	color: #FFFFFF;

	font-weight: bold;

}

-->

</style>



<div align="center">

<iframe src="../print_form.php?fno=<?php echo $fno;?>&&btnSave2=Save&&all_game_valueb=<?php echo $class_app;?>&&CourseType=<?php echo $CourseType;?>&&Course=<?php echo $Course;?>&&Course_Details=<?php echo $Course_Details;?>&&session=<?php echo $session;?>&&Student_Type=<?php echo $Student_Type;?>&&college=<?php echo $college;?>" width="1000" height="800" scrolling="yes"></iframe></div>





<?php

		$Submit=$_GET['Submit'];

		if($Submit!=''){

		$status=$_GET['status'];

		$college_roll=$_GET['college_roll'];
		
	
		$total_fees=$_GET['ghtotal'];
$admin=$_GET['admin'];
$para=$_GET['para'];
$pra_file_fee=$_GET['pra_file_fee'];
$uin_fee=$_GET['uin_fee'];
$other_fee=$_GET['other_fee'];
$other_fee2=$_GET['other_fee2'];
		$pay_fee=$admin+$para+$pra_file_fee+$uin_fee+$other_fee+$other_fee2;

		$pay_date=$_GET['pay_date'];

		$checked_by=$_GET['checked_by'];
$dis_admin=$_GET['dis_admin'];
$dis_parac=$_GET['dis_parac'];
$dis_para_file=$_GET['dis_para_file'];
$dis_uin=$_GET['dis_uin'];
$dis_other=$_GET['dis_other'];
$dis_other2=$_GET['dis_other2'];;
$dis_amount=$dis_admin+$dis_parac+$dis_para_file+$dis_uin+$dis_other+$dis_other2;
$fees_8=$_GET['fees_8'];
$fees_2=$_GET['fees_2'];
$fees_9=$_GET['fees_9'];
$fees_10=$_GET['fees_10'];
$fees_11=$_GET['fees_11'];
$fees_12=$_GET['fees_12'];
$note=$_GET['note'];
$sd=$_GET['sd'];
$disc=$total_fees-$pay_fee;
///////////////////////////////////////////////
$dis_admin1=$dis_admin+$admin;
$dis_parac1=$dis_parac+$para;
$dis_para_file1=$dis_para_file+$pra_file_fee;
$dis_uin1=$dis_uin+$uin_fee;
$dis_other1=$dis_other+$other_fee;
$dis_other21=$dis_other2+$other_fee2;
//////////////////////////////
if(($admin>$fees_8)||($para>$fees_2)||($pra_file_fee>$fees_9)||($uin_fee>$fees_10)||($other_fee>$fees_11)||($other_fee2>$fees_12)){
echo "<center><h1>Please Fill Correct Amount of Pay Fee (Grater Than Dues Amount Please Check it)</h1></center>";
}
elseif(($dis_admin1>$fees_8)||($dis_parac1>$fees_2)||($dis_para_file1>$fees_9)||($dis_uin1>$fees_10)||($dis_other1>$fees_11)||($dis_other21>$fees_12)){
echo "<center><h1>Please Fill Correct Amount of Discount Fee (Grater Than Dues Amount Please Check it)</h1></center>";
}elseif($dis_amount>$disc){
		echo "<center><h1>Please Fill Correct Amount of Discount Text Box</h1></center>";

		}elseif(($pay_fee!='')&&($dis_amount<=$disc)){

//////////////////////////////////////

		$queryyp = "SELECT * FROM class2 where college_roll='$college_roll' and session='$session' and code='$code'";

$numresultsyp=mysql_query($queryyp);

$resultyp= mysql_query($queryyp) or die("Couldn't execute query");

$a_rowwp = mysql_fetch_array( $resultyp );

$crollp=$a_rowwp['college_roll'];
$MobileNO=$a_rowwp['MobileNO'];

//echo '********'.$crollp.'--'.$college_roll;



if($college_roll!=''){



		
//$mnoo=$a_rowwp['MobileNO'];
//$message2="**Fees Details**
//Pay Date : $pay_date
//Admission Fees : $pay_fee
//Discount : $dis_amount
//For any Query : Please Contact to College.";
//$sendsms=new sendsms("http://speed.mdsoftech.com/api/v3",'sms',"A6855b25535ba62be5b9d8be5233350ca", "BVSPMV");
//$sendsms->send_sms("$mnoo", "$message2", 'http://speed.mdsoftech.com/thankyou.php&custom=XX', 'xml');
		
		 


if($crollp==""){
$query = "UPDATE class2 SET status='$status',college_roll='$college_roll',total_fees='$total_fees',pay_fee='$pay_fee',pay_date='$pay_date',checked_by='$checked_by' WHERE fno='$fno' and session='$session' and code='$code'";
}elseif($crollp!=""){
$query = "UPDATE class2 SET status='$status',total_fees='$total_fees',pay_fee='$pay_fee',pay_date='$pay_date',checked_by='$checked_by' WHERE fno='$fno' and session='$session' and code='$code'";
}
 $result = mysql_query( $query );

 if ( ! $result )

die ("Couldn't update: ".mysql_error());

print "<h1>Table Updated ". mysql_affected_rows() .

" row(s) updated</h1>";

 /////////////////////////////////////////////////////////////////
$sem_year23=$a_rowwp['Course_Details'];
$college_type23=$a_rowwp['CourseType'];
$sv23=$a_rowwp['Course'];

if(($college_roll!='')&&($sd!='')){
echo "****************************";
 $queryY = "INSERT INTO `pay_fees` (`id`, `roll_no`, `pay_date`, `pay_time`, `pay_amount`, `dis_amount`, `checked_by`, `code`, `college_type`, `sv`, `sem_yer`, `note`, `sd`, `admin`, `para`, `para_file`, `uin`, `other`, `other2`, `dis_admin`, `dis_parac`, `dis_para_file`, `dis_uin`, `dis_other`, `dis_other2`,`session`) VALUES ('$id','$fno','$pay_date','$pay_time','$pay_fee','$dis_amount','$checked_by','$college','$CourseType','$Course','$Course_Details','$note','$sd','$admin','$para','$pra_file_fee','$uin_fee','$other_fee','$other_fee2','$dis_admin','$dis_parac','$dis_para_file','$dis_uin','$dis_other','$dis_other2','$session'
)";

 $resultY = mysql_query( $queryY );

 ////////////////////////////////////////////////////////////////

 if ( ! $resultY )

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="veri_form_2.php?fno=<?php echo $fno;?>&&btnSave2=Save&&all_game_valueb=<?php echo $class_app;?>&&CourseType=<?php echo $CourseType;?>&&Course=<?php echo $Course;?>&&Course_Details=<?php echo $Course_Details;?>&&session=<?php echo $session;?>&&Student_Type=<?php echo $Student_Type;?>&&college=<?php echo $college;?>";

            }

            

            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");

            setTimeout('Redirect()', 1000);

         //-->

      </script>

<?php

		}

		}}

							

$queryy = "SELECT * FROM class2 where fno='$fno' and session='$session' and code='$code'";

$numresultsy=mysql_query($queryy);

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

$a_roww = mysql_fetch_array( $resulty );

$st=$a_roww['status'];

$collegeop=$a_roww['college'];

$college_rollt=$a_roww['college_roll'];
$tofees=$a_roww['total_fees'];

 if($st!="Locked"){?>

<form name="form1" method="get" action="veri_form_2.php">

<input name="fno" value="<?php echo $fno; ?>" type="hidden" >

<input name="all_game_valueb" value="<?php echo $class_app; ?>" type="hidden" >

<input name="CourseType" value="<?php echo $CourseType; ?>" type="hidden" >

<input name="Course" value="<?php echo $Course; ?>" type="hidden" >

<input name="Course_Details" value="<?php echo $Course_Details; ?>" type="hidden" >

<input name="session" value="<?php echo $session; ?>" type="hidden" >

<input name="Student_Type" value="<?php echo $Student_Type; ?>" type="hidden" >

<input name="college" value="<?php echo $collegeop; ?>" type="hidden" >






<table width="100%" border="0" cellspacing="2" cellpadding="2" align="center" bgcolor="#999999" >

  <tr>

    <td colspan="2"><div align="center"><strong>Student Verification </strong></div></td>

  </tr>

  <tr>

    <td ><strong>College Roll Number</strong></td>

    <td ><label>

         <?php	

	

$queryi = "SELECT * FROM class2 where Course='$Course' and Course_Details='$Course_Details' and session='$session' and code='$code' ORDER BY college_roll DESC";

$numresultsi=mysql_query($queryi);

 $numrowsi=mysql_num_rows($numresultsi);

$resulti = mysql_query($queryi) or die("Couldn't execute query");

$a_rowwi = mysql_fetch_array($resulti, MYSQL_BOTH);



$rn=$a_rowwi['college_roll'];  echo $rn.'*********';

?> 



<?php

if($rn==""){

$queryo = "SELECT * FROM fees where code='$college' and class='$Course' and section='$Course_Details' and session='$session' and code='$code'";

$numresultso=mysql_query($queryo);

 $numrowso=mysql_num_rows($numresultso);

$resulto = mysql_query($queryo) or die("Couldn't execute query");

$a_rowwo = mysql_fetch_array($resulto, MYSQL_BOTH);

$counter = 1;

$time=$a_rowwo['rollno'];

}else{

$time=$a_rowwi['college_roll']+1; //echo $time;

}





?>

      <input type="text" name="college_roll" id="college_roll" value="<?php if($college_rollt!=""){ echo $college_rollt;}else{ echo $time; }; ?>" readonly required>

    </label></td>

  </tr>

  <tr>

    <td><strong>Total Course Fees</strong></td>

    <td><label>

    <?php echo $tofees; ?>

    </label> <table width="100%" border="1" cellspacing="2" cellpadding="2" bgcolor="#CCCCCC">
      <tr>
    <td><strong>Fee Head</strong></td>
    <td><strong>Total Fee</strong></td>
    <td><strong>Discount</strong></td>
    <td><strong>Pay</strong></td>
  </tr>

  <tr>
    <td>Admission Fee</td>
    <td><input type="text" readonly="readonly" name="fees_8" value="<?php echo $fees_8; ?>"/></td>
    <td><input type="text" name="dis_admin" id="dis_admin" <?php if($_SESSION['login_type']!='admin'){ ?>readonly="readonly" <?php } ?>  required="required" value="<?php echo $dis_admin; ?>" <?php if($dis_admin>$fees_8){ ?>style="color:#FF0000"<?php }else{ ?> style="color:#009900" <?php } ?>/><?php if($dis_admin>$fees_8){ ?><div style="background-color:#FFFF00; color:#FF0000; font-size:14px;">Wrong Entry</span><?php }else{ ?><span style="color:#009900; font-size:14px;">Correct Entry</span><?php } ?></td>
    <td><input type="text" name="admin" id="admin" value="<?php echo $admin; ?>" required>
    <?php if($dis_admin1>$fees_8){ ?><div style="background-color:#FFFF00; color:#FF0000; font-size:14px;">Wrong Entry</span><?php }else{ ?><span style="color:#009900; font-size:14px;">Correct Entry</span><?php } ?>
    </td>
  </tr>
  
  <tr>
    <td><strong></strong></td>
    <td><strong>Total Fee=<?php echo $ghtotal=$fees_8; ?>
    <input type="hidden" name="ghtotal" id="ghtotal" value="<?php echo $ghtotal; ?>" required>
    </strong></td>
    <td><strong></strong></td>
    <td><strong></strong></td>
  </tr>
</table></td>

  </tr>

  <tr>

    <td><strong>Pay Fees</strong></td>

    <td><label>

      

    </label></td>

  </tr>

 

  <tr>

    <td><strong>Pay Date</strong></td>

    <td><label>

      <input type="date" name="pay_date"  id="pay_date" value="<?php 

	if (function_exists('date_default_timezone_set'))

{

  date_default_timezone_set('Asia/Kolkata');

}



echo date('Y-m-d');

	?>" required>

    </label></td>

  </tr>

  <tr>

    <td><strong>Checked By</strong></td>

    <td><label>

      <input type="text" name="checked_by" id="checked_by" value="<?php $login_session=$_SESSION['login_user']; echo $login_session;?>" readonly required>

    </label></td>

  </tr>

  <tr>

    <td><strong>Form Status</strong></td>

    <td><label>

      <input type="text" name="status" id="status" value="Locked" readonly required>

    </label></td>

  </tr>

  <tr>

    <td><strong>Note</strong></td>

    <td><label>

      <textarea name="note" id="note" required="required"></textarea>

    </label></td>

  </tr>

  <tr>

    <td>&nbsp;</td>

    <td><label>
<input type="text" name="sd" id="sd" value="<?php 

	if (function_exists('date_default_timezone_set'))

{

  date_default_timezone_set('Asia/Kolkata');

}



echo date('YmdHis');

	?>" readonly required>
      <input type="submit" name="Submit" id="Submit" value="Submit">

    </label></td>

  </tr>

</table>

</form>

<?php } else { ?>

<table width="90%" border="0" cellspacing="2" cellpadding="2" align="center" bgcolor="#009900">

  <tr>

    <td colspan="2"><div align="center" style="background:#990000; color:#FFFFFF; font-size:26px;">Student Verification Report</div></td>
  </tr>

  <tr>

    <td width="246"><span class="style1">College Roll Number</span></td>

    <td width="240"><span class="style1">

      <label>

      <?php echo $college_rollt; ?>      </label>

    </span></td>
  </tr>

  <tr>

    <td><span class="style1">Total Course Fees</span></td>

    <td><span class="style1">

      <label>
<?php echo $tofees; ?>
     	          </label>

    </span>    </td>
  </tr>
  <tr>



			<td><span class="style1">Pay Fees Details</span></td>



			<td><label>



		<table width="100%" border="1" cellspacing="2" cellpadding="2" bgcolor="#FFFFFF">



		  <tr bordercolor="#0000FF" style=" background-color:#0000CC;color:#FFFFFF">
		    <td rowspan="2">R.No.</td>
		    <td rowspan="2">Pay Date/Time</td>
		    <td colspan="6"><div align="center">Fee Head Pay</div></td>
            <td rowspan="2">Total Pay Amount</td>
		    <td colspan="6" bordercolor="#FFFFFF"><div align="center">Fee Head Discount</div></td>
		    <td rowspan="2">Total Discount</td>
		    
		    <td rowspan="2">Checked By</td>
		    <td rowspan="2">Print</td>
	      </tr>
		  <tr bordercolor="#0000FF" style=" background-color:#0000CC;color:#FFFFFF">



		    <td>Adm. Fee <br/><?php echo $fees_8; ?></td>
			<td>Pra. Fee<br/><?php echo $fees_2; ?></td>
			<td><?php echo $a_rowx[14]; ?><br/><?php echo $fees_9=$fees_9; ?></td>
			<td><?php echo $a_rowx[15]; ?><br/><?php echo $fees_10; ?></td>
			<td><?php echo $a_rowx[16]; ?><Br/><?php echo $fees_11; ?></td>
			<td><?php echo $a_rowx[17]; ?><br/><?php echo $fees_12; ?></td>
		    <td bordercolor="#FFFFFF">Adm. Fee</td>
		    <td bordercolor="#FFFFFF">Pra. Fee</td>
		    <td bordercolor="#FFFFFF"><?php echo $a_rowx[14]; ?></td>
		    <td bordercolor="#FFFFFF"><?php echo $a_rowx[15]; ?></td>
		    <td bordercolor="#FFFFFF"><?php echo $a_rowx[16]; ?></td>
		    <td bordercolor="#FFFFFF"><?php echo $a_rowx[17]; ?></td>
		  </tr>



		



		



			<?php



					$roll=$a_roww['fno'];				



		$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 ) )



		 {



		 echo $idd=$a_rowd[9];



 $check_exist_qryfe="select * from course_name where id='$idd' and session='$session' and code='$code'";



$run_qryfe=mysql_query($check_exist_qryfe);



$total_foundfe=mysql_num_rows($run_qryfe);



$roww_fe = mysql_fetch_array($run_qryfe, MYSQL_BOTH);



		 ?>



					   



						  



					   



					   



					 <tr bgcolor="#FFFF33">



					   <td><?php echo $a_rowd[0];?></td>



					   <td><?php echo $a_rowd[2];?>/<?php echo $a_rowd[3];?>{ <?php echo $roww_fe['course_name']; ?>-<?php echo $a_rowd[10];?> }</td>



			           <td>
                <a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=2')"<?php } ?>><?php echo $a_rowd[13]; $payy1+=$a_rowd[13];?></a></td>
			           <td><a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=1')"<?php } ?>><?php echo $a_rowd[14]; $payy2+=$a_rowd[14];?></a></td>
			           <td><a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=3')"<?php } ?>><?php echo $a_rowd[15]; $payy3+=$a_rowd[15];?></a></td>
			           <td><a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=4')"<?php } ?>><?php echo $a_rowd[16]; $payy4+=$a_rowd[16];?></a></td>
			           <td><a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=5')"<?php } ?>><?php echo $a_rowd[17]; $payy5+=$a_rowd[17];?></a></td>
			           <td><a <?php if($pr=='Headwise'){ ?>href="print_fees_head.php" onClick="return popitup('print_fees_head.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>&&head=6')"<?php } ?>><?php echo $a_rowd[18]; $payy6+=$a_rowd[18];?></a></td>
                       <td><?php echo $pay1=$a_rowd[4]; $ggtotal+=$a_rowd[4];?>/-</td>
			           <td><?php echo $a_rowd[19]; $duee1+=$a_rowd[19];?></td>
			           <td><?php echo $a_rowd[20]; $duee2+=$a_rowd[20];?></td>
			           <td><?php echo $a_rowd[21]; $duee3+=$a_rowd[21];?></td>
			           <td><?php echo $a_rowd[22]; $duee4+=$a_rowd[22];?></td>
			           <td><?php echo $a_rowd[23]; $duee5+=$a_rowd[23];?></td>
			           <td><?php echo $a_rowd[24]; $duee6+=$a_rowd[24];?></td>
			           <td><?php echo $dis1=$a_rowd[5]; $dgtotal+=$a_rowd[5];?>/-</td>



			



			<td><?php echo $a_rowd[6];?></td>



		    <td><script language="JavaScript" type="text/javascript">



<!--



function popitup(url) {



	newwindow=window.open(url,'print_fees','height=600,width=800');



	if (window.focus) {newwindow.focus()}



	return false;



}







// -->



            </script>

<?php if($pr!='Headwise'){ ?>
                <a href="print_fees.php" onClick="return popitup('print_fees.php?fno=<?php echo $fno;?>&&college=<?php echo $college;?>&&rno=<?php echo $a_rowd[0];?>')">Print</a><?php } ?> &nbsp;<?php $login_type=$_SESSION['login_type'];  if($login_type=='admin'){ ?>
<?php  //if($st==""){ ?>
<a href="debit_delete_fees.php?fno=<?php echo $a_roww['fno'];?>&&id=<?php echo $a_rowd[0];?>&&table=pay_fees" onClick="return confirm('Are you sure you want to Delete This Fees Records...?')">Delete</a><?php }else{ ?>
Not Delete
<?php //}
} ?></td>
		 


					 



				<?php 



		  $pay2+=$pay1;



		  $dis2+=$dis1;  



		  } ?>
 </tr>
					 <tr bgcolor="#FF0000" style="color:#FFFFFF">
					   <td>&nbsp;</td>
					   <td>&nbsp;</td>
					   <td><?php echo $payy1;?></td>
					   <td><?php echo $payy2; ?></td>
					  <td><?php echo $payy3;?></td>
			           <td><?php echo $payy4;?></td>
			           <td><?php echo $payy5;?></td>
			           <td><?php echo $payy6;?></td>
			           <td><?php echo $ggtotal;?>/-</td>
			           <td><?php echo $duee1;?></td>
                       <td><?php echo $duee2;?></td>
			           <td><?php echo $duee3;?></td>
			           <td><?php echo $duee4;?></td>
			           <td><?php echo $duee5;?></td>
			           <td><?php echo $duee6;?></td>
			           <td><?php echo $dgtotal;?>/-</td>
			           <td>&nbsp;</td>
			           <td>&nbsp;</td>
	      </tr>


				<tr >



				  <td colspan="18"><table width="100%" border="0" cellspacing="2" cellpadding="2">



					<tr>



					  <td width="56%"><div align="right">Total Course Fees</div></td>



					  <td width="13%"><div align="right"><strong><?php echo $tofees; 



						$s1=$tofees-$dis2;



					   $dues3=$s1-$pay2;



					   ?>/-</strong></div></td>



					  <td width="31%">&nbsp;</td>
					</tr>



					<tr>



					  <td><div align="right">Total Discount</div></td>



					  <td><div align="right"><strong>-<?php echo $dis2; ?>/-</strong></div></td>



					  <td>&nbsp;</td>
					</tr>



					<tr>



					  <td><div align="right">Your Total Course Fees After Adustment</div></td>



					  <td><div align="right"><?php echo $s1; ?>/-</div></td>



					  <td>&nbsp;</td>
					</tr>



					<tr>



					  <td><div align="right">Total Pay Amount</div></td>



					  <td><div align="right"><strong><?php echo $pay2; ?>/-</strong></div></td>



					  <td>&nbsp;</td>
					</tr>



					<tr>



					  <td><div align="right">Total Dues</div></td>



					  <td><div align="right">





						<?php echo $dues3; ?>/-



					  </div></td>



					  <td>&nbsp;</td>
					</tr>



					



				  </table></td>
				</tr>
		</table>



			




			



			</label></td>



		  </tr>

  

  

  <tr>

    <td><span class="style1">Form Checked By</span></td>

    <td><span class="style1">

      <label>

      <?php echo $a_roww['checked_by']; ?>      </label>

    </span></td>
  </tr>

  <tr>

    <td><span class="style1">Form Status</span></td>

    <td><span class="style1">

      <label>

      <?php echo $a_roww['status']; ?>      </label>

    </span></td>
  </tr>
</table>



<?php } ?>
