<?php
$PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
$q=$_GET['q'];
/*$CHKLed = DB_query("SELECT AccountsID,AccountName  FROM accountledger  WHERE AccountsID='".$q."' and  SubLedger='1'",$db);
if(DB_num_rows($CHKLed)>0)
{
//echo "SELECT LedgerId,SubLedgerName  FROM mastersubledger  WHERE UnderLedger='".$q."'";
   		$result_ledger = DB_query("SELECT LedgerId,SubLedgerName  FROM mastersubledger  WHERE UnderLedger='".$q."'",$db);
 		if( DB_num_rows($result_ledger)>0 )
		{
  			?>
 			SubLedger: 
			<select name="clientid" tabindex="5"  >
			<option value="0">Please select Ledger</option>
			<?php 			
 			while($myrow_ledger = DB_fetch_row($result_ledger))
			{
			  $p='';
			  if($myrow_ledger[0]==$clientid)
			  $p="selected";
			?>
			<option value="<?php echo $myrow_ledger[0]; ?>"<?php echo $p; ?>><?php echo $myrow_ledger[1]; ?></option>
			<?php }?>
			</select>
			
			<?php }
		}	*/		
//$result_ledger = DB_query("SELECT id,c_name  FROM clientmaster  WHERE ledger_id='".$q."'",$db);

$sql="SELECT AccountsID,AccountName,UnderGroup FROM accountledger  WHERE AccountsID='".$q."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$accountgroup=$row['UnderGroup'];

$accountgroup_sql="Select GroupName from accountgroupmaster where GroupId='".$accountgroup."'";
$accountgroup_result=DB_query($accountgroup_sql,$db);
$accountgroup_row=DB_fetch_array($accountgroup_result);
$groupname=$accountgroup_row['GroupName'];

//echo "SELECT vendor_code,vendor_name  FROM suppliers  WHERE account_group='".$q."'";	
	$result_ledger = DB_query("SELECT vendor_code,vendor_name  FROM suppliers  WHERE account_group='".$q."'",$db);
			 if(DB_num_rows($result_ledger)>0)
			 {
			 ?>
			 <span style="font-weight: bold"><strong>Vendor:</strong></span> 
<select name="vendorid" tabindex="5" >
  <option value="0">Select</option>
  <?php 			
 			while($myrow_ledger=DB_fetch_array($result_ledger))
			{
			  $p='';
			  if($myrow_ledger[0]==$vendorid)
			  $p="selected";
			?>
  <option value="<?php echo $myrow_ledger['vendor_code']; ?>"><?php echo $myrow_ledger['vendor_name']; ?></option>
  <?php }?>
  </select>
			 
			 <?php }
			 
			 
			 
		//echo "SELECT client_code,id,c_name  FROM clientmaster where ledger_id='".$q."' "; 
		 $result_ledger11 = DB_query("SELECT client_code,id,c_name  FROM clientmaster where ledger_id='".$q."' ",$db);
		if(DB_num_rows($result_ledger11)>0 )
		{
		?>
		     <span style="font-weight: bold"><strong>Clients:</strong></span> 
<select name="clientid" tabindex="5" >
  <option value="0">Select</option>
  <?php 			
		while($myrow_ledger11 = DB_fetch_row($result_ledger11))
		{
		$p='';
		if($myrow_ledger11['0']==$clientid)
		$p="selected";
		?>
  <option value="<?php echo $myrow_ledger11[0]; ?>"<?php echo $p; ?>><?php echo $myrow_ledger11[2]; ?></option>
  <?php }?>
  </select>
		<?php }?>