<?php
if($_REQUEST['submit']!='')
{
	if($_REQUEST['item_main_category']!='')
	{
		$MainCatArray=$_REQUEST['item_main_category'];
		$MaincatIds=implode(",",$MainCatArray);
	}
	else
	{
		$MaincatIds='';
	}
	if($_REQUEST['item']!='')
	{
		$itemArray=$_REQUEST['item'];
		$itemIds=implode(",",$itemArray);
	}
	else
	{
		$itemIds='';
	}	
	
	if($_REQUEST['item_sub_category']!='')
	{
		$SubCatArray=$_REQUEST['item_sub_category'];
		$SubCatIds=implode(",",$SubCatArray);
	}
	else
	{
		$SubCatIds='';
	}
	
	$datap['vendor_code']=$_REQUEST['vendor_code'];
	$datap['vendor_name']=$_REQUEST['vendor_name'];    
	$datap['category']=$_REQUEST['category'];    
	$datap['account_group ']=$_REQUEST['account_group'];   
	$datap['vendor_type']=$_REQUEST['vendor_type'];
	$datap['vendor_website']=$_REQUEST['vendor_website'];    
	$datap['site']=$_REQUEST['site'];      
	$datap['short_name ']=$_REQUEST['short_name'];   
	$datap['adrress1']=$_REQUEST['adrress1'];    
	$datap['adrress2']=$_REQUEST['adrress2'];    
	$datap['address3']=$_REQUEST['address3'];
	$datap['city']=$_REQUEST['pre_city'];
	$datap['state']=$_REQUEST['pre_state'];   
	$datap['country']=$_REQUEST['pre_country'];    
	$datap['pincode']=$_REQUEST['pincode'];    
	$datap['extension']=$_REQUEST['extension'];    
	$datap['phone1']=$_REQUEST['phone1'];    
	$datap['phone2']=$_REQUEST['phone2'];    
	$datap['mobile ']=$_REQUEST['mobile'];   
	$datap['fax']=$_REQUEST['fax'];       
	$datap['email']=$_REQUEST['email'];     
	$datap['pan_no']=$_REQUEST['pan_no'];   
	$datap['tin_no']=$_REQUEST['tin_no'];    
	$datap['lst_no']=$_REQUEST['lst_no'];   
	$datap['cst_no']=$_REQUEST['cst_no'];   
	$datap['excise_no']=$_REQUEST['excise_no'];    
	$datap['payterms']=$_REQUEST['payterms'];    
	$datap['tax_group']=$_REQUEST['tax_group'];  
	$datap['sup_range']=$_REQUEST['sup_range'];    
	$datap['sup_division']=$_REQUEST['sup_division'];
	$datap['tds_selection']=$_REQUEST['tds_selection'];
	$datap['item_main_category']=$MaincatIds;
	$datap['item_sub_category']=$SubCatIds;
	$datap['assigned_items']=$itemIds;
	$datap['CompanyId']=$_SESSION['ACGCompanyId'];
	
	//echo "<pre>";
	//print_r($datap);
	
	
	$s->RecordInsert('suppliers',$datap);
				 //tds_percentage='".$_REQUEST['tds_percentage']."'"; 
	$lastid=DB_Last_Insert_ID($db,'suppliers','id');
	if($lastid!='')
	{
		$data['AccountName']=$_REQUEST['vendor_name'];
		$data['vender_client']=$lastid;
		$data['UnderGroup']=$_REQUEST['account_group'];
		$data['CompanyId']=$_SESSION['ACGCompanyId'];
		$data['openingBalance']=$_REQUEST['openingBalance'];
		$data['openingtype']=$_REQUEST['openingtype'];
		$data['openingdate']=$_SESSION['financialYrStart'];
		$data['ledgertype']='vendor';
		//echo "<pre>";
		//print_r($data);
		$rowinsert= $s->RecordInsert('accountledger', $data);
		
		for($ctr=0;$ctr<count($_REQUEST['person']);$ctr++)
		{
			if($_REQUEST['person'][$ctr]!='')
			{
				$datacon['master_code']=$lastid;  
				$datacon['master_prefix']='S'; 
				$datacon['person']=$_REQUEST['person'][$ctr];   
				$datacon['department']=$_REQUEST['department'][$ctr]; 
				$datacon['designation']=$_REQUEST['designation'][$ctr]; 
				$datacon['phone']=$_REQUEST['phone'][$ctr];   
				$datacon['email']=$_REQUEST['contact_email'][$ctr];
				$rowinsert= $s->RecordInsert('contact_information_master',$datacon);
				//echo "<pre>";
				//print_r($datacon);
			}
		}
	}
	//exit;
$s->pageLocation("index.php?route=Supplier_list".$rurl);
}


