<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>





<div id="page-wrapper" >
          <div id="page-inner">

			<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Bank Opening</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>

                        

                        <table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Bank Opening		

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

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

                            

						</div><!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->



<script src="assets/js/jquery.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">
  <style>
    .datepicker-wrapper {
      position: relative;
    }
  </style>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
  <script>
    $(function() {
      // Initialize the datepicker
      $("#datepicker").datepicker({
        format: "mm/dd/yyyy",
        autoclose: true,
        todayHighlight: true
      });

      // Adjust the positioning of the datepicker dropdown
      $("#datepicker").on("show", function(e) {
        var inputOffset = $(this).offset();
        var inputHeight = $(this).outerHeight();
        var datepickerDropdown = $(".datepicker-dropdown");

        datepickerDropdown.css({
          top: inputOffset.top + inputHeight + 10,
          left: inputOffset.left
        });
      });
    });
  </script>

<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

	});

	

});	



</script> 



                      

								

<script>







$(document).ready(function() {







  $(".bank").change(function()



		  {



		  var bank=$(this).val();



		  var dataString = 'bank='+ bank;



		  //alert(dataString);



		  $.ajax



		  ({



		  type: "GET",



		  url: "getacc.php",



		  data: dataString,



		  cache: false,



		  success: function(resp)



		  {



		  //alert(resp);



		  //var company=$(resp).filter('#company').text();



		  //alert(company);



		  $('.account').html($('#account',resp).html());



		  }



		  });



		  });



});		  







</script>



                                

<?php











if(isset($_POST['submit']))











{











$date=$_POST['date'];











$bank=$_POST['bank'];











$accountname=$_POST['accountname'];











$paymenttype=$_POST['type'];











$amount=$_POST['amount'];

















		$date = date('Y-m-d',strtotime($date));





		





		$d=date("m",strtotime($date));





		if($d>03)





		{





		$y=date("Y",strtotime($date));





		$y1=$y+1;		





		





		$dd=date($y);





		$dd1=date($y1);	





		}





		elseif($d<=03)





		{





		$y1=date("Y",strtotime($date));





		$y=$y1-1;	





		





		$dd=date($y);





		$dd1=date($y1);	





		}





		





		$financial=$dd.'-'.$dd1;





		











if($amount)











{











$date=date('Y-m-d',strtotime($date));











$insert="INSERT into bank_ledger(date,accountname,paymenttype,amount,financial) values('$date','$accountname','$paymenttype','$amount','$financial')";











mysqli_query($conn,$insert) or die(mysqli_error($conn));











}























if($insert){











header("location:bank_ledger.php?s=1" . urlencode($Message));











}











else{











header("location:bank_ledger.php?s=2" . urlencode($Message));











}

















}











else











{























echo '











<center>





<table style="width:40%;">





<tr><td style="text-align:center;">





</td>











<td style="text-align:right;"></td></tr></table></center><br />











<form action="bank_obl.php" method="post" id="customer">











<center><table width="50%" id="page" style="line-height:35px;">











<tr><td id="page">Date <span class="red"></span></td><td></td> <td id="page"><input  class="form-control" style="width:30ch; margin-bottom:10px;"  type="text" name="date" id="datepicker" title="Select Date" class="datepicker" autocomplete="off" /required1></td></tr>











<tr><td id="page">Bank <span class="red"></span></td><td></td> <td id="page"><select  style="width: 30ch; padding-left:10px; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;"  name="bank" class="bank" style="width:220px;" id="required1" title="Select Bank"><option value="">Select Bank</option>';











$sl=mysqli_query($conn,"select * from bank order by ID asc");





while($sl1=mysqli_fetch_assoc($sl))





{











$chk=mysqli_query($conn,"select * from bank_ledger where financial='$fi1[financial]' and accountname='$sl1[ID]'");





$chk1=mysqli_num_rows($chk);











if($chk1==0)





{





echo"<option value='".$sl1['bank']."'>".$sl1['bank']."</option>";





}











}











echo'</select></td></tr>











<tr><td id="page">Account Name <span class="red"></span></td><td></td> <td id="page"><select style="width: 30ch; padding-left:10px; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;"  name="accountname" style="width:220px;" id="required1" title="Select Account" class="account"><option value="" selected="selected">Select Account Name</option></select></td></tr>











<tr><td id="page">Payment Type <span class="red"></span></td><td></td><td id="page"><select  class="form-control" style="width:30ch; margin-bottom:20px;"  name="type" style="width:220px;" id="required1" title="Select Type"><option value="debit">Debit</option><option value="credit">Credit</option></select></td></tr>











<tr><td id="page">Amount <span class="red"></span></td><td></td><td id="page"><input  class="form-control" style="width:30ch; margin-bottom:20px;"  size="50" type="text" name="amount" id="required1" title="Enter Amount" autocomplete="off" /></td></tr>';











echo'<tr><td colspan="2"></td><td id="page"><button id="save" type="submit" name="submit" value="Add" class="btn btn btn-primary">Save</button></td><td id="page"></td></tr>











</table></center>











</form>';











}





?>

                                                                

        

								



										<!-- PAGE CONTENT ENDS -->

									</div><!-- /.col -->

								</div><!-- /.row -->

							</div><!-- /.page-content -->

						</div>

					</div><!-- /.main-content -->
					</div><!-- /.main-content -->
					</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();

?>

