<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}
$tyrenum_veh='';

include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();

//$tablename='cf_client';

		if(isset($_POST['banksubmit'])){
		
				if(isset($_POST['bank_name'])){
				$bank_name=addslashes($_POST['bank_name']);
				}
		
				if(isset($_POST['branch_name'])){
				$branch_name=addslashes($_POST['branch_name']);
				}
				
				if(isset($_POST['acno'])){
				$acno=addslashes($_POST['acno']);
				}
				
				if(isset($_POST['open_bal'])){
				$openbal=addslashes($_POST['open_bal']);
				}
								
				if(isset($_POST['ifsc'])){
				$ifsc=addslashes($_POST['ifsc']);
				}
				
				if(isset($_POST['phno'])){
				$phno=addslashes($_POST['phno']);
				}
				
				if(isset($_POST['bank_address'])){
				$bank_address=addslashes($_POST['bank_address']);
				}
				
				
				
				$sql2 = mysql_query("insert into cf_bank (bankname,bank_branch,bank_acno,bank_open,bank_address,bank_phoneno,bank_ifsc) values ('$bank_name','$branch_name','$acno','$openbal','$bank_address','$phno','$ifsc')");
				
				$lastid = mysql_insert_id();
				
				$newstring = substr($acno, -4);
			
				$ledgername=$bank_name.'_'.$newstring;
			
				mysql_query("insert into cf_ledger (ledgername,ledgertype,empid,groupid,ledger_start_date) values('$ledgername','bankledger','$lastid','12','".date('Y-m-d')."')");	
				
								
			
			header("location:bank-list.php");
}
			$clientcode='';
			$clientname= '';			
			$cont_person= '';
			$clientphno= '';				
			$client_address='';
			$client_tinno= '';
			
			if(isset($_POST['bankedit']))
			{
				$subid =  $_REQUEST['bankid'];
				
				if(isset($_POST['bank_name'])){
				$bank_name=addslashes($_POST['bank_name']);
				}
		
				if(isset($_POST['branch_name'])){
				$branch_name=addslashes($_POST['branch_name']);
				}
				
				if(isset($_POST['acno'])){
				$acno=addslashes($_POST['acno']);
				}
				
				if(isset($_POST['open_bal'])){
				$openbal=addslashes($_POST['open_bal']);
				}
				
				if(isset($_POST['ifsc'])){
				$ifsc=addslashes($_POST['ifsc']);
				}
				
				if(isset($_POST['phno'])){
				$phno=addslashes($_POST['phno']);
				}
				
				if(isset($_POST['bank_address'])){
				$bank_address=addslashes($_POST['bank_address']);
				}
				
				//echo "update cf_bank set bankname='$bank_name',bank_branch='$branch_name',bank_acno = '$acno',bank_address='$bank_address',bank_phoneno='$phno' where bank_id ='$subid'";				
				$result1=mysql_query("update cf_bank set bankname='$bank_name',bank_branch='$branch_name',bank_acno = '$acno',bank_open='$openbal',bank_address='$bank_address',bank_phoneno='$phno',bank_ifsc='$ifsc' where bank_id ='$subid'");
				
				//$newstring = substr($acno, -4);
			
				//$ledgername=$bank_name.'_'.$newstring;
			
				//mysql_query("update cf_ledger set ledgername='$ledgername' where ledgertype = 'bankledger' and empid=$subid ");	
				
				//mysql_query("insert into cf_ledger (ledgername,ledgertype,empid,groupid,ledger_start_date) values('$ledgername','bankledger','$subid','7','".date('Y-m-d')."')");	
				
				header("location:bank-list.php");
				
			}
			
			$bankname='';
			$bank_branch='';
			$bank_acno= '';
			$bankopen='';
			$bank_address= '';
			$bank_phoneno= '';
			$bank_ifsc= '';
		
		
			
		if(isset($_REQUEST['bankid'])){
			
				$id=$_REQUEST['bankid'];
				$tablename='cf_bank';
				$sqlObj->tablename="cf_bank";
				$condition=" where 	bank_id='$id'";
				$sqlObj->condition=$condition;
				$sqlObj->fieldvalue="*";
				$fieldvalue=$sqlObj->fieldvalue;
				$sql=$sqlObj->SelectTable();
				$bankname= $sql['bankname'];
				$bank_branch= $sql['bank_branch'];
				$bank_acno= $sql['bank_acno'];
				$bankopen= $sql['bank_open'];
				$bank_address= $sql['bank_address'];
				$bank_phoneno= $sql['bank_phoneno'];
				$bank_ifsc= $sql['bank_ifsc'];
				//$newclientno =  $sql['clientnewcode'];
				
						
			}
			
		
			
			