if($_REQUEST['ID']!='')
{
	$sql=DB_query("Select * from suppliers where id='".$_REQUEST['ID']."'",$db);
	$myrow=DB_fetch_array($sql);
	//select * from accountledger where vender_client='".$_GET['ID']."'
	$vendor_code = stripcslashes($myrow['vendor_code']);
	$vendor_name = stripcslashes($myrow['vendor_name']);
	$category = stripcslashes($myrow['category']);							
	$account_group = stripcslashes($myrow['account_group']);									
	$vendor_type = stripcslashes($myrow['vendor_type']);
	$site = stripcslashes($myrow['site']);
	$vendor_website = $myrow['vendor_website'];
	$short_name = stripcslashes($myrow['short_name']);
	$adrress1 = stripcslashes($myrow['adrress1']);
	$adrress2 = stripcslashes($myrow['adrress2']);
	$address3 = stripcslashes($myrow['address3']);
	$country = stripcslashes($myrow['country']);
	$state = stripcslashes($myrow['state']);
	$city = stripcslashes($myrow['city']);
	$pincode = stripcslashes($myrow['pincode']);
	$extension = stripcslashes($myrow['extension']);
	$phone1 = stripcslashes($myrow['phone1']);
	$phone2 = stripcslashes($myrow['phone2']);
	$mobile = stripcslashes($myrow['mobile']); 
	$fax = stripcslashes($myrow['fax']);
	$email = stripcslashes($myrow['email']);
	$pan_no = stripcslashes($myrow['pan_no']);
	$tin_no = stripcslashes($myrow['tin_no']);
	$lst_no = stripcslashes($myrow['lst_no']);
	$cst_no = stripcslashes($myrow['cst_no']);
	$excise_no = stripcslashes($myrow['excise_no']);
	$payterms = stripcslashes($myrow['payterms']);
	$tax_group = stripcslashes($myrow['tax_group']);
	$sup_range = $myrow['sup_range'];
	$sup_division = $myrow['sup_division'];
	$tds_selection = $myrow['tds_selection'];
	$item_main_category = $myrow['item_main_category'];
	$assigned_items =$myrow['assigned_items'];
	$item_sub_category =$myrow['item_sub_category'];
	//$tds_percentage = $myrow['tds_percentage'];
	$sqlgetacc=DB_query("SELECT * FROM accountledger WHERE vender_client='".$_REQUEST['ID']."'",$db);
	$GetAccle=DB_fetch_array($sqlgetacc);
	$openingBalance=$GetAccle['openingBalance'];
	$openingtype=$GetAccle['openingtype'];
	$openingdate=$GetAccle['openingdate'];
	
}
else 
{
	$vendor_code = $_REQUEST['vendor_code'];
	$vendor_name = $_REQUEST['vendor_name'];
	$category = $_REQUEST['category'];							
	$account_group = $_REQUEST['account_group'];									
	$vendor_type = $_REQUEST['vendor_type'];
	$site = $_REQUEST['site'];
	$vendor_website = $_REQUEST['vendor_website'];
	
	$short_name = $_REQUEST['short_name'];
	$adrress1 = $_REQUEST['adrress1'];
	$adrress2 = $_REQUEST['adrress2'];
	$address3 = $_REQUEST['address3'];
	$country = $_REQUEST['country'];
	$state = $_REQUEST['state'];
	$city = $_REQUEST['city'];
	$pincode = $_REQUEST['pincode'];
	$extension = $_REQUEST['extension'];
	$phone1 = $_REQUEST['phone1'];
	$phone2 = $_REQUEST['phone2'];
	$mobile = $_REQUEST['mobile']; 
	$fax = $_REQUEST['fax'];
	$email = $_REQUEST['email'];
	$pan_no = $_REQUEST['pan_no'];
	$tin_no = $_REQUEST['tin_no'];
	$lst_no = $_REQUEST['lst_no'];
	$cst_no = $_REQUEST['cst_no'];
	$excise_no = $_REQUEST['excise_no'];
	$payterms = $_REQUEST['payterms'];
	$tax_group = $_REQUEST['tax_group'];
	$sup_range = $_REQUEST['sup_range'];
	$sup_division = $_REQUEST['sup_division'];
	$tds_selection = $_REQUEST['tds_selection'];
	$item_main_category = $_REQUEST['item_main_category'];
	$assigned_items =$_REQUEST['assigned_items'];
	$item_sub_category =$_REQUEST['item_sub_category'];
	//$tds_percentage = $_REQUEST['tds_percentage'];
}



