<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$fin_year=$_SESSION['fin_year'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
?>
<title>Kerala Khadi and Village Industries Board</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;
}
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
}
</style>
<body>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px; color:white;"></font>
<form action='<?print $PHP_SELF?>' name="f1" method='post' >
<center>
<table cellspacing=1 cellpadding=1 bgcolor='steelblue'>
<tr><td bgcolor='white' align=center>
<table class=noprint>
<?$new_year1 = '20'.(substr($fin_year,2,2)+1).'-20'.(substr($fin_year,-2)+1)?>
<tr><br><br><br><br><br><br><br><td colspan=2 align=center bgcolor='red'><b>Delete Newly Created Database  >>> <?print $new_year1?>
<input type='submit' name='proceed' value='Proceed' >
</table>
</td></tr>
</table>
</form>

<?php
$targetpage = "dropnew.php";
$date=date('Y-m-d');
$new_year = 'khadidb'.(substr($fin_year,2,2)+1).(substr($fin_year,-2)+1);
if(isset($_POST['proceed']))
{
    $re1=mysqli_query($db,"select count(jvno) from ".$new_year.".journal2")or die(mysqli_error($db));
    $row1=mysqli_fetch_array($re1);
    if ($row1[0]>0)
    {
        print "<script> alert('Database is not empty !!!'); document.location='dropnew.php' </script>";
        return;
    }
	$sv_year='20'.(substr($fin_year,2,2)).'-'.(substr($fin_year,-2));
	$query="update khadidb.branch set brpass='$sv_year'";	 
	mysqli_query($db,$query);
    $sql1 ="drop database ".$new_year;
   	mysqli_query($db,$sql1)or die(mysqli_error($db));
	
   	print $sql1.".....Successful....!!!<br>";
}
?>