?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OIL FILL</title>
<link href="css/styles.css" rel="stylesheet"  />
<link type="text/css" href="css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="scripts_date/jquery.js"></script>
<script type="text/javascript" src="scripts_date/jquery-calendar-1.7.2.js"></script>




<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


</script>


<style>
.lableentrytext{
font-size: 12px;
color: #505050;
clear: both;
margin-bottom: 5px;
text-transform: capitalize;
}
</style>
</head>

<body>
<div class="wrapper">
  <div>
<?php 
	include("header.php");
?>
 
</div>
 
 
 <div class="tabbedArea">
  
  <div class="tabBody">
   <h1>Add bank </h1>
   <form name="frmname" method="post" action="">
   <div class="addEmp" style="margin-bottom:0px; border-bottom:0px solid;width:1000px;">
        <table width="70%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td valign="top">
           
        <div class="form1">
           
		
         <div  class="select1">
         <p class="input1">Bank Name<span style="color:#FF3300">*</span></p>
         <input type="text" name="bank_name" class="input1 input3" value="<?=$bankname?>"   >
         </div>
            
       <div>     
            <p class="input1">Branch Name<span style="color:#FF3300">*</span></p>
            <input type="text" name="branch_name" class="input1 input3" value="<?=$bank_branch?>"  >
       </div>
       
       <div>     
            <p class="input1">Ac No<span style="color:#FF3300">*</span></p><input type="text" name="acno" class="input1 input3" value="<?=$bank_acno?>"  >
       </div>
	   
	    <div  class="select1">
         <p class="input1">Opening Balance<span style="color:#FF3300">*</span></p>
         <input type="text" name="open_bal" class="input1 input3" value="<?=$bankopen?>"   >
         </div>
           
     </div>
        </td>
            <td valign="top"><div class="form1">
      	<div>     
      			<p class="input1">Ph No<span style="color:#FF3300">*</span></p>
                <input type="text" name="phno" class="input1 input3" value="<?=$bank_phoneno?>" >
           </div>     
		     
         <div>     
      			<p class="input1">IFSC Code<span style="color:#FF3300">*</span></p>
                <input type="text" name="ifsc" class="input1 input3" value="<?=$bank_ifsc?>" >
           </div>  
             
            
           <div>     
      			<p class="input1">Address</p><textarea name="bank_address" class="input1"><?=$bank_address?></textarea>
     	   </div>
                       
           <div>
            &nbsp;
            </div>
            </div></td>
          </tr>
           <tr>
            <td colspan="2"><div class="searchField1">
        
           <?php
	 	if(isset($_REQUEST['bankid'])){
	  ?>
      <input name="bankedit" type="submit" class="input1" value="Edit" onClick="return validation();"/>
      <?php }else { ?>
     <input name="banksubmit" type="submit" class="input1" value="Save" onClick="return validation();"/>
     <?php } ?>

         <input type="button" class="input1" value="Cancel" >
        </div>
        </td>
          </tr>
        </table>
 

<div class="mand"><p>Fields marked <span style="color:#FF3300">*</span> are Mandatory</p></div>
</div>
   </form>
   </div>
 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
</body>
</html>


		






