
<?php
session_start();
include("include/dbconnect.php");
extract($_REQUEST);
$sid=$_REQUEST['id'];
$mq=mysql_query("select * from studenttbl where id='$sid'");
$mr=mysql_fetch_array($mq);
$bc=$mr['batchCode'];
$name=$mr['name'];
$cname=$mr['collegeName'];
$coursename=$mr['courseName'];
$mob=$mr['contactNo'];
$emailid=$mr['emailId'];

?>

<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords"
        content="wrappixel, admin dashboard, html css dashboard, web dashboard, bootstrap 5 admin, bootstrap 5, css3 dashboard, bootstrap 5 dashboard, Ample lite admin bootstrap 5 dashboard, frontend, responsive bootstrap 5 admin template, Ample admin lite dashboard bootstrap 5 dashboard template">
    <meta name="description"
        content="Ample Admin Lite is powerful and clean admin dashboard template, inpired from Bootstrap Framework">
    <meta name="robots" content="noindex,nofollow">
    <title>No1 Technologies</title>
    <link rel="canonical" href="https://www.wrappixel.com/templates/ample-admin-lite/" />
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="plugins/images/favicon.png">
    <!-- Custom CSS -->
   <link href="css/style.min.css" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->


</head>

<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <div class="lds-ripple">
            <div class="lds-pos"></div>
            <div class="lds-pos"></div>
        </div>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper" data-layout="vertical" data-navbarbg="skin5" data-sidebartype="full"
        data-sidebar-position="absolute" data-header-position="absolute" data-boxed-layout="full">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
        <header class="topbar" data-navbarbg="skin5">
            <nav class="navbar top-navbar navbar-expand-md navbar-dark">
                <div class="navbar-header" data-logobg="skin6">
                    <!-- ============================================================== -->
                    <!-- Logo -->
                    <!-- ============================================================== -->
                    <a class="navbar-brand" href="dashboard.html">
                        <!-- Logo icon -->
                        <b class="logo-icon">
                            <!-- Dark Logo icon -->
                            <img src="plugins/images/logo-icon.png" alt="homepage" />
                        </b>
                        <!--End Logo icon -->
                        <!-- Logo text -->
                        <span class="logo-text">
                            <!-- dark Logo text -->
                            <img src="plugins/images/logo-text.png" alt="homepage" />
                        </span>
                    </a>
                    <!-- ============================================================== -->
                    <!-- End Logo -->
                    <!-- ============================================================== -->
                    <!-- ============================================================== -->
                    <!-- toggle and nav items -->
                    <!-- ============================================================== -->
                    <a class="nav-toggler waves-effect waves-light text-dark d-block d-md-none"
                        href="javascript:void(0)"><i class="ti-menu ti-close"></i></a>
                </div>
                <!-- ============================================================== -->
                <!-- End Logo -->
                <!-- ============================================================== -->
                <div class="navbar-collapse collapse" id="navbarSupportedContent" data-navbarbg="skin5">
                    <ul class="navbar-nav d-none d-md-block d-lg-none">
                        <li class="nav-item">
                            <a class="nav-toggler nav-link waves-effect waves-light text-white"
                                href="javascript:void(0)"><i class="ti-menu ti-close"></i></a>
                        </li>
                    </ul>
                    <!-- ============================================================== -->
                    <!-- Right side toggle and nav items -->
                    <!-- ============================================================== -->
                    <ul class="navbar-nav ms-auto d-flex align-items-center">

                        <!-- ============================================================== -->
                        <!-- Search -->
                        <!-- ============================================================== -->
                        <li class=" in">
                            <form role="search" class="app-search d-none d-md-block me-3">
                                <input type="text" placeholder="Search..." class="form-control mt-0">
                                <a href="" class="active">
                                    <i class="fa fa-search"></i>
                                </a>
                            </form>
                        </li>
                        <!-- ============================================================== -->
                        <!-- User profile and search -->
                        <!-- ============================================================== -->
                        <li>
                            <a class="profile-pic" href="#">
                                <img src="plugins/images/users/varun.jpg" alt="user-img" width="36"
                                    class="img-circle"><span class="text-white font-medium">Steave</span></a>
                        </li>
                        <!-- ============================================================== -->
                        <!-- User profile and search -->
                        <!-- ============================================================== -->
                    </ul>
                </div>
            </nav>
        </header>
        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <aside class="left-sidebar" data-sidebarbg="skin6">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
                <!-- Sidebar navigation-->
                <nav class="sidebar-nav">
                    <ul id="sidebarnav">
                        <!-- User Profile-->
                        <li class="sidebar-item pt-2">
                            <a class="sidebar-link waves-effect waves-dark sidebar-link" href="Studentlist.php"
                                aria-expanded="false">
                                <i class="far fa-clock" aria-hidden="true"></i>
                                <span class="hide-menu">Student List</span>
                            </a>
                        </li>
                        <li class="sidebar-item">
                            <a class="sidebar-link waves-effect waves-dark sidebar-link" href="fees.php"
                                aria-expanded="false">
                                <i class="fa fa-user" aria-hidden="true"></i>
                                <span class="hide-menu">Fees</span>
                            </a>
                        </li>
                        <li class="sidebar-item">
                            <a class="sidebar-link waves-effect waves-dark sidebar-link" href="Reportnew.php"
                                aria-expanded="false">
                                <i class="fa fa-table" aria-hidden="true"></i>
                                <span class="hide-menu">Reports</span>
                            </a>
                        </li>
                       
                        
                       
                       
                    </ul>

                </nav>
                <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper" style="min-height: 250px;">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb bg-white">
                <div class="row align-items-center">
                    <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                        <h4 class="page-title">FEES UPDATE</h4>
                    </div>
                                <div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
                        <div class="d-md-flex">
                            <ol class="breadcrumb ms-auto">
                                <li><a href="#" class="fw-normal">Dashboard</a></li>
                            </ol>
                            <a href="Studentlist.php" 
                                class="btn btn-danger  d-none d-md-block pull-right ms-3 hidden-xs hidden-sm waves-effect waves-light text-white">
                                Student List</a>
                        </div>
                    </div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
             <form name="form1" action="" method="post">
			 <div class="row">
                    <div class="col-md-12">
                        <div class="white-box">
                            <h3 class="box-title">BATCH CODE: <?php echo $bc;?></h3>
	
	
	<div class="row">
	
	
	<script type="text/javascript">
	