if($_REQUEST['Update']!='')
{
	$data['AccountName']=$_REQUEST['vendor_name'];
	$data['UnderGroup']=$_REQUEST['account_group'];
	$data['CompanyId']=1;
	$data['ledgertype']='vendor';
	$data['vender_client']=$_GET['ID'];
	$data['openingBalance']=$_REQUEST['openingBalance'];
	$data['openingtype']=$_REQUEST['openingtype'];
	$data['openingdate']=$_REQUEST['openingdate'];
	$data['ledgertype']='vendor';
	//$data['openingdate']=$_SESSION['financialYrStart'];
	$chkledgerExist=DB_query("select * from accountledger where vender_client='".$_GET['ID']."' and ledgertype='vendor'",$db);
	if(DB_num_rows($chkledgerExist)==0)
	{
		$rowinsert= $s->RecordInsert('accountledger', $data);
	}
	else
	{	
		$cond="vender_client='".$_GET['ID']."' and ledgertype='vendor'";
		$rowinsert= $s->RecordEdit('accountledger', $data, $cond);
	}
	
	if($_REQUEST['item_main_category']!='')
	{
		$MainCatArray=$_REQUEST['item_main_category'];
		$MaincatIds=implode(",",$MainCatArray);
	}
	else
	{
		$MaincatIds='';
	}
	if($_REQUEST['item']!='')
	{
		$itemArray=$_REQUEST['item'];
		$itemIds=implode(",",$itemArray);
	}
	else
	{
		$itemIds='';
	}	
	
	if($_REQUEST['item_sub_category']!='')
	{
		$SubCatArray=$_REQUEST['item_sub_category'];
		$SubCatIds=implode(",",$SubCatArray);
	}
	else
	{
		$SubCatIds='';
	}
	
	$dataupdate['vendor_code']=$_REQUEST['vendor_code'];
	$dataupdate['vendor_name']=$_REQUEST['vendor_name'];    
	$dataupdate['category']=$_REQUEST['category'];    
	$dataupdate['account_group ']=$_REQUEST['account_group'];   
	$dataupdate['vendor_type']=$_REQUEST['vendor_type'];
	$dataupdate['vendor_website']=$_REQUEST['vendor_website'];    
	$dataupdate['site']=$_REQUEST['site'];      
	$dataupdate['short_name ']=$_REQUEST['short_name'];   
	$dataupdate['adrress1']=$_REQUEST['adrress1'];    
	$dataupdate['adrress2']=$_REQUEST['adrress2'];    
	$dataupdate['address3']=$_REQUEST['address3'];
	$dataupdate['city']=$_REQUEST['pre_city'];
	$dataupdate['state']=$_REQUEST['pre_state'];   
	$dataupdate['country']=$_REQUEST['pre_country'];    
	$dataupdate['pincode']=$_REQUEST['pincode'];    
	$dataupdate['extension']=$_REQUEST['extension'];    
	$dataupdate['phone1']=$_REQUEST['phone1'];    
	$dataupdate['phone2']=$_REQUEST['phone2'];    
	$dataupdate['mobile ']=$_REQUEST['mobile'];   
	$dataupdate['fax']=$_REQUEST['fax'];       
	$dataupdate['email']=$_REQUEST['email'];     
	$dataupdate['pan_no']=$_REQUEST['pan_no'];   
	$dataupdate['tin_no']=$_REQUEST['tin_no'];    
	$dataupdate['lst_no']=$_REQUEST['lst_no'];   
	$dataupdate['cst_no']=$_REQUEST['cst_no'];   
	$dataupdate['excise_no']=$_REQUEST['excise_no'];    
	$dataupdate['payterms']=$_REQUEST['payterms'];    
	$dataupdate['tax_group']=$_REQUEST['tax_group'];  
	$dataupdate['sup_range']=$_REQUEST['sup_range'];    
	$dataupdate['sup_division']=$_REQUEST['sup_division'];
	$dataupdate['tds_selection']=$_REQUEST['tds_selection'];
	$dataupdate['item_main_category']=$MaincatIds;
	$dataupdate['item_sub_category']=$SubCatIds;
	$dataupdate['assigned_items']=$itemIds;
	$Cond="id='".$_REQUEST['ID']."'";
	//echo "<pre>";
	//print_r($dataupdate);
	$s->RecordEdit('suppliers',$dataupdate,$Cond);
	
	
	///tds_percentage='".$_REQUEST['tds_percentage']."'
	
	
	$upadteId=$_REQUEST['ID'];
	$DelId="master_code='".$_REQUEST['ID']."' and master_prefix='S'";
	$s->DeleteRecord('contact_information_master',$DelId);
	for($m=0;$m<count($_REQUEST['person']);$m++)	
	{
		if($_REQUEST['person'][$m]!='')
		{					
			$dataconUpdate['master_code']=$upadteId;  
			$dataconUpdate['master_prefix']='S'; 
			$dataconUpdate['person']=$_REQUEST['person'][$m];   
			$dataconUpdate['department']=$_REQUEST['department'][$m]; 
			$dataconUpdate['designation']=$_REQUEST['designation'][$m]; 
			$dataconUpdate['phone']=$_REQUEST['phone'][$m];   
			$dataconUpdate['email']=$_REQUEST['contact_email'][$m];
			$rowinsert= $s->RecordInsert('contact_information_master',$dataconUpdate);
			//echo "<pre>";
			//print_r($dataconUpdate);
		}
	}
	//exit;
	$s->pageLocation("index.php?route=Supplier_list".$rurl);
}
?>
<script language="JavaScript" type="text/javascript">
$.noConflict();
$( "#openingdate").datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true, changeYear: true,yearRange: '-80:+20'});
function search_state(str)
{
	//alert(str);
	if (str.length==0)
	{
	document.getElementById("searchstate").innerHTML="";
	return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("searchstate").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","get_state1.php?country="+str,true);
	xmlhttp.send();
}

function search_city(str)
{
	//alert(str);
	var country = document.getElementById("country").value;
	//alert("country="+country);
	if (str.length==0)
	{
	document.getElementById("searchcity").innerHTML="";
	return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("searchcity").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","get_city1.php?state="+str+"&country="+country,true);
	xmlhttp.send();
}



function get_itemsubgroup()
{
	var opt = frm.item_main_category;  
  var numofoptions = opt.length  
    var selValue = new Array  
    var j = 0  
    for (i=0; i<numofoptions; i++)  
    {  
      if (opt[i].selected === true)  
      {  
        selValue[j] = opt[i].value  
        j++  
      }  
    }  
  
    selValue = selValue.join("','")  
   	//var arrayItem=document.getElementById("arrayItem").value;
	if(selValue=="")
  {
  document.getElementById("sub_id").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("sub_id").innerHTML=xmlhttp.responseText;
    }
  }
   
 // var str1=emplode(','str);
  //alert(str1);
xmlhttp.open("GET","item_subcategory.php?s="+selValue,true);
xmlhttp.send();
}
function get_item(str)
{
	
	var count=document.getElementById("cnt").value;
	var sub_cat_array=Array();
	for(var i=0;i<count;i++)
	{
		var arrayItem=document.getElementById("arrayItem_"+i).value;
		//alert(arrayItem);
		var item_sub_category=document.getElementById("item_sub_category_"+i).value;
		if(document.getElementById("item_sub_category_"+i).checked==true)
		{sub_cat_array[i]=item_sub_category;}
	}
	if(str=="")
  	{
  		document.getElementById("itemid").innerHTML="";
  		return;
  	}
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
		xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    	document.getElementById("itemid").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_items.php?q="+sub_cat_array+"&arr="+arrayItem,true);
xmlhttp.send();
}
function FProfileMaster(str)
{   myCheckboxArray = document.frm.elements["item_sub_category[]"];
	var t=myCheckboxArray.length;
	if(document.getElementById('assigned_site').checked==true)
	{	
	
		if(t==undefined)
	
		document.getElementById('item_sub_category_'+0).checked=true;
		for (var i = 0; i <t; i++)
	{
	document.getElementById('item_sub_category_'+i).checked=true;	
	}	
	}
	else
	{
		if(t==undefined)
	
		document.getElementById('item_sub_category_'+0).checked=false;
	for (var i = 0; i < t; i++)
	{
	document.getElementById('item_sub_category_'+i).checked=false;	
	}
	}
	
var count=document.getElementById("cnt").value;
	var sub_cat_array=Array();
	for(var i=0;i<count;i++)
	{
		var arrayItem=document.getElementById("arrayItem_"+i).value;
		//alert(arrayItem);
		var item_sub_category=document.getElementById("item_sub_category_"+i).value;
		if(document.getElementById("item_sub_category_"+i).checked==true)
		{sub_cat_array[i]=item_sub_category;}
	}
	if(str=="")
  	{
  		document.getElementById("itemid").innerHTML="";
  		return;
  	}
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
		xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    	document.getElementById("itemid").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_items.php?q="+sub_cat_array+"&arr="+arrayItem,true);
xmlhttp.send();
	
}



function subitems()
{
myCheckboxArray = document.frm.elements["item[]"];
		var t=myCheckboxArray.length;
	if(document.getElementById('subgroup').checked==true)
	{	
	if(t==undefined)
	
		document.getElementById('item_'+0).checked=true;	
	
	for (var i = 0; i < t; i++)
	{
	document.getElementById('item_'+i).checked=true;	
	}	
	}
	else
	{
		if(t==undefined)
	
		document.getElementById('item_'+0).checked=false;	
	
	//var k=document.getElementByName("item").length;
	for (var i = 0; i < t; i++)
	{
	document.getElementById('item_'+i).checked=false;	
	}
	}
}






function GetSatateCountry(str)
{
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
 	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		var data=xmlhttp.responseText.split("__");
    	document.getElementById("pre_state").value=data[0];
		document.getElementById("pre_country").value=data[1];
		document.getElementById("pre_state1").value=data[2];
		document.getElementById("pre_country1").value=data[3];
    }
  	}
	xmlhttp.open("GET","SateCountryName.php?CityId="+str,true);
	xmlhttp.send();
}



