<?PHP

ob_start();

session_start();

include 'connect.php';

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

{

$user=$_SESSION['adminemail'];



$gtp=mysql_query("select * from admin where username='$user'");

$gtp1=mysql_fetch_array($gtp);



include 'top.php';

?>







			<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=mysql_query("select * from financial where user='$user' order by ID desc");

$aca1=mysql_fetch_array($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>



<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']))











{











$id=$_POST['id'];











$date=$_POST['date'];











$bank=$_POST['bank'];











$accountname=$_POST['accountname'];











$paymenttype=$_POST['type'];











$amount=$_POST['amount'];











if($accountname && $amount)











{











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











$insert="UPDATE bank_ledger set date='$date',accountname='$accountname',paymenttype='$paymenttype',amount='$amount' where ID='$id'";











mysql_query($insert) or die(mysql_error());











}























if($insert){











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











}











else{











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











}

















}











else

{



$id=$_GET['ledger'];



$sl=mysql_query("select * from bank_ledger where accountname='$id'");

$ch=mysql_num_rows($sl);

$sl1=mysql_fetch_array($sl);



$sup=mysql_query("select * from bank where ID='$id'");

$sup1=mysql_fetch_array($sup);



if($ch>0)

{



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



}

else

{



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



}





echo'<form action="editbank_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 type="text" name="date" value="'.$date.'" id="required1" title="Select Date" class="datepicker" /></td></tr>



<tr><td id="page">Bank <span class="red">*</span></td><td>:</td> <td id="page">



<input type="hidden" name="id" value="'.$sl1['ID'].'" /><input type="text" name="bank" readonly="true" value="'.$sup1['bank'].'"></td></tr>



<tr><td id="page">Account Name <span class="red">*</span></td><td>:</td> <td id="page">



<input type="hidden" name="accountname" value="'.$id.'" /><input type="text" readonly="true" value="'.$sup1['accountname'].'"></td></tr>



<tr><td id="page">Payment Type <span class="red">*</span></td><td>:</td><td id="page"><select name="type" id="required1" title="Select Type" style="width:220px;">';



?>



<option value="debit" <?php if($sl1['paymenttype']=='debit'){ echo'selected="selected"'; } ?>>Debit</option>

<option value="credit" <?php if($sl1['paymenttype']=='credit'){ echo'selected="selected"'; } ?>>Credit</option>



<?php



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



<tr><td id="page">Amount <span class="red">*</span></td><td>:</td><td id="page"><input size="50" type="text" name="amount" id="required1" title="Enter Amount" value="'.$sl1['amount'].'" /></td></tr>';



echo'<tr><td colspan="2"></td><td id="page"><button id="save" type="submit" name="submit" value="Add" class="btn btn-sm 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 -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();



?>