ortunityStatus=data.opportunityStatus?data.opportunityStatus:[]
this.serviceLin=data.serviceLin?data.serviceLin:'' 
// this.serviceLine=data.serviceLine?data.serviceLine:[]
this.practiceNamee=data.practiceNamee?data.practiceNamee:'' 
this.practiceName=data.practiceName?data.practiceName:[]
this.verticalNam=data.verticalNam?data.verticalNam:'' 
// this.verticalName=data.verticalName?data.verticalName:[]
this.subVerticalNam=data.subVerticalNam?data.subVerticalNam:'' 
this.subVerticalName=data.subVerticalName?data.subVerticalName:[]
this.geoNam=data.geoNam?data.geoNam:''
// this.geoName=data.geoName?data.geoName:[]
this.regionNam=data.regionNam?data.regionNam:'' 
this.regionName=data.regionName?data.regionName:[]
this.allianceName=data.allianceName?data.allianceName:'' 
this.allianceId=data.allianceId?data.allianceId:''
// this.AllianceseArray=data.AllianceseArray 
this.selectedAllianceNameObj={SysGuid: data.allianceId?data.allianceId:'', Name: data.allianceName?data.allianceName:''};
this.competitorNam=data.competitorNam?data.competitorNam:''
// this.competitorName=data.competitorName?data.competitorName:[]
this.selectedIpRadio=data.selectedIpRadio?data.selectedIpRadio:''

this.ipName=data.ipName?data.ipName:''
this.ipId=data.ipId?data.ipId:''
// this.ipArray= data.ipArray 
this.SelectedIpObj= {SysGuid: data.ipId?data.ipId:'', Name: data.ipName?data.ipName:''}; 
}
}






createTempData(){

return {
opportunityName:this.opportunityName?this.opportunityName:'',
selectedAccNameObj:{SysGuid: this.accountId?this.accountId:'', Name: this.accountName?this.accountName:''},
accountName:this.accountName?this.accountName:'',
accountId:this.accountId?this.accountId:'',
// AccountnameArray:this.AccountnameArray,
opportunityStatusName:this.opportunityStatusName?this.opportunityStatusName:'',
// opportunityStatus:this.opportunityStatus?this.opportunityStatus:'',
serviceLin:this.serviceLin?this.serviceLin:'',
// serviceLine:this.serviceLine?this.serviceLine:'',
practiceNamee:this.practiceNamee?this.practiceNamee:'',
practiceName:this.practiceName?this.practiceName:[],
verticalNam:this.verticalNam?this.verticalNam:'',
// verticalName:this.verticalName?this.verticalName:'',
subVerticalNam:this.subVerticalNam?this.subVerticalNam:'',
subVerticalName:this.subVerticalName?this.subVerticalName:[],
geoNam:this.geoNam?this.geoNam:'',
// geoName:this.geoName?this.geoName:'',
regionNam:this.regionNam?this.regionNam:'',
regionName:this.regionName?this.regionName:[],
allianceName:this.allianceName?this.allianceName:'',
allianceId:this.allianceId?this.allianceId:'',
// AllianceseArray:this.AllianceseArray,
selectedAllianceNameObj:{SysGuid: this.allianceId?this.allianceId:'', Name: this.allianceName?this.allianceName:''},
competitorNam:this.competitorNam?this.competitorNam:'',
// competitorName:this.competitorName?this.competitorName:'',
selectedIpRadio:this.selectedIpRadio?this.selectedIpRadio:1,

ipName:this.ipName?this.ipName:'',
ipId:this.ipId?this.ipId:'',
// ipArray:this.ipArray,
SelectedIpObj:{SysGuid: this.ipId?this.ipId:'', Name: this.ipName?this.ipName:''},


}


}

  


  AppendRedisCache(data?) {
    this.service.SetRedisCacheData((data)? (data) : (this.createTempData()), 'opportunityFinder').subscribe(res => {

      if (!res.IsError) {
        console.log("SUCESS FULL AUTO SAVE")
      }
    }, error => {
      console.log(error)
    })
  }


getCacheData(){

this.service.GetRedisCacheData('opportunityFinder').subscribe(res => {
    
     if (!res.IsError) {
      this.bindData(JSON.parse(res.ResponseObject))
         } 
    else {
          
        } 
      })
    }

    getSymbol(data) {
      data = this.escapeSpecialChars(data);
      return unescape(JSON.parse('"' + data + '"')).replace(/\+/g,'');
    }
  
    escapeSpecialChars(jsonString) {
      return jsonString.replace(/\n/g, "\\n")
         .replace(/\r/g, "\\r")
         .replace(/\t/g, "\\t")
         .replace(/\f/g, "\\f");
  
  }
 
  ngOnInit() {

      if(localStorage.getItem('accountRoute') == '1' ){
    var name =    (localStorage.getItem('accountName'))? this.EncrDecr.get('EncryptionEncryptionEncryptionEn', localStorage.getItem('accountName'), 'DecryptionDecrip') : ''
this.selectedAccNameObj = { SysGuid: "(localStorage.getItem('accountSysId'))? this.EncrDecr.get('EncryptionEncryptionEncryptionEn', localStorage.getItem('accountSysId'), 'DecryptionDecrip') : ''", 
Name: (localStorage.getItem('accountName'))? this.EncrDecr.get('EncryptionEncryptionEncryptionEn', localStorage.getItem('accountName'), 'DecryptionDecrip') : '' }
this.accountId =  (localStorage.getItem('accountSysId'))? this.EncrDecr.get('EncryptionEncryptionEncryptionEn', localStorage.getItem('accountSysId'), 'DecryptionDecrip') : '';
this.accountName = this.getSymbol(name)?this.getSymbol(name):'';
}
else{
  this.accountId = ''
  this.accountName  = ''
  this.selectedAccNameObj = { SysGuid: '', Name: ''}
}

    this.getCacheData()
    this.opportunityStatusData();
    this.gainRoleApi()



  //   var orginalArray = this.allopportunities.getAll();
  //   orginalArray.subscribe((x: any[]) => {
  // console.log('tableNameTable',x);
  //     this.allopportunity = x;
  //   });
    var orginalOrderArray = this.allopportunities.getAllOrder();
    orginalOrderArray.subscribe((x: any[]) => {
      this.allorder = x;
    });



  }




   lookupdata = {
      tabledata: [],
      recordCount: 10,
      headerdata: [],
      Isadvancesearchtabs: false,
      controlName: '',
      lookupName:'',
      isCheckboxRequired : false,
      inputValue : '',
      TotalRecordCount :0,
      selectedRecord:[],
       nextLink:'',
      pageNo:1,
      isLoader:false,
      casesensitive:true

    };


    //  (this.selectedAllianceNameObj && Object.keys(this.selectedAllianceNameObj).length)
      selectedLookupData(controlName) {
        switch(controlName) {
          case  'alliances' : {
            return this.SelectedAllianceArray.length>0?this.SelectedAllianceArray:[]
          }
        case  'account' : {

            return this.SelectedAccountArray.length>0?this.SelectedAccountArray:[]
          }
     case  'IP' :