<?php 
session_start();
include 'dbc.php';

date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");

$userid=$_SESSION["userid"];
$month_name=$_POST["month_name"];


  
 $sqlgfine = "SELECT * FROM issueslip where month_name='$month_name' and user_id='$userid'";
$resultgfine=$conn->query($sqlgfine);
while($rowgfine = $resultgfine->fetch_assoc())
 
  {
$adm_no1=$rowgfine['adm_no'];
$class_name=$rowgfine['class_name'];
$fee=$rowgfine['mfee'];
$fee1=$rowgfine['fee1'];
$fee2=$rowgfine['fee2'];
$fee3=$rowgfine['fee3'];
$fee4=$rowgfine['fee4'];
$fee5=$rowgfine['fee5'];
$fee6=$rowgfine['fee6'];
   
    $sqlchallan = "SELECT * FROM admission where adm_no='$adm_no1' and user_id='$userid'";
$resultchallan=$conn->query($sqlchallan);
$rowchallan = $resultchallan->fetch_assoc();

 
$feebal=$rowchallan['bal'];
$feebal1=$rowchallan['feebal1'];
$feebal2=$rowchallan['feebal2'];
$feebal3=$rowchallan['feebal3'];
$feebal4=$rowchallan['feebal4'];
$feebal5=$rowchallan['feebal5'];
$feebal6=$rowchallan['feebal6'];
   $tfeebal= $feebal - $fee;
   $tfeebal1= $feebal1 - $fee1;
$tfeebal2= $feebal2 - $fee2;
$tfeebal3= $feebal3 - $fee3;
$tfeebal4= $feebal4 - $fee4;
$tfeebal5= $feebal5 - $fee5;
$tfeebal6= $feebal6 - $fee6;
 $sql1 = "update admission set 
bal='$tfeebal', feebal1='$tfeebal1' , feebal2='$tfeebal2', feebal3='$tfeebal3', feebal4='$tfeebal4', feebal5='$tfeebal5', feebal6='$tfeebal6' where adm_no='$adm_no1' and user_id='$userid'";
$conn->query($sql1);
	
	$sql = "delete from issueslip where month_name='$month_name' and user_id='$userid'";
$conn->query($sql);

	
	 }
header("location:Del_all_Challan.php");

?>
