<?php class Client_Master
	{
 		public function Client_Master()  
		{
		 
		}
		   function Client($title,$selclientid)
		   { 
		    
					global $db;
					$ClientSQL=DB_query("Select * from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site='".$_SESSION['AssignedBranch']."' 
		and Zone in(".$_SESSION['AssignedSites'].")",$db);		
					if(!$ClientSQL)
					{
					   die('Error.'.DB_error_msg($db));
					}
  					echo "<select name='".$title."' style='width:120px' >";
					echo "<option value='000' selected='selected' >--Select Client--</option>";
					while($Row=DB_fetch_array($ClientSQL))
					{
					   $p='';
					   if($Row['id']==$selclientid){
					   $p='selected';
					  echo "<option value='".$Row['id']."' selected='".$p."'  > "  .$Row['c_name']."</option>";
					  }else{
					  echo "<option value='".$Row['id']."'   > "  .$Row['c_name']."</option>";
					  }
					}
					echo "</select>";
			}
			
			function GetClientByLedger($pid)
			{
				global $db;
				$s=new db_query();
				//echo "Select vender_client,ledgertype from accountledger where AccountsID='".$pid."'";
				$AccountSql=DB_query("Select vender_client,ledgertype from accountledger where AccountsID='".$pid."'",$db);
				$AccountRes=DB_fetch_array($AccountSql);
				if($AccountRes['ledgertype']=='leads')	{
				$clientids= $s->GetFieldValue('crm_leads',"leadid='".$AccountRes['AccountName']."'  ",'company_name'); 
				 $client_name= $s->GetFieldValue('clientmaster',"id='".$clientids."'  ",'c_name'); }
				 else
				  $client_name= $s->GetFieldValue('clientmaster',"id='".$AccountRes['vender_client'] ."'  ",'c_name');
				  
				  return( $client_name);
				
			}
			
			
		 
		 
	
	}
	
	$Class_Client=new Client_Master();
	?>
