<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}
	
	





$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));

	

	

	include("connect.php");



	
	$bankmid=$_POST['bankmid'];
	$bankname=$_POST['bankname'];
	$bankwebsite=$_POST['bankwebsite'];
	$bankbranch=$_POST['bankbranch'];
	$branchaddress=$_POST['branchaddress'];
	$cname=$_POST['countrymid'];
	$sname=$_POST['statemid'];
	$ciname=$_POST['citymid'];
	
	$bankpostalcode=$_POST['bankpostalcode'];
	$bankcontact=$_POST['bankcontact'];
	$bankemail=$_POST['bankemail'];
	$bankaccountname=$_POST['bankaccountname'];
	$accountopendate=date("Y-m-d", strtotime($_POST['accountopendate']));
	$bankaccounttype=$_POST['bankaccounttype'];
	$bankaccountnumber=$_POST['bankaccountnumber'];
	$bankcurrentbalance=$_POST['bankcurrentbalance'];
	$bankaccountnumber=$_POST['bankaccountnumber'];
	$bankmicr=$_POST['bankmicrcode'];
	$bankiffccode=$_POST['bankiffccode'];
	$companymid=$_POST['companymid'];
	$bankbranchcode=$_POST['bankbranchcode'];
	$bankcustomerid=$_POST['bankcustomerid'];
	$bankheadname=$_POST['bankheadname'];
	$bankheadcontact=$_POST['bankheadcontact'];
	$bankheadmobile=$_POST['bankheadmobile'];
	$bankheaddepartment=$_POST['bankheaddepartment'];
	$bankheadposition=$_POST['bankheadposition'];
	$bankheadnote=$_POST['bankheadnote'];
	
	if($_SESSION['utype']=="admin")
	{ 
	$branchmid=$_POST['branchmid'];
	}
	else
	{
		$branchmid= $_SESSION['branchid'];
	}
	
	$tt="";
	/* if(empty($_FILES['attechment']['name']) == false  )
	{
		$attechment = date("YmdHis").$_FILES['attechment']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['attechment']['tmp_name'], $path ."/". $attechment );
	
		$tt = ",attechment='$attechment' ";
	} */

	
	if($_SESSION['utype']=="admin")
		{
			$eve = "update res_bank_master set branchmid='$branchmid',bankname='$bankname',bankwebsite='$bankwebsite',bankbranch='$bankbranch',branchaddress='$branchaddress',countrymid='$cname',statemid='$sname',citymid='$ciname',bankpostalcode='$bankpostalcode',bankcontact='$bankcontact',bankemail='$bankemail',bankaccountname='$bankaccountname',accountopendate='$accountopendate',bankaccounttype='$bankaccounttype',bankaccountnumber='$bankaccountnumber',bankcurrentbalance='$bankcurrentbalance',bankmicrcode='$bankmicr',companymid='$companymid',bankiffccode='$bankiffccode',bankbranchcode='$bankbranchcode',bankcustomerid='$bankcustomerid',bankheadname='$bankheadname',bankheadcontact='$bankheadcontact',bankheadmobile='$bankheadmobile',bankheaddepartment='$bankheaddepartment',bankheadposition='$bankheadposition',bankheadnote='$bankheadnote' $tt where bankmid='$bankmid'";
		}
		else
		{
			
			$eve = "update res_bank_master set bankname='$bankname',bankwebsite='$bankwebsite',bankbranch='$bankbranch',branchaddress='$branchaddress',countrymid='$cname',statemid='$sname',citymid='$ciname',bankpostalcode='$bankpostalcode',bankcontact='$bankcontact',bankemail='$bankemail',bankaccountname='$bankaccountname',accountopendate='$accountopendate',bankaccounttype='$bankaccounttype',bankaccountnumber='$bankaccountnumber',bankcurrentbalance='$bankcurrentbalance',bankmicrcode='$bankmicr',companymid='$companymid',bankiffccode='$bankiffccode',bankbranchcode='$bankbranchcode',bankcustomerid='$bankcustomerid',bankheadname='$bankheadname',bankheadcontact='$bankheadcontact',bankheadmobile='$bankheadmobile',bankheaddepartment='$bankheaddepartment',bankheadposition='$bankheadposition',bankheadnote='$bankheadnote' $tt where bankmid='$bankmid'";
		}
	

	if ($conn->query($eve) === TRUE)

	{		

		$_SESSION['msg'] = "bank Record Updated succesfully";

		header('Location: bank.php');		

	} 

	else 

	{

			

		$_SESSION['msg'] = "Error";

		header('Location: bank.php');

	}

?>