function GetDesginationUser(val,id)
{	
	var id1=id.split("_");
	var j=id1[1];
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
		if(j==undefined)
		{
			document.getElementById("designation").innerHTML=xmlhttp.responseText;
		}
		else
		{
			document.getElementById("designation_"+j).innerHTML=xmlhttp.responseText;
		}
	}
	}
	xmlhttp.open("GET","Get_Desg_For_Contact_person.php?deptId="+val,true);
	xmlhttp.send();
}

</script><head>
<style type="text/css">

a{
color: #171717;
text-decoration: none;

}
a:hover{
color: #fff;

text-decoration: none;
}

#wrapper{
width:702px;
margin:auto;
}
.box{
background: #fff;

}
.boxholder{
clear: both;
padding: 5px;
border:#737373 5px solid;
padding-bottom:15px;

}
.tab{
float: left;
height: 32px;
width: 116px;
margin: 0 1px 0 0;
text-align: center;
background: #8DC70A url(images/greentab.jpg) no-repeat;
}
.tabtxt{
margin: 0;
color: #fff;
font-size: 12px;
font-weight: bold;
padding: 9px 0 0 0;

}


/****************** Start page styles ********************************************/



#wrap {
	max-width: 600px;
	margin: 30px auto;
	background: #fff;
	border: 4px solid #FFD16F;
	-moz-border-radius: 15px;
	-webkit-border-radius: 15px;
	border-radius: 15px;
	padding: 20px;
    }

.field { 
	padding: 0 0 1em;
	width:160px;
	}