add_number();
 function add_number() {
               
                var first_number = parseInt(document.getElementById("txtbalance").value);
                var second_number = parseInt(document.getElementById("txtinstallment").value);
                var result = first_number - second_number;
     
                document.getElementById("txtbalance").value = result;
            }
			
function validate()
{
	if(document.form1.txtinstallment.value=="")
	{
	alert("Enter the Paid Amount");
	document.form1.txtinstallment.focus();
	return false;
	}
	if (isNaN(document.form1.txtinstallment.value))
                {
                    alert("Enter only Numer Paid Amount");
                    document.form1.txtinstallment.select();
                    return false;
                }
	
	
return true;	
}	
</script>
	 <div class="col-sm-6">

   <div class="form-group row">
  <div class="col-xs-6">
    <label for="ex1">Name</label>
    <input class="form-control" id="txtname" value="<?php echo $mr['name'];?>" name="txtname"  onchange="myFunction(this.value)" type="text">
  </div>
   </div>
  
 <div class="col-xs-6">
    <label for="txtcourse">Course Name</label>
    <input class="form-control" id="txtcourse" value="<?php echo $mr['courseName'];?>" name="txtcourse" type="text">
  </div>
   
  
  <div class="col-xs-6">
    <label for="txttotal">Total Amount</label>
    <input class="form-control" id="txttotal" value="<?php echo $mr['totalAmount'];?>" name="txttotal" type="text">
  </div>
  
  <div class="col-xs-6">
    <label for="txtpaid">Paid Amount</label>
    <input class="form-control" id="txtpaid" value="<?php echo $mr['paidAmount'];?>" name="txtpaid"  type="text">
  </div>
   <div class="col-xs-6">
    <label for="txtbalance">Installment</label>
    <input class="form-control" id="txtinstallment"  onChange="add_number()" value="" name="txtinstallment" type="text">
  </div>
  
  <div class="col-xs-6">
    <label for="txtbalance">Balance</label>
    <input class="form-control" id="txtbalance"  value="<?php echo $mr['baalanceAmount'];?>" name="txtbalance" type="text">
  </div>
   <div class="col-xs-6">
  <input type="submit" name="btn"  value="Update" class="btn btn-primary" onclick="return validate()" style="width:50%;margin-top:10px;background-color:#f33155;"></button>
  </div>
   </div>
   
    <div class="col-sm-6">

   
 </div>
