<?php 
session_name('CAKEPHP'); session_start(); 
$PageSecurity = 4;
include('includes/session.inc');
include('includes/function_lib.php');

//$user_id = $_SESSION['ACG_DashBoard_User'];
if($_REQUEST['str']=='Enquiry'){
$sql="Select * from crm_leads where Convert_IntoAccountStatus='Y' and Quotes_Status='N' and mst_branchid='".$_REQUEST['site']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and company_name='".$_REQUEST['client_id']."' order by leadid";
$result=DB_query($sql,$db);
$data1='';

$data1.="<select name='leadid' id='leadid' style='width:150px;' onchange='GetLeadRecord(this.value)' >
<option value='0'>Select Lead</option>";

while($myrow=DB_fetch_array($result))
{

$data1.="<option value=".$myrow['leadid'].">".$myrow['leadcode']."</option>";
}
 $data1.="</select>";
 
 $data2='';
 
 $sql1="Select pre_mobile from clientmaster where  id='".$_REQUEST['client_id']."'";
 $result1=DB_query($sql1,$db);
 $mbile=DB_fetch_array($result1);
 $mobile=$mbile['pre_mobile'];
 $data2.="<input type='text' name='partyContact2' style='width:150px;' value=".$mobile.">";
 
 
 echo $data=$data1."__".$data2;
 }
elseif($_REQUEST['str']=='lead'){

 $sql="Select * from crm_leads where Convert_IntoAccountStatus='N' and mst_branchid='".$_REQUEST['site']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and company_name='".$_REQUEST['client_id']."' and EST_Status=0 order by leadid";
$result=DB_query($sql,$db);
$data1='';
/* */
$data1.="<select name='lead_ref_no' id='lead_ref_id' style='width:100%;' onchange='GetLeadRecord(this.value)'> 
<option value=''>Select Lead</option>";

while($myrow=DB_fetch_array($result))
{

$data1.="<option value=".$myrow['leadid'].">".$myrow['leadcode']."</option>";
}
 $data1.="</select>";

 echo $data=$data1;
 }
elseif($_REQUEST['str']=='Estimation Against Bom')
 {
 $SQLE=DB_query("SELECT * FROM cstest_estimation_bom where branch='".$_REQUEST['site']."' and client='".$_REQUEST['client_id']."'
  and est_status=0 ",$db);
	
	$data1.="<select name='leadid' id='leadid' style='width:150px;' onchange='GetEstimationRecord2(this.value)' >
<option value='0'>Select Estimation</option>";

	while($myrowE=DB_fetch_array($SQLE))
	{

		$data1.="<option value=".$myrowE['id'].">".$myrowE['sheet_no']."</option>";
	}
	
	$data1.="</select>";
	
	 $data2='';
	 $sql1="Select pre_mobile from clientmaster where  id='".$_REQUEST['client_id']."'";
	 $result1=DB_query($sql1,$db);
	 $mbile=DB_fetch_array($result1);
	 $mobile=$mbile['pre_mobile'];
	 $data2.="<input type='text' name='partyContact2' style='width:150px;' value=".$mobile.">";
	 echo $data=$data1."__".$data2;
 
 }
 else
 {
 	$SQLE=DB_query("SELECT * FROM estimation_sheet where branch='".$_REQUEST['site']."' and client='".$_REQUEST['client_id']."'",$db);
	
	$data1.="<select name='leadid' id='leadid' style='width:150px;' onchange='GetEstimationRecord(this.value)' >
	
<option value='0'>Select Estimation</option>";


	while($myrowE=DB_fetch_array($SQLE))
	{

		$data1.="<option value=".$myrowE['id'].">".$myrowE['sheetno']."</option>";
	}
	
	$data1.="</select>";
	
	 $data2='';
	 $sql1="Select pre_mobile from clientmaster where  id='".$_REQUEST['client_id']."'";
	 $result1=DB_query($sql1,$db);
	 $mbile=DB_fetch_array($result1);
	 $mobile=$mbile['pre_mobile'];
	 $data2.="<input type='text' name='partyContact2' style='width:150px;' value=".$mobile.">";
	 echo $data=$data1."__".$data2;
 }