/****************** End page styles ********************************************/
</style>
<script type="text/javascript" src="js/prototype.lite.js"></script>
<script type="text/javascript" src="js/moo.fx.js"></script>
<script type="text/javascript" src="js/moo.fx.pack.js"></script>
<script type="text/javascript" src="js/min.js"></script>
<script type="text/javascript" src="js/file-upload.js"></script>
<script type="text/javascript">
function init(){
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: false, height: true, duration: 600}
	);
	//hash functions
	var found = false;
	toggles.each(function(h4, i){
		var div = Element.find(h4, 'nextSibling');
			if (window.location.href.indexOf(h4.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
		if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
</script>
</head>
<script src="js/function-ajax.js" language="javascript"></script>


<style>
.cap{text-transform:capitalize;}
</style>
<link rel="stylesheet" href="css/new_mxerp1.css">
<div class="body_contain">
<div class="tab_div">
<h1>New Vendor</h1>
<input type='hidden' name='New' value='Yes'>
<form action="" method="post" name="frm">
	<p align="center"><?php if($_REQUEST['ID']!=''){?><input type='Submit' name='Update' class="search" value="Update"><?php } else{?><input type='Submit' name='submit' class="search" onclick="return validatefrm()" value="Save"><?php }?></p>
	
	
<div id="wrapper" style="width:702px;">
	<div id="content">
		<h4 class="tab" title="first"><div class="tabtxt"><a href="#">General Details</a></div></h4>
		<div class="tab"><h4 class="tabtxt" title="second"><a href="#">Address Details</a></h4></div>
		<div class="tab"><h4 class="tabtxt" title="third"><a href="#">Other Details</a></h4></div>
		<div class="tab"><h4 class="tabtxt" title="fourth"><a href="#">Contact Person</a></h4></div>
		<div class="tab"><h4 class="tabtxt" title="fifth"><a href="#">Assign Item</a></h4></div>
		<div class="tab"><h4 class="tabtxt" title="sixth"><a href="#">Opening Closing Details</a></h4></div>
<div class="boxholder">
			<!--Employee Detail box-->
	<div class="box">
	<table width="100%"  border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
			<td class="tabledata1"><strong>Vendor Name<font size="+1" color="#FF0000">*</font></strong></td>
			<td><input name="vendor_name" id="vendor_name" type="text"  value="<?php echo $vendor_name;?>" style="width:150px;" onblur="ShowDiv(this.value,'hid-SupplierID','suppliercode.php')"></td>
			<td class="tabledata1"><strong>Category<font size="+1" color="#FF0000">*</font></strong></td>
	   		<td>
	   			<select name="category" id="category" style="width:150px;" ><!--onChange="VendorCodeGenerator(this.value)"-->
	  			<option value="000">Select Category</option>
	 			<?php
	 			$get_category=DB_query("Select * from category_master",$db);
	 			while($cat_res=DB_fetch_array($get_category))
	 			{
	 			?>
	 			<option value="<?php echo $cat_res['id'];?>"<?php echo($category==$cat_res['id']?'selected':'')?>><?php echo $cat_res['name'];?></option>
	 			<?php } ?>
	 			</select>
			</td>
			</tr>
			<tr class="row1">
			<td class="tabledata1"><strong>Vendor Code</strong></td>
	   		<td><div id="hid-SupplierID"><input type="text" name="vendor_code"  value="<?php echo $vendor_code;?>" style="width:150px;"></div></td>
			
			<td class="tabledata1"><strong>Account Group</strong></td>
			<td>
  			<?php 
  			$acc_sql="SELECT * FROM accountgroupmaster WHERE GroupName REGEXP 'creditor'";
  			$acc_res=DB_query($acc_sql,$db);
  			$acc_row=DB_fetch_array($acc_res);
  			$AccountId=$acc_row['GroupId'];
  
 			$ledger_sql=DB_query("Select GroupId, GroupName from accountgroupmaster where MainGroupId='".$AccountId."' OR GroupId ='".$AccountId."'",$db);
   			?>
	 		<select name="account_group"  style="width:150px;">
			<?php while($ledger_row=DB_fetch_array($ledger_sql)) 
			{?>
 			<option Value="<?php echo $ledger_row['GroupId'];?>" <?php echo ($account_group==$ledger_row['GroupId']?'selected':'');?>><?php echo $ledger_row['GroupName'];?></option>
  			<?php }	?>  
        	</select></td>	
			</tr>
			
			<tr class="row1">
			<td class="tabledata1"><strong>Short Name</strong></td>
			<td><input type="text" name="short_name"  value="<?php echo $short_name;?>" style="width:150px;"></td>	
			<td class="tabledata1"><strong>Vendor Type</strong></td>
			<td>
			<select name="vendor_type" style="width:150px;">
            <option Value="Manufacturer" <?php echo ($vendor_type=='Manufacturer'?'selected':'');?>>Manufacturer</option>
			<option Value="Distributer" <?php echo ($vendor_type=='Distributer'?'selected':'');?>>Distributer</option>
			<option Value="Dealer" <?php echo ($vendor_type=='Dealer'?'selected':'');?>>Dealer</option>
			<option Value="Transporter" <?php echo ($vendor_type=='Transporter'?'selected':'');?>>Transporter</option>
			<option Value="Contractor" <?php echo ($vendor_type=='Contractor'?'selected':'');?>>Contractor</option>
			<option Value="Others" <?php echo ($vendor_type=='Others'?'selected':'');?>>Others</option>
            </select></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1"><strong> Website</strong></td>
			<td><input name="vendor_website" type="text" value="<?php echo $vendor_website;?>" style="width:150px;" /></td>
			<td class="tabledata1"><strong>Branch<font size="+1" color="#FF0000">*</font></strong></td>
	   		<td><?php 
	$ss1="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in ('".$_SESSION['AssignedBranch']."')";
	$site_sql=DB_query($ss1,$db);?>
	<select name="site" id="site" style="width:150px;"><!-- onchange="generate_reqno(this.value)"-->
	<option value="000">---Select---</option>
	<?php while($site_row=DB_fetch_array($site_sql)){?>
	<option value="<?php echo $site_row['loccode'];?>"<?php echo ($site==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
	<?php } ?>
	</select></td>	
			</tr>	
			</table>
	</div>
<!--end of Employee Detail box-->

<!--Academic box-->
	<div class="box">
	<table width="100%"  border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
			<td class="tabledata1" rowspan="3" width="19%"><strong>Address<font size="+1" color="#FF0000">*</font></strong></td>
			<td><input type="text" name="adrress1" id="adrress1"  value="<?php echo $adrress1;?>" style="width:150px;"></td>
			<td class="tabledata1"><strong>Pin Code</strong></td>
			<td><input type="text" name="pincode"  value="<?php echo $pincode;?>"style="width:150px;"></td>
			</tr>	
			<tr class="row1">
			<td><input type="text" name="adrress2" id="adrress2"  value="<?php echo $adrress2;?>" style="width:150px;"></td>
			<td class="tabledata1"><strong>Extension</strong></td>
	   		<td><input type="text" name="extension" value="<?php echo $extension;?>"style="width:150px;"></td>
			</tr>
			<tr class="row1">
			<td><input type="text" name="address3" id="address3"  value="<?php echo $address3;?>" style="width:150px;"></td>
			<td class="tabledata1"><strong>Phone1</strong></td>
			<td><input type="text" name="phone1" value="<?php echo $phone1;?>"style="width:150px;"></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1"><strong>City<font size="+1" color="#FF0000">*</font></strong></td>
					 <td>
						<select name="pre_city" id="pre_city" style="width:150px;" onchange="GetSatateCountry(this.value)">
						  <option value="">Select</option>
						  <?php 
						  $city_sql=DB_query("select * from city_master",$db);
						  while($city_row=DB_fetch_array($city_sql)) { ?>
						  <option value="<?php echo $city_row['id'];?>"<?php echo($city==$city_row['id']?'selected':''); ?>><?php echo $city_row['city'];?></option>
						  <?php } ?>
						</select>
					 </td>
		<td class="tabledata1"><strong>Phone2</strong></td>
		<td><input type="text" name="phone2" value="<?php echo $phone2;?>"style="width:150px;"></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1"><strong>State<font size="+1" color="#FF0000">*</font></strong></td>
					<td><input type="hidden" name="pre_state" id="pre_state" value="<?php echo $state; ?>" style="width:150px;" />
					<?php $STname=$s->GetFieldValue('state_master',"id='".$state."'",'state'); ?>
					<input type="text" name="pre_state1" id="pre_state1" value="<?php echo $STname; ?>" style="width:150px;" />
					</td>
		  <td class="tabledata1"><strong>Mobile</strong></td>
		  <td><input type="text" name="mobile" id="mobile" value="<?php echo $mobile;?>"style="width:150px;"></td>
		  </tr>
		<tr class="row1">
		<td class="tabledata1"><strong>Country<font size="+1" color="#FF0000">*</font></strong></td>
					 <td><input type="hidden" name="pre_country" id="pre_country" value="<?php echo $country; ?>" style="width:150px;" />
					 <?php $Conname=$s->GetFieldValue('country_master',"id='".$country."'",'country'); ?>
					 <input type="text" name="pre_country1" id="pre_country1" value="<?php echo $Conname; ?>" style="width:150px;" />
					 </td>
           <td class="tabledata1"><strong>Fax</strong></td>
           <td><input type="text" name="fax" style="width:150px;" value="<?php echo $fax;?>"></td> 
            </tr>
			<tr class="row1">
				<td></td><td></td>
		<td class="tabledata1"><strong>E-mail</strong></td>
	   <td><input name="email" type="text" value="<?php echo $email;?>" style="width:150px;"/></td>
	   </tr>
			</table>
	</div>
			<!--end of Academic box-->
			
			<!--Address box-->
	<div class="box">
	<table width="100%"  border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
	<td class="tabledata1"><strong>PAN No.</strong></td>
	<td><input type="text" name="pan_no" id="pan_no"  value="<?php echo $pan_no;?>"style="width:150px;"></td>
	<td class="tabledata1"><strong>Pay Terms</strong></td>
	   <td><select name="payterms" id="payterms" style="width:150px;">
	   <?php 
	   $result=DB_query('SELECT terms, termsindicator FROM paymentterms', $db);
	while ($myrow = DB_fetch_array($result)) 
	{	$p='';
		if($payterms==$myrow['termsindicator'])
		$p="selected";	
	?>
		<option value="<?php echo $myrow['termsindicator'];?>"<?php echo $p;?>><?php echo $myrow['terms']; ?></option>
	<?php } ?>
	</option></select></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>TIN No.</strong></td>
	<td><input type="text" name="tin_no" id="tin_no"  value="<?php echo $tin_no;?>"style="width:150px;"></td>	
	<td class="tabledata1"><strong>Tax Group</strong></td>
	     <td><select name="tax_group" id="tax_group" style="width:150px;">
		 		<option value="">Select</option>
             <?php 
	   $sql='SELECT salestax_id,tax_code FROM sales_tax_master';
	   $result=DB_query($sql,$db);
	   while($myrow = DB_fetch_array($result))
		   {
		   		$p='';
				if($tax_group==$myrow['salestax_id'])
				$p="selected";
		   ?>
             <option value="<?php echo $myrow['salestax_id'];?>"<?php echo $p;?>><?php echo $myrow['tax_code'];?></option>
             <?php  } ?>
         </select></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>LST No.</strong></td>
	<td><input type="text" name="lst_no" id="lst_no"  value="<?php echo $lst_no;?>"style="width:150px;"></td>
	<td class="tabledata1"><strong>Range</strong></td>
	<td><input type="text" name="sup_range" id="sup_range" value="<?php echo $sup_range;?>" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>CST No.</strong></td>
	<td><input type="text" name="cst_no" id="cst_no"  value="<?php echo $cst_no;?>"style="width:150px;"></td>
	<td class="tabledata1"><strong>Division</strong></td>
	<td><input type="text" name="sup_division" id="sup_division" value="<?php echo $sup_division;?>" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Excise No.</strong></td>
	<td><input type="text" name="excise_no" id="excise_no"  value="<?php echo $excise_no;?>"style="width:150px;"></td>
	<td class="tabledata1"><strong>TDS Section</strong></td>
	<td><select name="tds_selection" id="tds_selection" style="width:150px;" >
	  			<option value="000">Select Tax section</option>
	 			<?php
	 			$get_category=DB_query("Select * from tds_classification where parentid=0",$db);
				if(DB_num_rows($get_category)>0){
	 			while($cat_res=DB_fetch_array($get_category))
	 			{
	 			?>
	 			<option value="<?php echo $cat_res['id'];?>"<?php echo($tds_selection==$cat_res['id']?'selected':'')?>><?php echo $cat_res['TaxTitle'];?></option>
	 			<?php } }?>
 			  </select>
				
 </td>
</tr>
<!--<tr class="row1">
<td></td><td></td>
<td class="tabledata1">TDS Percentage:</td>
<td><input name="tds_percentage" type="text" id="tds_percentage" value="<?php echo $tds_percentage;?>" size="5" />
%</td>
</tr>-->
</table>
	</div>
			<!--end of Address box-->
	<div class="box">
	<table width="100%" cellpadding="3" cellspacing="0" border="0">
		<tr class="row1">
			<td class="tabledata1">
				<input type="button" onClick="addRow('dataTable')" value="Add More" class="search" />&nbsp;
				<input type="button" class="search"  onclick="deleteRow('dataTable')" value="Delete" />
			</td>
		</tr>
	</table>
	<table width="100%"  border="1" cellpadding="3" cellspacing="0" style="border:1px solid #333333;">
		<tr bgcolor="#c1c1c1">
			<td><strong>Sr No.</strong></td>
			<td><strong>Person Name</strong></td>
			<td><strong>Department</strong></td>
			<td><strong>Designation</strong></td>
			<td><strong>Contact No.</strong></td>
			<td><strong>Email Id</strong></td>
		</tr>
		<?php if($_REQUEST['ID']){$i=0;
			$conatctSQL=DB_query("SELECT * FROM contact_information_master where master_code='".$_REQUEST['ID']."' and master_prefix='S'",$db);
			while($ContactDetail=DB_fetch_array($conatctSQL)){?>
		 <tr bgcolor="#c1c1c1" id="hidrow_<?php echo $i; ?>">
		   <td style="text-align:center"><a href="#" onclick="delcontactperson(<?php echo $i; ?>)"><img src="images/delete1.Gif" /></a></td>
		   <td><input type="text" name="person[]" id="person_<?php echo $i; ?>" style="width:120px;"  value="<?php echo $ContactDetail['person'];?>"></td>
		   <td><select name="department[]" id="department_<?php echo $i; ?>" onchange='GetDesginationUser(this.value,this.id)' style="width:120px;">
		   			<option value="000">---Select---</option>
					<?php $qdepart=DB_query("select * from deptmaster where CompanyId='".$_SESSION['ACGCompanyId']."'",$db); 
					while($rsdepart=DB_fetch_array($qdepart)){?>
				<option value="<?php echo $rsdepart['id'];?>"<?php echo($ContactDetail['department']==$rsdepart['id']?'selected':'')?>><?php echo $rsdepart['deptname'];?></option>
				<?php }?>
		   </select></td>
		   <td>
		   <?php $sqlDesg=DB_query("select * from desigmaster Where mst_departmentid='".$ContactDetail['department']."'",$db);?>
		   <select name="designation[]" id="designation_<?php echo $i; ?>" style="width:120px;">
		   		<option value="">Select</option>
		   		<?php while($DesgDetails=DB_fetch_array($sqlDesg)){ ?>
		   		<option value="<?php echo $DesgDetails['id'];?>"<?php echo($ContactDetail['designation']==$DesgDetails['id']?'selected':''); ?>><?php echo $DesgDetails['designame'];?></option>
				<?php }?>
		   </select></td>
		   <td><input type="text" name="phone[]" style="width:90px;" value="<?php echo $ContactDetail['phone'];?>" size="15"></td>
		   <td><input type="text" name="contact_email[]" style="width:120px;"  value="<?php echo $ContactDetail['email'];?>"></td>
	  </tr>	
		<?php $i++;}}?>
		<input type="hidden" id="count1" value="<?php echo $i; ?>" />
		<tbody id='dataTable'>
	   	<tr bgcolor="#c1c1c1">
		   <td><input name='delitem[]' type='checkbox' value='' /></td>
		   <td><input type="text" name="person[]" id="person1" style="width:120px;"  value=""></td>
		   <td><select name="department[]" id="department" onchange='GetDesginationUser(this.value,this.id)' style="width:120px;">
		   			<option value="000">---Select---</option>
					<?php $qdepart=DB_query("select * from deptmaster where CompanyId='".$_SESSION['ACGCompanyId']."'",$db); 
					while($rsdepart=DB_fetch_array($qdepart)){?>
				<option value="<?php echo $rsdepart['id'];?>"<?php echo($department==$rsdepart['id']?'selected':'')?>><?php echo $rsdepart['deptname'];?></option>
				<?php }?>
		   </select></td>
		   <td><select name="designation[]" id="designation" style="width:120px;">
		   			<option value="">Select</option>
		   </select></td>
		   <td><input type="text" name="phone[]" id="phone" style="width:90px;" value="" ></td>
		   <td><input type="text" name="contact_email[]" id="contact_email" style="width:120px;"  value=""></td>
	  </tr>
	  </tbody>
	  <input type="hidden" name="counter" id="hiditemcount"  /> 	
</table>
	</div>		
			
			
			<!--Salary box-->
	<div class="box">
	<table width="100%"  border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
	<td class="tabledata1"><strong>Item Category</strong></td>
	<td><select name="item_main_category[]" id="item_main_category" multiple onchange="get_itemsubgroup()" >
		<option value="">Select</option>
		<?php $explmaincat=explode(",",$item_main_category);
		$m=0;
		$category_sql=DB_query("Select * from stockmaincategory",$db);
		while($category_row=DB_fetch_array($category_sql))
		{?>
			<option value="<?php echo $category_row['id'];?>" <?php if($explmaincat[$m]==$category_row['id'])echo "selected";?>><?php echo $category_row['stockmaincategoryname'];?></option>
		<?php 	
		$m++;}
		?>
	</select>
</td>
</tr>
	<tr class="row1">
	<td class="tabledata1" nowrap="nowrap"><strong>Sub Category</strong></td>
    <td id="sub_id"><div style="overflow:auto; height:100px; width:500px; border:1px solid; " >
	
    			<?php $sub_cats=explode(",",$item_sub_category);
		//print_r($sub_cats);
		$SubString=implode("','",$sub_cats);
		$Scategory_sql=DB_query("Select id,categoryid,categorydescription from stockcategory where id in ('".$SubString."')",$db);
		$c=0;
		while($Scategory_row=DB_fetch_array($Scategory_sql))
		{
			$checked='';
			
			for($x=0;$x<count($sub_cats);$x++)
			{	
			 	if($sub_cats[$x]==$Scategory_row['id'])
			 	$checked="checked";
			}
			
			
			?>
			<input type="checkbox" name="item_sub_category[<?php echo $c;?>]" id="item_sub_category_<?php echo $c;?>" value="<?php echo $Scategory_row['id'];?>" <?php echo $checked;?> onclick="get_item(this.value)" /><?php echo $Scategory_row['categoryid']." - ".$Scategory_row['categorydescription'];?><br />
			<input type="hidden" name="arrayItem" id="arrayItem_<?php echo $c;?>" value="<?php if(isset($assigned_items)){echo $assigned_items;}else{echo "";}?>" />
		<?php 	
		$c++;}
		?>

</div><input type="hidden" name="cnt" id="cnt" value="<?php echo $c;?>" /></td>
	</tr>
	<tr class="row1">
    <td class="tabledata1"><strong>Items</strong></td>
    <td><div id="itemid">
	<div style="overflow:auto; height:100px; width:500px; border:1px solid; " >
	<?php 
	$items=explode(",",$assigned_items);
	//print_r($items);
	$item_sql=DB_query("select id,StockID,item_name from item_master where SubCategoryID in ('".$SubString."')",$db);
	$c3=0;
	while($row3=DB_fetch_array($item_sql))
	{ 
		$checked='';
		for($x=0;$x<count($items);$x++)
		{	
			 if($items[$x]==$row3['id'])
			 $checked="checked";
		}
		
		
	?>
	<input type="checkbox" name="item[<?php echo $c3;?>]" id="item_<?php echo $c3;?>" value="<?php echo $row3['id'];?>" <?php echo $checked;?>/><?php echo $row3['StockID']." - ".$row3['item_name'];?><br />
	<?php 	
	$c3++;
	}
	?>
	</div>
	</div></td>
  </tr>	
</table>
	</div>
			<!--end of Salary box-->
			
			<!--Leave box-->
	<div class="box">
	<table width="100%"  border="0" cellpadding="3" cellspacing="0">
			<tr class="row1">
			<td class="tabledata1"><strong>Opening Balance</strong></td>
			<td><input type="text" name="openingBalance" id="openingBalance" style="width:150px;" value="<?php echo $openingBalance;?>"/></td>
			<td class="tabledata1"><strong>Opening Date</strong></td>
			<td><input name="openingdate" id="openingdate" type="text" value="<?php if($openingdate!=''){echo $openingdate;}else{ echo ConvertSQLDate($_SESSION['financialYrStart']);} ?>"  style="width:150px;"></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1"><strong>Opening Type</strong></td>
	   		<td><input name="openingtype" id="openingtypeDR" type="radio"  value="DR" <?php  echo ($openingtype=='DR'?'checked':'')?>  >DR
	<input name="openingtype" id="openingtypeCR" type="radio"  value="CR" <?php  echo ($openingtype=='CR'?'checked':'')?> >CR</td>
			</tr>
	</table>
	</div>
			<!--end of Leave box-->
			<!--Uploads box-->


</div>
	<div style="clear:both;"></div>
	</div>
</div>
 </form>
<script type="text/javascript">

	Element.cleanWhitespace('content');
	init();



function addRow(tableID) 
{
	if(document)
	if(document.getElementById("count1").value!='')
	{
		var edit_cnt=parseInt(document.getElementById("count1").value);
	}
	else
	{
	edit_cnt=1;
	}
	
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rowCount;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {	
	var newCount=parseInt(rowCount)+parseInt(edit_cnt)-1;
	//var newCount=parseInt(rowCount);
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+newCount;
	break;
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id_hidden = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+newCount;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+newCount;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id_chk = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+newCount;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+newCount;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	document.getElementById("stock_perunit_"+newCount).value='1';
	}
	
function deleteRow(tableID) 
{
		try 
		{
			var table = document.getElementById(tableID);
			//alert(table);
			var rowCount = table.rows.length;
			//alert(rowCount);
			for(var i=0; i<rowCount; i++) 
				{
					var row = table.rows[i];
					var chkbox = row.cells[0].childNodes[0];
					if(null != chkbox && true == chkbox.checked) 
					{
						if(rowCount <= 1) 
						{
							alert("Cannot delete all the rows.");
							break;
						}
					table.deleteRow(i);
					rowCount--;
					i--;
					}
					
				}
		document.getElementById("hiditemcount").value=parseInt(rowCount)-1;		
		}
		catch(e) 
		{
			alert(e);
		}

}	


function delcontactperson(i)
{
	document.getElementById("person_"+i).value='';
	document.getElementById("hidrow_"+i).style.display='none';
}

function validatefrm()
{
	if(document.getElementById("vendor_name").value=='')
	{
		alert("You Must Fill Vendor Name First !");
		document.getElementById("vendor_name").focus();
		return false;
	}
	if(document.getElementById("category").value=='000')
	{
		alert("You Must Fill Vendor Category First !");
		document.getElementById("category").focus();
		return false;
	}
	if(document.getElementById("site").value=='000')
	{
		alert("You Must Select The Branch First !");
		document.getElementById("site").focus();
		return false;
	}
	if(document.getElementById("adrress1").value=='')
	{
		alert("You Must Fill Address First !");
		document.getElementById("adrress1").focus();
		return false;
	}
	if(document.getElementById("pre_city").value=='')
	{
		alert("You Must Select The City First !");
		document.getElementById("pre_city").focus();
		return false;
	}
	//if(document.getElementById("mobile").value=='')
	//{
		//alert("You Must Fill MObile No First !");
		//document.getElementById("mobile").focus();
		//return false;
	//}
	//if(document.getElementById("pan_no").value=='')
	//{
		//alert("You Must Fill PAN No First !");
		//document.getElementById("pan_no").focus();
		//return false;
	//}
	//if(document.getElementById("payterms").value=='')
	//{
		//alert("You Must Select The Payment Terms First !");
		//document.getElementById("payterms").focus();
		//return false;
	//}
	//if(document.getElementById("tin_no").value=='')
	//{
		//alert("You Must Fill TIN No First !");
		//document.getElementById("tin_no").focus();
		//return false;
	//}
	//if(document.getElementById("tax_group").value=='')
	//{
		//alert("You Must Select The Tax Group First !");
		//document.getElementById("tax_group").focus();
		//return false;
	//}
	//if(document.getElementById("lst_no").value=='')
	//{
		//alert("You Must Fill LST No First !");
		//document.getElementById("lst_no").focus();
		//return false;
	//}
	//if(document.getElementById("sup_range").value=='')
	//{
		//alert("You Must Fill Range No First !");
		//document.getElementById("sup_range").focus();
		//return false;
	//}
	//if(document.getElementById("cst_no").value=='')
	//{
		//alert("You Must Fill CST No First !");
		//document.getElementById("cst_no").focus();
		//return false;
	//}
	//if(document.getElementById("sup_division").value=='')
	//{
		//alert("You Must Fill Division No First !");
		//document.getElementById("sup_division").focus();
		//return false;
	//}
	//if(document.getElementById("excise_no").value=='')
	//{
		//alert("You Must Fill Excise No First !");
		//document.getElementById("excise_no").focus();
		//return false;
	//}
	//if(document.getElementById("tds_selection").value=='000')
//	{
//		alert("You Must Select TDS Section First !");
//		document.getElementById("tds_selection").focus();
//		return false;
//	}
	if(document.getElementById("person1").value=='')
	{
		alert("You Must Fill Person Name First !");
		document.getElementById("person1").focus();
		return false;
	}
	if(document.getElementById("department").value=='000')
	{
		alert("You Must Select The Department First !");
		document.getElementById("department").focus();
		return false;
	}
	if(document.getElementById("designation").value=='' || document.getElementById("designation").value=='0')
	{
		alert("You Must Select The Designation First !");
		document.getElementById("designation").focus();
		return false;
	}
	if(document.getElementById("phone").value=='')
	{
		alert("You Must Fill Phone No First !");
		document.getElementById("phone").focus();
		return false;
	}
	if(document.getElementById("contact_email").value=='')
	{
		alert("You Must Fill Contact Email First !");
		document.getElementById("contact_email").focus();
		return false;
	}
	//if(document.getElementById("openingBalance").value=='')
	//{
		//alert("You Must Fill Opening Balance First !");
		//document.getElementById("openingBalance").focus();
		//return false;
	//}
	//if(document.getElementById("openingdate").value=='')
	//{
		//alert("You Must Fill Opening Date First !");
		//document.getElementById("openingdate").focus();
		//return false;
	//}
	//if(document.getElementById("openingtypeDR").checked==false && document.getElementById("openingtypeCR").checked==false)
	//{
		//alert("You Must Select Opening Type First !");
		//document.getElementById("openingdate").focus();
		//return false;
	//}
}
</script>