</div>
 
 
</div>

                        </div>
						</form>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer text-center"> 2021 © Ample Admin brought to you by <a
                    href="https://www.wrappixel.com/">wrappixel.com</a>
            </footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="js/app-style-switcher.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.js"></script>
	<?php
 $msg="";
	 	$rdate=date("d-m-Y");
	 if(isset($btn))
	 {
                                                      
        $mq2=mysql_query("select max(id) from feestbl");
		$mr2=mysql_fetch_array($mq2);
		$id2=$mr2['max(id)']+1;
		
			
		$mq3=mysql_query("select count(id) from feestbl where batchCode='$bc'");
		$mr3=mysql_fetch_array($mq3);
		$id3=$mr3['count(id)']+1;
		$cc=$txtcourse."- PART -".$id3;
		
		$insfees=mysql_query("insert into feestbl(id,batchCode,name,course,amountPaid,rdate) values($id2,'$bc','$txtname','$cc','$txtinstallment','$rdate')");
 		
		
		$paid=$_POST['txtpaid'];
$inst=$_POST['txtinstallment'];		

$totalpaid=$paid+$inst;



		
		
 		$ins=mysql_query("Update studenttbl set paidAmount='$totalpaid',baalanceAmount='$txtbalance' where batchCode='$bc'");
 		if($ins)
		{
			include('database.php');
$database = new Database();
		require('fpdf/fpdf.php');	
	$result1 = $database->runQuery("SELECT id,rdate,course,amountPaid FROM feestbl where batchCode='$bc'");
$header1 = $database->runQuery("SELECT UCASE(`COLUMN_NAME`)");	
$pdf=new FPDF();
$pdf->AddPage();
$height=0;
$pdf->Image('6.jpg',5,5);

$height=$height+33;
$pdf -> Line(5, $height, 200, $height);
$height=$height+10;
$pdf -> Line(5, $height, 200, $height);
$height=$height+25;
$pdf -> Line(5, $height, 200, $height);	
$height=$height+180;
$pdf -> Line(5, $height, 200, $height);
	

	
$pdf->SetFont('Arial','I',6);
$height=$height+4;
$pdf->SetXY(80, $height); // X start, Y start in mm
$text = "*THIS IS COMPUTER GENERATED INVOICE ";
$pdf->Write(0, $text);

$pdf->SetFont('Courier','B',10);
$height=$height+4;
$pdf->SetXY(25, $height); // X start, Y start in mm
$text = "No.169 , Stony Meadows, ";
$pdf->Write(0, $text);


$pdf->SetFont('Courier','B',10);

$pdf->SetXY(75, $height); // X start, Y start in mm
$text = "10 th Cross Ponnagar Extension,";
$pdf->Write(0, $text);


$pdf->SetFont('Courier','B',10);

$pdf->SetXY(140, $height); // X start, Y start in mm
$text = " Trichy - 620001.";
$pdf->Write(0, $text);


	$textheight=18;
$pdf->SetFont('Arial','B',10);
$pdf->SetXY(100, $textheight); // X start, Y start in mm
$text = "INVOICE ";
$pdf->Write(0, $text);


$textheight=38;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "BILL NO : ";
$pdf->Write(0, $text);

$pdf->SetXY(24, $textheight); // X start, Y start in mm
$text = $bc;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "INVOICE DATE:";
$pdf->Write(0, $text);

$pdf->SetXY(170, $textheight); // X start, Y start in mm
$text = $rdate;
$pdf->Write(0, $text);	

$pdf->SetFont('Arial','B',8);


$textheight=$textheight+9;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "TO : ";
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "COURSE DETAILS  ";
$pdf->Write(0, $text);

$textheight=$textheight+7;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text =$txtname;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text ="COURSE NAME : ".$txtcourse;
$pdf->Write(0, $text);


$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $cname;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "TOTAL AMT       : ".$txttotal;
$pdf->Write(0, $text);




$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $mob;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "PAID AMT           : ".$totalpaid;
$pdf->Write(0, $text);

$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $emailid;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "BALANCE AMT  : ".$txtbalance;
$pdf->Write(0, $text);

$textheight=$textheight+6;
//$pdf -> Line(95, $textheight, 200, $textheight);


//$textheight=$textheight+10;

$pdf->SetXY(85, $textheight); // X start, Y start in mm
$text = "BILLING SUMMERY " ;
$pdf->Write(0, $text);
$textheight=$textheight+5;
$pdf -> Line(5, $textheight, 200, $textheight);

$textheight=$textheight+5;

$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "S.NO";
$pdf->Write(0, $text);

$pdf->SetXY(7+40, $textheight); // X start, Y start in mm
$text = "DATE ";
$pdf->Write(0, $text);


$pdf->SetXY(7+80, $textheight); // X start, Y start in mm
$text = "DESCRIPTION ";
$pdf->Write(0, $text);

$pdf->SetXY(7+140, $textheight); // X start, Y start in mm
$text = "PAID AMOUNT ";
$pdf->Write(0, $text);



$textheight=$textheight+5;
$pdf -> Line(5, $textheight, 200, $textheight);
$j=1;

foreach($result1 as $row) {
	$textheight=$textheight+7;
	$pdf->Ln();
	$pdf->SetFont('Arial','',10);
	$textwidth=7;
	$i=1;
	foreach($row as $column)
	{
	
	
	$pdf->SetXY($textwidth, $textheight); // X start, Y start in mm


if($i==1)
{

	$pdf->Write(0, $j);
$textwidth=$textwidth+40;
$j=$j+1;
}
else if($i==2)
{
	$textwidth=$textwidth+40;
	$pdf->Write(0, $column);
}
else if($i==3)
{
	$textwidth=$textwidth+60;
	$pdf->Write(0, $column);
}

else if($i==4)
{
	$textwidth=$textwidth+70;
	$pdf->Write(0, $column);
}


$i=$i+1;
	}
	
		//$pdf->Cell(35,5,$column,1);
}



$dir="C:\\wamp\\www\\Billingno1\\bills\\";
$filename= $bc."-".$rdate.$cc.".pdf";
$pdf ->Output('F',$dir.$filename);	
//$pdf ->Output("F",'S');	







            ?>
	 <script language="javascript">
	 window.location.href="mailsend.php?fname=<?php echo $filename; ?>&mail=<?php echo $emailid; ?>";
	 </script>
	 <?php
	 	}
		else
		{
		 ?>
	 <script language="javascript">
	 window.location.href="aa.php";
	 </script>
	 <?php
		}
	
	 }
	 ?>
</body>

</html>