public without sharing class searchAimsAccount {
|
|
|
public String SearchName {get;set;}
|
private String accountid = null;
|
private String accName = null;
|
public List<Account> at {get;set;}
|
|
public searchAimsAccount() {
|
accountId = ApexPages.currentPage().getParameters().get('accId');
|
accName = ApexPages.currentPage().getParameters().get('accName');
|
}
|
|
public void init(){
|
String soql = makeSoql('',accountId);
|
at = Database.query(soql);
|
}
|
|
public PageReference serContact(){
|
at = Database.query(this.makeSoql(SearchName,accountid));
|
return null;
|
}
|
|
private String makeSoql(String searchName,String accountid){
|
|
String soql = 'SELECT id,Name,State_Master__c,State_Master__r.Name,Address__c FROM Account';
|
if (accountId != null && accountId != '') {
|
soql += ' where id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__c = :accountid and AgencyHos_ENG__c = true ) ' ;
|
|
}else{
|
soql += ' where id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__r.Name = :accName and AgencyHos_ENG__c = true ) ' ;
|
}
|
|
if(String.isNotBlank(searchName)){
|
soql += ' AND Name like \'%' + SearchName+ '%\'';
|
}
|
soql += ' order by Name desc limit 200 ';
|
return soql;
|
|
}
|
|
/*public List<Agency_Hospital_Link__c> ahlList;
|
public List<searchAgencyHospitalLink> AgencyHospitalLinkList { get; set; }
|
public List<Account> AccountList {get;set;}
|
public String accountId{get;set;}
|
public searchAimsAccount() {
|
accountId = ApexPages.currentPage().getParameters().get('accId');
|
|
AgencyHospitalLinkList = new List<searchAgencyHospitalLink>();
|
system.debug('accountId' + accountId);
|
}
|
|
public void init(){
|
system.debug(accountId + 'accountId');
|
ahlList = [select Hospital__c, Hospital__r.name,Agency__c from Agency_Hospital_Link__c where Agency__c = :accountId and AgencyHos_ENG__c = true limit 200 ];
|
for(Agency_Hospital_Link__c ahl_c : ahlList){
|
searchAgencyHospitalLink ahl = new searchAgencyHospitalLink(ahl_c);
|
AgencyHospitalLinkList.add(ahl);
|
}
|
|
}
|
class searchAgencyHospitalLink{
|
public Agency_Hospital_Link__c ahlc { get; set;}
|
public searchAgencyHospitalLink(Agency_Hospital_Link__c ahl_c){
|
ahlc = ahl_c;
|
}
|
}*/
|
}
|