<?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</li>

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

					</div>



					<div class="page-content">

			



						<div class="page-header">

							<h1>

								Bank

							</h1>

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

<br />



						<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

	$('#work').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;

		

		$('button:submit').prop('disabled', true);

		

	});

	

});	



</script>







<?php



	



if(isset($_GET['id']))



{



	



$id=$_GET['id'];







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



{







$id=$_POST['id'];



$bank=$_POST['bank'];



$name=$_POST['name'];



$acno=$_POST['acno'];



$ifsc=$_POST['ifsc'];



$branch=$_POST['branch'];







if($bank)



{







$up=mysql_query("update bank set bank='$bank',accountno='$acno',accountname='$name',ifsc='$ifsc',branch='$branch',editedby='$user' where ID='$id'");







if($up)



{







header("location:viewbank.php?s=1");







}







}







}







else



{







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



$cus1=mysql_fetch_array($cus);







echo '<form action="viewbank.php?id='.$id.'" method="post" id="work">





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







<input type="hidden" name="id" value="'.$id.'" />







<tr><td id="page">Bank <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="bank" value="'.$cus1['bank'].'" id="required1" title="Enter Bank" /></td></tr>



<tr><td id="page">Branch <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="branch" value="'.$cus1['branch'].'" id="required1" title="Enter Branch" /></td></tr>



<tr><td id="page">Account No <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="acno" value="'.$cus1['accountno'].'" id="required1" title="Enter A/C No" /></td></tr>







<tr><td id="page">Account Name <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="name" value="'.$cus1['accountname'].'" id="required1" title="Enter A/C Name" /></td></tr>







<tr><td id="page">IFSC Code </td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="ifsc" value="'.$cus1['ifsc'].'" /></td></tr>







<tr><td align="right" id="page"></td><td align="right" id="page"></td><td id="page"><button class="btn btn-sm btn-primary" type="submit" name="submit" value="Add">Save</button></td></tr>







</table></center>







</form>';







}







}







else



	{

		

		

		if (isset($_GET['s'])) 



	{



	 $status=$_GET['s'];



		 if($status=='1')



		 {



		 echo '<div class="alert alert-block alert-success">

						<button type="button" class="close" data-dismiss="alert">

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

						</button>

					Values Edited Successfully.

			   </div>';



		}

		

	}





echo'<table style="width:99%; margin:auto;">

                                        

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

                                        <a href="bank.php"><button class="btn btn-minier btn-info">+ Add Bank</button></a>

                                        </td>

                                        

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

                                        

                                        <td style="width:30%;">

                                        <div class="clearfix" style="padding-top:5px;">

											<div class="pull-right tableTools-container"></div>

										</div>

                                        </td>

                                        

                                        </tr>

                                        

                                        </table>';

									

echo'<table id="dynamic-table" class="table table-striped table-bordered table-hover">';



echo"<thead><tr><th width='7%'>S.No</th><th width='25%'>Bank</th><th width='30%'>Account No</th><th width='25%'>A/C Name</th><th style='width:8%;'>Edit</th></tr></thead>

<tbody>";



$select="select * from bank order by ID asc";

$select1=mysql_query($select);

$sno=0;

while($value=mysql_fetch_array($select1))

{

$sno=$sno+1;

echo'<tr><td>'.$sno.'</td><td>'.$value['bank'].'</td><td>'.$value['accountno'].'</td><td>'.$value['accountname'].'</td><td>';



													   if($gtp1['type']!='staff')

													   {

													   echo'<div class="hidden-sm hidden-xs btn-group">

													   

															<a href="viewbank.php?id='.$value['ID'].'" title="Edit">

																<i class="ace-icon fa fa-pencil bigger-100 green"></i></a> &nbsp; 



														</div>';

													   }



echo'</td></tr>';

}



echo"</tbody></table>";



	}

	



?>                                

                               

								



								<!-- 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();

?>